@rushvora/claudia-local-api
v1.1.1
Published
Command line utility to launch Express local API for claudia-api-builder. Test drive your lambda functions before deployment
Downloads
13
Maintainers
Readme
claudia-local-api
Command line utility to launch Express local API for claudia-api-builder. Test drive your lambda functions before deployment
npm install --save-dev claudia-local-api
To install globally:
npm install --global claudia-local-api
Usage
If you have a claudia
and claudia-api-builder
app/server named lib/app.js
ready for deployment and you want to test it locally:
'use strict';
const ApiBuilder = require('claudia-api-builder');
function handleGetRequest(app, req) {
return new app.ApiResponse('OK', {
called: 'handleGetRequest'
}, 200);
}
function handlePostRequest(app, req) {
return new app.ApiResponse('OK', {
called: 'handlePostRequest'
}, 201);
}
function bootstrap() {
const app = new ApiBuilder();
app.get('/', handleGetRequest.bind(null, app));
app.post('/', handlePostRequest.bind(null, app));
return app;
}
module.exports = bootstrap();
You can install claudia-local-api
and run the command line Express API to test out the lambda function locally:
claudia-local-api --api-module lib/app.js
Or add into your package.json
:
"server": "claudia-local-api --api-module lib/app.js"
This will start up a local Express server on port 3000 to proxy requests to your claudia-api-builder
app.
For full list of options:
claudia-local-api --help