0.8.6 • Published 4 years ago
kelch v0.8.6
Kelch
Kelch enables you to build REST API incredibly easily using JavaScript and AWS Serverless Application Model. Kelch deploys your REST API codes written by JavaScript to AWS Lambda and deploys and configs AWS API Gateway.
You can use Kelch and deploy your REST API code to your AWS account by following steps.
How to use
Install Kelch:
$ npm install -g kelch
Make directory for codes:
$ mkdir kelch-sample && cd kelch-sample
Generate a sample code and config file:
$ kelch init
$ ls
kelch-config.json sample.js
Create REST APIs (sample.js):
// You can define functions corresponding to each HTTP method
function get(req) {
// By returning value as it is, Kelch will return Http status code 200 and body containing returned value
return 'Hello Kelch !!';
}
function post(req) {
// You can get body, query string values, path parameters etc. from req passed by Kelch
var body = req.body;
}
function put(req) {
// You can set HTTP status code you want to return
return { statusCode: 204 };
}
// You don't need to prepare all HTTP method functions
// function del(req) {
// }
Deploy created Rest APIs:
$ kelch deploy
...
REST APIs URL:
https://[api-gateway-no].execute-api.[aws-region].amazonaws.com/api/sample
AWS Lambda functions and AWS API Gateway will be deployed to your AWS account. API endpoint is defined according to file name (ex: deployed sample.js can be accessed via https://[endpoint]/api/sample)
Command Help
Usage: kelch COMMAND [ARGS]...
Options:
--version
--help
Commands:
init
--stack-name (optional)
--s3-bucket (optional)
create-resource
--name (required)
create-config
--stack-name (optional)
--s3-bucket (optional)
deploy
--stack-name (optional)
--s3-bucket (optional)
delete
--stack-name (optional)