JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1588
  • Score
    100M100P100Q105579F
  • License MIT

AWS Lambda web framework

Package Exports

  • bragg

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bragg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bragg

Build Status Coverage Status

Serverless web framework for AWS λ and Azure Functions

This framework is heavily inspired by koa.

Install

$ npm install --save bragg

Usage

Simple example

Adding a single function as middleware is quite easy. The following example will result in a 200 response with the body set to Foo Bar.

const bragg = require('bragg');
const app = bragg();

app.use(ctx => {
    ctx.body = 'Foo Bar';
});

exports.handler = app.listen();

Promise support

If a promise is assigned to the body property, it will be resolved before sending the result to the client.

const bragg = require('bragg');
const app = bragg();

app.use(ctx => {
    ctx.body = Promise.resolve('Foo Bar');
});

exports.handler = app.listen();

Middlewares

Multiple middlewares will be executed one after the other. The result of the following example is Foo Bar Baz.

const bragg = require('bragg');
const app = bragg();

app.use(() => {
    return 'Foo';
});

app.use((ctx, result) => {
    return Promise.resolve(result + ' Bar');
});

app.use((ctx, result) => {
    ctx.body = result + ' Baz';
});

exports.handler = app.listen();

Middlewares

License

MIT © Sam Verschueren