Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/potapovdim/post-get-service
https://github.com/potapovdim/post-get-service
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/potapovdim/post-get-service
- Owner: potapovDim
- License: mit
- Created: 2022-10-23T09:30:20.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-06T15:16:51.000Z (about 2 years ago)
- Last Synced: 2023-02-28T13:22:45.666Z (over 1 year ago)
- Language: JavaScript
- Size: 313 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## Usage
- Build simple in memory HTTP server
- GET, POST are supported methods.![npm downloads](https://img.shields.io/npm/dm/post-get-service.svg?style=flat-square)
## Install
```sh
npm install -SD post-get-service || npm i -g post-get-service
```## Example
base usage example
```js
const { run_service, generate_api_requests } = require('post-get-service');const model = {
port: 8081,
api: [
{
path: '/user',
},
{
path: '/item',
},
],
};example();
async function example() {
generate_api_requests(model, 'js', './interactions.js');
const service = await run_service(model);
const { create_data_user, get_data_user } = require('./interactions.js');await create_data_user({ user: 1 });
await create_data_user({ user: 2 });
await create_data_user({ user: 3 });
await create_data_user({ user: 4 });const user = await get_data_user();
console.log(user); // { user: 1 }await service.stop();
}
```