https://github.com/deptno/offline-gateway
:mushroom: API Gateway emulation + CRUD, Stream?
https://github.com/deptno/offline-gateway
api api-gateway gateway local-gateway microservice
Last synced: 3 months ago
JSON representation
:mushroom: API Gateway emulation + CRUD, Stream?
- Host: GitHub
- URL: https://github.com/deptno/offline-gateway
- Owner: deptno
- Created: 2018-10-22T06:41:43.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-15T10:48:09.000Z (almost 7 years ago)
- Last Synced: 2025-06-13T02:05:55.278Z (4 months ago)
- Topics: api, api-gateway, gateway, local-gateway, microservice
- Language: TypeScript
- Homepage:
- Size: 1.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :mushroom: Offline gateway

File based API gateway,
:tada: specially `offline-gateway` support **DynamoDB local stream**```bash
npm -g i offline-gateway
```## Usage
Define API **TYPE** and **PATH** in filename.
`METHOD.PATH1.PATH2.PATHN.js`
```bash
touch {post,get}.user.js
```
and write code```bash
bat {post,get}.user.js
``````text
───────┬──────────────────────────────────────────────────
│ 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 │ }
───────┴──────────────────────────────────────────────────
``````bash
tree
``````text
.
├── ...(ignoring)
├── post.user.js
└── get.user.js
```Run `offline-gateway` or `ogw`
```bash
$ offline-gateway # or ogw
```
```text
🍄 Callgate ready to work on port 3000
```And **USE**
```bash
http post localhost:3000/user
``````text
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: ExpressCreated
```
```bash
$ http get localhost:3000/user
```
```text
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
```bash
PORT=5945 ogw
```
### DynamoDB local stream`touch ddb.region.port.tableName.js`
```javascript
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
- [Dynamon - GUI DynamoDB local client](https://github.com/deptno/dynamon)## License
MIT