Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@everestate/serverless-router
Advanced tools
Serverless Router
npm install @everestate/serverless-router --save
To use serverless-router
you will need at least one of its plugins.
const ServerlessRouter = require('@everestate/serverless-router');
const ServerlessRouterWebPlugin = require('@everestate/serverless-router-plugin-web');
const router = new ServerlessRouter([ServerlessRouterWebPlugin]);
router.web
.get('/users/:userId/appointments', (event, context, callback) => {
const appointments = findAppointmentsByUserId(event.pathParameters.userId);
return callback(null, {
statusCode: '200',
body: JSON.stringify({ appointments }),
});
})
.post('/users/:userId/appointments', (event, context, callback) => {
const { userId } = event.pathParameters;
const appointment = createAppointment({ ...event.body, userId });
return callback(null, {
statusCode: '201',
body: JSON.stringify({ appointment }),
});
})
.delete('/users/:userId/appointments/:appointmentId', (event, context, callback) => {
const { appointmentId } = event.pathParameters;
deleteAppointmentById(appointmentId);
return callback(null, {
statusCode: '204',
body: '',
});
});
router.dispatch(event, context, callback);
serverless-router
has default handler to catch mismatching request.
It responds with status
404
and { message: "ServerlessRouter can't find this route" }
in the body.
Of course it's possible to define your custom mismatch handler:
router.mismatch((event, context, callback) => {
const { path, httpMethod } = event;
console.log(`ServerlessRouter mismatch: ${httpMethod} ${path}`);
return callback(null, {
statusCode: '500',
body: '',
});
});
There are few implementations for testing purposes you might be interesting in:
lib/__tests__/__fixtures__/EvenOddPlugin.js
lib/__tests__/__fixtures__/TypePlugin.js
lib/__tests__/__fixtures__/WeekdayPlugin.js
@TODO: describe plugin implementation principles
MIT
FAQs
Serverless, minimalist, pluggable, universal router.
The npm package @everestate/serverless-router receives a total of 8 weekly downloads. As such, @everestate/serverless-router popularity was classified as not popular.
We found that @everestate/serverless-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.