0.0.1 • Published 1 year ago

@valora/http-handler v0.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@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)