offline-gateway
offline gateway, zero configuration, file based, supported dynamodb-local stream
Last updated 2 years ago by deptno .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install offline-gateway 
SYNC missed versions from official npm registry.

:mushroom: Offline gateway

demo

File based API gateway,
:tada: specially offline-gateway support DynamoDB local stream

npm -g i offline-gateway

Usage

Define API TYPE and PATH in filename.

METHOD.PATH1.PATH2.PATHN.js

touch {post,get}.user.js

and write code

bat {post,get}.user.js
───────┬──────────────────────────────────────────────────
       │ File: post.user.js
───────┼──────────────────────────────────────────────────
   1   │ module.exports = (event, context, callback) => {
   2   │   return {
   3   │     statusCode: 201,
   4   │     body: 'Created',
   5   │   }
   6   │ }
───────┴──────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────
       │ File: get.user.js
───────┼──────────────────────────────────────────────────
   1   │ module.exports = (event, context, callback) => {
   2   │   return {
   3   │     statusCode: 200,
   4   │     body: JSON.stringify([])
   5   │   }
   6   │ }
───────┴──────────────────────────────────────────────────
tree
.
├── ...(ignoring)
├── post.user.js
└── get.user.js

Run offline-gateway or ogw

$ offline-gateway # or ogw
???? Callgate ready to work on port 3000

And USE

http post localhost:3000/user
HTTP/1.1 201 Created
Connection: keep-alive
Content-Length: 7
Content-Type: text/html; charset=utf-8
Date: Sun, 21 Oct 2018 17:49:06 GMT
ETag: W/"7-rM9AyJuqT6iOan/xHh+AW+7K/T8"
X-Powered-By: Express

Created
$ http get localhost:3000/user
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 2
Content-Type: text/html; charset=utf-8
Date: Sun, 21 Oct 2018 17:49:11 GMT
ETag: W/"2-l9Fw4VUO7kr8CvBlt4zaMCqXZ0w"
X-Powered-By: Express

[] 

PORT

PORT=5945 ogw

DynamoDB local stream

touch ddb.region.port.tableName.js

module.exports = (event) => {
  console.log('records', event)
}

offline-gateway polling stream's(first shard, DynamoDB support only one stream) first shard by 1 second.

Features

  • [x] Hot reloading
  • [x] DynamoDB local stream(limited, very initial version)

Link

License

MIT

Current Tags

  • 0.1.12                                ...           latest (2 years ago)

13 Versions

  • 0.1.12                                ...           2 years ago
  • 0.1.11                                ...           2 years ago
  • 0.1.10                                ...           2 years ago
  • 0.1.9                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |