This package has been deprecated

Author message:

package was moved to @cloudifyjs/restful

aws-serverless-restful-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i aws-serverless-restful-wrapper

Weekly Downloads

0

Version

0.0.9

License

MIT

Unpacked Size

64.2 kB

Total Files

44

Last publish

Collaborators

  • diegotremper