https://github.com/griffinsauce/netlify-lambda-router
An express-like router for Netlify lambda functions.
https://github.com/griffinsauce/netlify-lambda-router
express lambda-functions netlify netlify-functions netlify-lambda
Last synced: 8 days ago
JSON representation
An express-like router for Netlify lambda functions.
- Host: GitHub
- URL: https://github.com/griffinsauce/netlify-lambda-router
- Owner: GriffinSauce
- Created: 2019-11-26T19:51:33.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-13T15:10:47.000Z (over 4 years ago)
- Last Synced: 2025-01-23T03:30:50.182Z (5 months ago)
- Topics: express, lambda-functions, netlify, netlify-functions, netlify-lambda
- Language: JavaScript
- Size: 131 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# netlify-lamba-router
An express-like router for Netlify lambda functions.
Just one dependency: `path-to-regexp`. The same library that express uses to parse/match paths.
## Status
While this worked fine for early versions of my app, I have moved from Netlify to Zeit Now where routing is filesystem based. This repo is currently unmaintained.
## Usage
```.js
const router = require('netlify-lambda-router')(); // Not quite, it's not published to NPM (yet)router.get('/things/:id', async (req) => {
const thing = await getThing(req.params.id);
return {
statusCode: 200
body: JSON.stringify(thing)
}
})exports.handler = router.handle;
```The signature is similar to express but instead of a `res` we simply return an object. More info on the return object in the [functions notes](FUNCTIONS.md).
## Todo
- mimic req better by translating event props
- document handlers and return value
- move cleanPath to an option
- document that it won't 404 by default _or_ return 404License: MIT