1.0.18 • Published 4 years ago

nodejs-lambda-api v1.0.18

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

nodejs-lambda-api

Simple api builder for serverless lambda nodejs.

Installation

npm install nodejs-lambda-api

Example

const { api } = require("nodejs-lambda-api");

const app = api();

app.use((req, res, next)=> {
    //Set Headers
    res.setHeaders("Access-Control-Allow-Origin","*")
    next()
});

app.use((req, res, next) => {
    next()
});

app.get("/", (req, res, next) => {
    res.status(200)
    res.json({ data: "success" })
})

app.post("/", (req, res, next) => {
    const response = {
        body: JSON.stringify({
            message: "posted successfully",
            input: req.body
        })
    };
    res.status(200)
    res.json(response)
})

app.use(function(req, res, next) {
    res.status(404)
    res.send()
});

app.use(function(err, req, res, next) {
    res.status(500)
    res.send()
});

module.exports.handle = app.handle

Aws Setup

  1. Set method to ANY

Built in middlewares

  1. app.use
  2. app.get
  3. app.post
  4. app.patch
  5. app.delete
  6. app.update
1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago