Static file server and mocked REST+JSON server backed by YAML files. Mostly useful for teaching JavaScript topics where a web server or API is needed.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Peter J. Jones 03e9eae62b
Replace with ws
2 years ago
bin Initial import 5 years ago
lib Replace with ws 2 years ago
.gitignore Fixed a bug where Content-Type was incorrectly reported 4 years ago
LICENSE Initial import 5 years ago Mention WebSockets in the README 4 years ago
package.json Replace with ws 2 years ago

REST+JSON and Static File Server

Mockapie is a simple Node.js module that serves static content from a directory and pretends to be a database-connected REST server.


If an HTTP request is made to /api/* the REST+JSON server will be activated. The request will be handled by fetching/manipulating data in YAML files located in the data directory.

Example URLs and how they map to YAML files:

  • GET /api/artists: Return all records from data/artists.yml

  • POST /api/artists: Add a new record to data/artists.yml

  • GET /api/artists/1: Fetch a record from data/artists.yml where the id attribute is 1

  • GET /api/artists/1/albums: Fetch a record from data/albums.yml where the artist_id attribute is 1

  • And so forth for all of the REST-related HTTP methods and arbitrary nesting of resources

Static File Server

When a request does not start with /api/* then the static file server will be used to serve files out of www.


The server uses to push log messages to all connected sockets.

Default Configuration

The following values are currently hard coded:

  • Port: 3000
  • YAML directory: data
  • Static file directory: www
  • REST+JSON URL prefix: /api/

Example Application