aws-http-api-gateway
v0.1.4
Published
A Framework to handle AWS HTTP APIs with AWS Lambda
Downloads
1
Maintainers
Readme
AWS HTTP API Gateway Framework
AWS API Gateway - HTTP API Framework -- Also called API Gateway v2.
A framework to easily implement HTTP APIs in AWS API Gateway. Implement CRUD operations in less than 100 lines of code!
Test a working demo for your own with this repo.
Docs
The framework complete docs can be found here.
Quick start
- Install via npm
npm i aws-http-api-gateway
- Setup your serverless function
# serverless.yml
service:
name: PetStore
provider:
name: aws
runtime: nodejs12.x
functions:
PetsGetManyApi:
handler: src/apis/pets/get-many.handler
events:
- httpApi: 'GET /pets'
- Code your handler
// src/apis/pets/get-many.js
'use strict';
const { GetManyApi, ApiHandler } = require('aws-http-api-gateway');
const PetConnector = require('../../connectors/pets');
const petConnector = new PetConnector();
class PetGetManyApi extends GetManyApi {
get dataConnector() {
return petConnector;
}
};
module.exports.handler = ApiHandler(PetGetManyApi);
- Code your data connector (implement with your favorite database)
'use strict';
const dbHandler = require('some-db-handler');
module.exports = class PetsConnector {
get(getParams) {
return dbHandler.get(getParams);
}
};
- You're ready to go. Just deploy your service!
serverless deploy