0.1.5 • Published 5 months ago

@json-express/core v0.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

JSON Express

A lightweight, fast JSON server for rapid API prototyping and development. Get a full REST API with zero coding in seconds.

✨ Features

  • Zero Configuration - Just point to your JSON files and go
  • Full REST API - GET, POST, PATCH, DELETE operations
  • Lightweight - Minimal dependencies, maximum performance
  • CORS Enabled - Coming soon

šŸš€ Quick Start

Global Installation

npm install -g @json-express/core

Usage

# Navigate to your project directory
$ cd my-project

# Create a sample JSON file (albums.json)
$ echo '[{"name": "Encore", "releaseDate": "12-11-2004"}]' > albums.json

# Start the server
$ json-server

Local Installation (Project-specific)

# Navigate to your project directory
$ cd my-project

# Install locally in your project
$ npm install @json-express/core

# Create your JSON files
$ echo '[{"name": "Encore", "releaseDate": "12-11-2004"}]' > albums.json

# Start the server using npx
$ npx json-express

Stopping the Server

To stop the JSON Express server, use:

  • Mac/Linux: Ctrl + C
  • Windows: Ctrl + C

āš™ļø Configuration

JSON Express favors convention over configuration, but when you need customization, simply create a config.json file in the same directory as your JSON data files.

Creating a Configuration File

# Create config.json in your project directory
echo '{"PORT": "8080"}' > config.json

Available Configuration Options

{
  "PORT": 8080
}

Note: More configuration properties are coming soon!

Example Project Structure

my-project/
ā”œā”€ā”€ config.json     # Optional configuration
ā”œā”€ā”€ albums.json     # Your data files
ā”œā”€ā”€ artists.json    # Your data files
└── ...

šŸ“š API Endpoints

Based on your JSON structure, JSON Express automatically creates RESTful endpoints:

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 

šŸ“ Sample JSON Structure

Create as many JSON files with any number of fields as you like. ID will be added automatically!

Here's an albums.json file with some data:

[
  {
    "name": "Encore",
    "releaseDate": "12-11-2004"
  },
  {
    "name": "The Marshall Mathers LP",
    "releaseDate": "23-05-2000"
  },
  {
    "name": "The Slim Shady LP",
    "releaseDate": "23-02-1999"
  }
]

And an artists.json file:

[
  {
    "name": "Eminem",
    "realName": "Marshall Bruce Mathers III",
    "dob": "17-10-1972",
    "genre": "Hip Hop",
    "country": "United States",
    "debutYear": 1996,
    "isActive": true,
    "recordLabel": "Aftermath Entertainment",
    "website": "https://www.eminem.com"
  },
  {
    "name": "Taylor Swift",
    "realName": "Taylor Alison Swift",
    "dob": "13-12-1989",
    "genre": "Pop",
    "country": "United States",
    "debutYear": 2006,
    "isActive": true,
    "recordLabel": "Republic Records",
    "website": "https://www.taylorswift.com"
  },
]

šŸ“„ License

ISC License - see the LICENSE file for details.

šŸ› Issues

Found a bug or have a feature request? Please open an issue.

0.1.5

5 months ago

0.1.4

5 months ago

0.1.3

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago