Skip to content

saheljalal/saucy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

saucy-server

A mock REST API server built on json-server, designed for rapid frontend prototyping and testing. Point your app at saucy-server, and immediately get realistic CRUD endpoints backed by a large JSON dataset — no backend required.

Features

  • JSON-based mock API — serves a ~1.3 MB db.json file as a fully navigable REST API.
  • Automatic CRUD — every top-level collection in db.json (posts, comments, albums, photos, users, todos) is exposed with GET (list + detail), and standard create/update/delete semantics out of the box.
  • keyPath query nesting — pass ?keyPath=a.b.c to wrap the response payload inside an object at the given path (e.g. data becomes {a:{b:{c:data}}}), handy for matching an existing client's expected envelope.
  • Echo mode for non-GET requestsPOST, PUT, PATCH, and DELETE requests echo the request body straight back to the caller, so you can exercise submit flows without persisting anything.

Tech Stack

Installation

git clone https://github.com/saheljalal/saucy-server.git
cd saucy-server
npm install

Usage

Start the server with:

npm start

It listens on port 3000:

http://localhost:3000

API

All routes listed below are served from the collections in db.json. The /api/ prefix is rewritten to /, so both /posts and /api/posts resolve to the same resource.

Method Behavior
GET /<collection> Returns the full list for any collection in db.json (e.g. posts, users, todos, ...).
GET /<collection>/:id Returns a single item by id.
POST / PUT / PATCH / DELETE Echoes the request body back to the client (no persistence).
Any GET + ?keyPath=a.b.c Wraps the response inside {a:{b:{c:<data>}}}.

Examples

# list posts
curl http://localhost:3000/posts

# single user
curl http://localhost:3000/users/1

# nest the response under a.b.c
curl 'http://localhost:3000/posts?keyPath=a.b.c'
# -> { "a": { "b": { "c": [ ...posts ] } } }

# echo mode — body is returned as-is
curl -X POST http://localhost:3000/posts \
  -H 'Content-Type: application/json' \
  -d '{"title":"hello","body":"world"}'
# -> { "title": "hello", "body": "world" }

License

MIT — Copyright (c) 2017 Sahel Jalal.

About

a saucy test server

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors