https://github.com/pjones/mockapie
Static file server and mocked REST+JSON server backed by YAML files
https://github.com/pjones/mockapie
Last synced: 18 days ago
JSON representation
Static file server and mocked REST+JSON server backed by YAML files
- Host: GitHub
- URL: https://github.com/pjones/mockapie
- Owner: pjones
- License: bsd-2-clause
- Created: 2015-06-23T00:39:10.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-05T19:33:37.000Z (over 7 years ago)
- Last Synced: 2025-02-18T00:43:11.717Z (4 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.## REST+JSON
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`.## WebSockets
The server uses [socket.io](http://socket.io/) 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
* [AngularJS Course](https://github.com/devalot/angularjs) source code.