@dotcook/lambda-api
v1.0.7
Published
``` npm i @dotcook/lambda-api ```
Downloads
22
Readme
install
npm i @dotcook/lambda-api
Simple Example
const Joi = require('@hapi/joi');
const { Api, Validate } = require('@dotcook/lambda-api');
module.exports = {
hello: Api(async (event, context) => {
return {
hi: '123',
};
}),
apiWithCustomStatusCode: Api(async (event, context) => {
return {
statusCode: 201,
result: {},
}
}),
apiWithValidation: Api(Validate({
path: {
ids: Joi.string().required(),
},
query: {
page: Joi.number().optional(),
},
body: {
operation: Joi.any(),
},
}), async (event) => {
return {
body: event.body,
query: event.queryStringParameters,
path: event.pathParameters,
}
}),
};