0.0.9 • Published 4 years ago

aws-serverless-restful-wrapper v0.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

aws-serverless-restful-wrapper


NOTE

This package is no longer maintained and was moved to @cloudifyjs/restful.

An API Gateway event wrapper for AWS Lambda functions for REST APIs

CircleCI npm npm codecov dependencies Status devDependencies Status Known Vulnerabilities Greenkeeper badge

Install

$ npm install aws-serverless-restful-wrapper

Features

Usage

Fetch a single document

GET /todos/{id}

const restful = require('aws-serverless-restful-wrapper')

module.exports.get = restful.document({
  target: async (path, query, headers) => {
    console.log('Returning todo')
    return {
      id: '123',
      text: 'My task',
      checked: true
    }
  }
})

API Gateway Response:

HTTP 200
Content-Type: 'application/json'

{
  "id": "123",
  "text": "My task",
  "checked": true
}

Fetch a collection

const restful = require('aws-serverless-restful-wrapper')

module.exports.get = restful.collection({
  target: async (path, query, headers) => {
    console.log('Returning todos')
    return [
      {
        id: '1',
        text: 'My task 1',
        checked: true
      },
      {
        id: '2',
        text: 'My task 2',
        checked: true
      }
    ]
  }
})

API Gateway Response:

HTTP 200
Content-Type: 'application/json'

[
  {
    "id": "1",
    "text": "My task 1",
    "checked": true
  },
  {
    "id": "2",
    "text": "My task 2",
    "checked": true
  }
]

Using Joi validation

const Joi = require('@hapi/joi')
const restful = require('aws-serverless-restful-wrapper')

module.exports.get = restful.document({
  validators: {
    path: Joi.object({
      id: Joi.string().required()
    })
  },
  target: async (path, query, headers) => {
    console.log('Returning todo')
    return {
      text: 'My task',
      checked: true
    }
  }
})

Contributing

  • Write docs
  • Suggest a feature
  • Submit PRs
    • Logging
    • Support for XML based REST
  • Write exemples

License

This source code is licensed under the MIT license found in the LICENSE.txt file.

0.0.9

4 years ago

1.0.0-alpha.6

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago