@valora/http-handler
v0.0.1
Published
Handle logging and errors in your Google Cloud Function HTTP endpoint implementations.
Downloads
8,999
Keywords
Readme
@valora/http-handler
Handle logging and errors in your Google Cloud Function HTTP endpoint implementations.
Development
Install dependencies:
yarn
Run tests:
yarn test
Using
Add @valora/http-handler:
yarn add @valora/http-handler
Define your HttpFunction
:
import {
HttpFunction,
Request,
Response,
} from '@google-cloud/functions-framework/build/src/functions'
import { createLogger } from '@valora/logging'
import { asyncHandler } from '@valora/http-handler'
// Any Bunyan logger
const logger = createLogger()
const requestHandler: HttpFunction = async (req: Request, res: Response) => {
res.status(200).send({ message: 'hello' })
}
const export helloCloudFunctionHandler = asyncHandler(requestHandler, logger)