If you’re building serverless applications on AWS Lambda, handling routing, middleware, and errors can quickly get messy. Enter Zapix – a lightweight, TypeScript-friendly router designed specifically for Lambda.
Why Zapix?
- Minimal router supporting
get,post,put,patch,delete,options, andallmethods - Middleware chaining similar to Express.js – validate, authenticate, or transform requests easily
-
Global error handling with
router.useErrorfor centralized control -
Safe and consistent HTTP responses with the
Response()utility - Fully typed for TypeScript, providing IntelliSense and safer code
Key Features
- Middleware & Handlers – chain multiple middlewares before hitting your main controller.
- Centralized Error Handling – catch validation errors, JS errors, and more in one place.
- Type Safety – request and response objects are strongly typed.
-
Utilities –
safeJsonParsefor JSON safety andResponse()for unified responses.
Getting Started
Install Zapix via npm:
npm install zapix
Example usage:
import { Router, Handler } from 'zapix';
const router = new Router();
router.post('/users', createUser);
router.get('/users', readUsers);
router.get('/users/{userId}', readUserInfo);
router.put('/users/{userId}', updateUser);
router.delete('/users/{userId}', deleteUser);
// Fallback route
router.all(() => ({
statusCode: 404,
body: JSON.stringify({ error: 'Route not found' }),
}));
export const handler = Handler(router);
Zapix makes it simple to write clean, maintainable Lambda functions without losing type safety or flexibility.
Try it out
Check out the repo and documentation here: https://www.npmjs.com/package/zapix
Tags: #AWS #Serverless #AWSLambda #TypeScript #NodeJS #WebDevelopment #OpenSource #DeveloperTools
Top comments (0)