npm.io
1.1.0 • Published 10 years ago

serve-locally

Licence
MIT
Version
1.1.0
Deps
0
Vulns
0
Weekly
0

serve-locally

Build Status

Express middleware.

When defined, takes requests and checks the configured root folder for matching JSON responses based on the url path and files/folders in the root folder.

Responds with the JSON response in matching file.

Installation

$ npm install serve-locally

Uses ES6 features and requires NodeJS 5.6.x and above.

Example

Refer to the test/server.js and matching directories.

API

const serveLocally = require('serve-locally');
const app = require('express')();

app.use(serveLocally({'root': './sample_responses'}));
serveLocally(opts)
  • options options to configure the middleware
    • root where to search for the responses. Defaults to .
Resolution Logic

Refer to the documentation in index.js for the resolution logic and caveats.

LICENSE

MIT