
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@codeinkit/http-trigger
Advanced tools
A simple HTTP server for handling API routes with support for URL parameters, CORS, and static file serving.
:paramName syntaxYou can define routes with dynamic parameters using the :paramName syntax:
// Example route file: users/[id].ts
export const triggers = [
{
type: 'http',
method: 'GET',
path: '/users/:id'
}
];
export default async function(data: any, unsafe: any) {
const { id } = data; // URL parameter is available in data
return {
status: 200,
response: { userId: id, message: `User ${id} details` }
};
}
/users/:id - matches /users/123, /users/abc, etc./posts/:postId/comments/:commentId - matches /posts/123/comments/456/api/products/:category/:productId - matches /api/products/electronics/laptopimport HttpTrigger from './src/index';
const httpTrigger = new HttpTrigger(flows, unsafe, {
origin: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type', 'Authorization']
}, './public');
await httpTrigger.registerFolder('./routes');
httpTrigger.listen(3000);
Routes are defined in TypeScript files with the following structure:
export const triggers = [
{
type: 'http',
method: 'GET', // HTTP method (GET, POST, PUT, DELETE, etc.)
path: '/api/users/:id' // Route path with optional parameters
}
];
export default async function(data: any, unsafe: any) {
// data contains:
// - URL parameters (e.g., { id: '123' })
// - Query parameters (e.g., { page: '1', limit: '10' })
// - Request body (if parsed)
// unsafe contains:
// - req: http.IncomingMessage
// - res: http.ServerResponse
// - headers: request headers
return {
status: 200,
response: { message: 'Success' },
headers: { 'Custom-Header': 'value' }, // optional
redirect: '/new-location', // optional
httpSent: false // set to true if you manually send response
};
}
Use the provided helper functions to parse request bodies:
import { handleJson, handleUrlEncodedExtended } from './src/index';
export default async function(data: any, unsafe: any) {
// Parse JSON body
const jsonData = await handleJson(data, unsafe);
// Parse URL-encoded form data
const formData = await handleUrlEncodedExtended(data, unsafe);
return {
status: 200,
response: { received: jsonData.body }
};
}
FAQs
A basic TypeScript project
The npm package @codeinkit/http-trigger receives a total of 6 weekly downloads. As such, @codeinkit/http-trigger popularity was classified as not popular.
We found that @codeinkit/http-trigger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.