eduhds / json-filepoints

JSON files as endpoints.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON-FILEPOINTS

NodeJS Express.js Yarn

JSON files as endpoints.

Usage

  • Place your .json files in a folder so that the path matches the desired endpoint
  • You can organize the files via the method (GET, POST, ...) if you prefer

Default folder is json if not specified.

  • If you need endpoints like this:
/endpoint
/folder/to/endpoint
/my/get/endpoint
/my/post/endpoint
  • So make a source directory like this:
json
├── endpoint.json
├── folder
│   └── to
│       └── endpoint.json
├── GET
│   └── my
│       └── get
│           └── endpoint.json
└── POST
    └── my
        └── post
            └── endpoint.json

Running server

Download single JS bundle file

Download from releases and unzip json-filepoints.js.

# Default port and source directory
node json-filepoints.js

# Change port with -p
node json-filepoints.js -p <port>

# Change source directory with -d
node json-filepoints.js -d <folder>

Cloning repository

git clone https://github.com/eduhds/json-filepoints.git

cd json-filepoints

yarn build

node build/json-filepoints.js

Alternatively you can run yarn start or yarn dev

Docker

docker run --rm -p 3030:3030 -v $(pwd)/json:/json eduhds/json-filepoints -d /json

Try

curl http://localhost:3030/folder/to/endpoint

Disclaimer

This project is intended to test purposes like mocking api's. Don't use in production.

About

JSON files as endpoints.


Languages

Language:JavaScript 94.3%Language:Dockerfile 5.7%