UNPKG

ts-lambda-local-dev

Version:
29 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const local_lambda_1 = require("../local.lambda"); // handler is a function that takes in an event and context and returns a response const handler = async (req, context) => { var _a; return ({ statusCode: 200, body: `Hello World !!! My userId is ${(_a = req.pathParameters) === null || _a === void 0 ? void 0 : _a.id}\n My JWT is ${JSON.stringify(req.requestContext.authorizer.lambda.jwt)}.` }); }; // context is provided as optional field in config. const config = { handler, port: 8000, requestContext: { authorizer: { lambda: { jwt: { claims: { sub: '1234567890', name: 'John Doe', iat: 1516239022, }, scopes: ['read', 'write'], }, }, }, }, pathParamsPattern: '/user/:id', // optional, default to '/' }; // visit http://localhost:8000/user/1234567890 to see the response const localLambda = new local_lambda_1.LocalLambda(config); localLambda.run(); //# sourceMappingURL=index.js.map