openapi-node-function-template

1.5.1 • Public • Published

OpenAPI 3 function template

Build Status OpenFaaS OpenAPInpm version npm downloads

Do you want to build a microservice based on OpenAPI 3 specification? Do you hate writing all the boilerplate endpoint code? Or do you need your neat serverless function? Running on OpenFaaS or another serverless provider?

You came to the right place.

OpenAPI Node Function Template is a single dependency along your OpenAPI 3 specification file you actually need in order to run your service!

  • ✅ generated OpenAPI 3 REST endpoint
  • ✅ validated inputs based on the provided schemas
  • ✅ flexible middlewares
  • ✅ follows OpenFaaS template but it is not bound to it
  • ✅ running as standalone NodeJS server
  • ✅ works on top of Express
  • ✅ uses fantastic OpenAPI Backend project

Release notes

1.5.0

  • passing request fields from OpenAPI Backend Context as part of FunctionEvent
  • passing also raw Context if necessary
  • documented FunctionEvent

1.4.0

1.3.0

  • support for flexible middleware injections

1.2.0

  • upgraded OpenAPI Backend to 2.3.0

Operation handler

Your operation handler for an endpoint looks like this:

export default async (message, context) => {
  context.status(200).succeed({ "nice": "json" });
}

Where message is of type FunctionEvent and context is of type FunctionContext.

Environment configuration

Variable Default value Description
NODE_ENV
SSL false
http__port 4000
http__request_id_header X-Request-Id
http__ssl__key_file $(cwd)/ca/key.pem
http__ssl__cert_file $(cwd)/ca/cert.pem
openapi__single_operation_id singleHandler
openapi__filename
openapi__url
service__namespace default-ns
request__body__size 1mb
logger__name defaultLogger
logger__level info

Examples

Develop

Prepare .npmrc

Create .npmrc in the root:

save-exact=true
prefix=/home/developer/.npm-global

Use Docker for development

docker-compose up -d dev docker-compose exec dev zsh

Publish

npm login registry.npmjs.org npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i openapi-node-function-template

Weekly Downloads

1

Version

1.5.1

License

MIT

Unpacked Size

25.2 kB

Total Files

20

Last publish

Collaborators

  • lgazo