@crazyrabbitltc/railway-mcp
Version:
Railway MCP Server - 146+ tools with 100% Railway API coverage, comprehensive MCP testing framework, and real infrastructure management through AI assistants. Enhanced version with enterprise features, based on original work by Jason Tan.
175 lines (174 loc) • 4.35 kB
JavaScript
export class WebhookRepository {
client;
constructor(client) {
this.client = client;
}
async list(projectId) {
const query = projectId ? `
query listProjectWebhooks($projectId: String!) {
project(id: $projectId) {
webhooks {
edges {
node {
id
url
projectId
events {
type
enabled
}
isActive
lastDeliveryStatus
lastDeliveryAt
createdAt
updatedAt
}
}
}
}
}
` : `
query listWebhooks {
webhooks {
edges {
node {
id
url
projectId
events {
type
enabled
}
isActive
lastDeliveryStatus
lastDeliveryAt
createdAt
updatedAt
}
}
}
}
`;
const response = await this.client.request(query, projectId ? { projectId } : undefined);
const webhooksData = projectId ? response.project?.webhooks : response.webhooks;
return webhooksData?.edges.map(edge => edge.node) || [];
}
async get(webhookId) {
const query = `
query getWebhook($webhookId: String!) {
webhook(id: $webhookId) {
id
url
projectId
events {
type
enabled
}
isActive
lastDeliveryStatus
lastDeliveryAt
createdAt
updatedAt
}
}
`;
const response = await this.client.request(query, { webhookId });
return response.webhook;
}
async create(input) {
const query = `
mutation webhookCreate($input: WebhookCreateInput!) {
webhookCreate(input: $input) {
id
url
projectId
events {
type
enabled
}
isActive
createdAt
updatedAt
}
}
`;
const response = await this.client.request(query, { input });
return response.webhookCreate;
}
async update(webhookId, input) {
const query = `
mutation webhookUpdate($webhookId: String!, $input: WebhookUpdateInput!) {
webhookUpdate(id: $webhookId, input: $input) {
id
url
projectId
events {
type
enabled
}
isActive
lastDeliveryStatus
lastDeliveryAt
updatedAt
}
}
`;
const response = await this.client.request(query, { webhookId, input });
return response.webhookUpdate;
}
async delete(webhookId) {
const query = `
mutation webhookDelete($webhookId: String!) {
webhookDelete(id: $webhookId)
}
`;
const response = await this.client.request(query, { webhookId });
return response.webhookDelete;
}
async test(webhookId) {
const query = `
mutation webhookTest($webhookId: String!) {
webhookTest(id: $webhookId) {
id
webhookId
status
responseCode
responseTime
event {
type
payload
}
deliveredAt
createdAt
}
}
`;
const response = await this.client.request(query, { webhookId });
return response.webhookTest;
}
async getDeliveries(webhookId, limit = 50) {
const query = `
query getWebhookDeliveries($webhookId: String!, $limit: Int) {
webhookDeliveries(webhookId: $webhookId, first: $limit) {
edges {
node {
id
webhookId
status
responseCode
responseTime
event {
type
payload
}
deliveredAt
createdAt
}
}
}
}
`;
const response = await this.client.request(query, { webhookId, limit });
return response.webhookDeliveries.edges.map(edge => edge.node);
}
}