npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

railway-deploy-hook

v1.0.2

Published

Simple Railway Function to enable Webhook Deploys

Readme

Railway Deploy Hook

Overview

This service provides a webhook endpoint that triggers redeployment of Railway services. It uses the Railway GraphQL API and is designed to be deployed as a Railway Function.

Setup & Deployment

1. Create Railway Function

  1. Go to Railway and log in
  2. Create a new project or select an existing one
  3. Click "New" → "Function"

2. Add Code

Copy the entire contents of the index.js file from this repository and paste it into your Railway Function:

3. Configure Environment Variable

  1. Go to the "Variables" tab in your Railway Function
  2. Add a new variable:
    • Name: RAILWAY_API_TOKEN
    • Value: Your Railway API Token

Creating a Railway API Token

  1. Go to Railway Dashboard
  2. Click on your profile (top right) → "Account Settings"
  3. Navigate to "Tokens" in the sidebar
  4. Click "Create New Token"
  5. Give the token a name (e.g., "Deploy Hook")
  6. Copy the generated token and add it as the RAILWAY_API_TOKEN variable

4. Deploy Function

  1. Click "Deploy" in your Railway Function
  2. Wait for the deployment to complete
  3. Copy the URL of your deployed Function

Usage

Calling the Webhook

Send a POST request to your webhook endpoint with the required query parameters:

POST https://your-function-subdomain.railway.app/webhook?environmentId=ENVIRONMENT_ID&serviceId=SERVICE_ID

Parameters

  • environmentId: The ID of the Railway environment where the service is located
  • serviceId: The ID of the Railway service to redeploy

Example Request

curl -X POST "https://your-function-url.railway.app/webhook?environmentId=c3b077f3-feb0-448f-80b4-ccdae37a6fb5&serviceId=952f84ee-e0e7-4c76-92df-88e3cfe52e0d"

Finding Service and Environment IDs

  1. Go to your Railway project
  2. Select the desired environment
  3. Click on the service you want to deploy
  4. Go to "Settings" → "General"
  5. You'll find the IDs under "Service ID" and "Environment ID"

Health Check

Check if your service is running:

curl https://your-function-url.railway.app/health

Expected response:

{
  "status": "ok"
}

API Responses

Successful Request

{
  "success": true,
  "message": "Service 952f84ee-e0e7-4c76-92df-88e3cfe52e0d redeployed in environment c3b077f3-feb0-448f-80b4-ccdae37a6fb5"
}

Bad Request

{
  "error": "Missing required query parameters: environmentId, serviceId"
}

Server Error

{
  "error": "Error message",
  "details": "Detailed error information"
}

Automation

You can integrate this webhook into various CI/CD pipelines or automation tools:

  • GitHub Actions: Call the webhook after successful tests
  • Zapier/Make: Connect with other services
  • Cron Jobs: Schedule regular deployments
  • Monitoring Tools: Trigger deployments based on metrics

Troubleshooting

Common Issues

  1. 401 Unauthorized: Check your RAILWAY_API_TOKEN
  2. 400 Bad Request: Make sure both query parameters (environmentId and serviceId) are present
  3. 500 Internal Server Error: Check the logs in your Railway Function

Viewing Logs

  1. Go to your Railway Function
  2. Click on the "Deployments" tab
  3. Click on the current deployment
  4. Scroll to the "Logs" to diagnose errors

Security

  • ⚠️ Keep your RAILWAY_API_TOKEN secret
  • 🔒 The token has access to your entire Railway account
  • 🛡️ Consider implementing authentication for the webhook endpoint in production environments

Support

For issues or questions:

  1. Check the Railway Function logs
  2. Make sure all environment variables are set correctly
  3. Verify that the service and environment IDs are correct

Note: This service uses the Railway GraphQL API v2. Make sure your API token has the necessary permissions for service deployments.