1. Getting Started
  2. Example

Quick Example

Point to JSON files

Once your have installed json-express/core

Here I will show you how to turn your JSON files to REST server within seconds.

  • If you already have your JSON files

    Change terminal to the directory with all your json files which you wish to convert to REST API

    $ cd your/project/dir
  • If you don\'t have any JSON files

    I will provide you with some json files for you to test

    $ cd your/server/dir
    
    # Create an albums.json file
    $ echo '[{"name": "Encore", "releaseDate": "12-11-2004"}, {"name": "The Marshall Mathers LP", "releaseDate": "23-05-2000"}]' > albums.json
    
    # Create an artists.json file
    $ echo '[{"name": "Eminem", "realName": "Marshall Bruce Mathers III", "dob": "17-10-1972", "genre": "Hip Hop", "country": "United States", "debutYear": 1996}, {"name": "Taylor Swift", "realName": "Taylor Alison Swift", "dob": "13-12-1989", "genre": "Pop", "country": "United States", "debutYear": 2006}]' > artists.json
    

Time to run

Once JSON files are prepared it's time to fire up json-express

  • For global installation

    $ json-express
  • For local installation

    $ npx json-express

Your server is up 🚀

That's it, your server is up and ready with following api for each resources

GET    /albums         # Get all albums
GET    /albums/:id     # Get album with id
POST   /albums         # Create a new album
PATCH  /albums/:id     # Partially update album with id 
DELETE /albums/:id     # Delete album with id