Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
A wrapper around the great json-server. It allows you to specify multiple REST resources. Pass in a directory of Javascript files to be required, and they become your REST endpoints.
npm install bogus-api
require('bogus-api').create().start({
resourceDir: './my-resources',
resourceUriPrefix: '/api/v1',
});
Each JS file in the my-resources
directory could look like:
var users = [];
// Create 10 users
for (var i = 0; i < 10; i++) {
users.push({ id: i, name: 'user' + i });
}
module.exports = users;
Or it could look like:
module.exports = [
{ "id": 1, "title": "json-server", "author": "typicode" },
{ "id": 2, "title": "test", "author": "ccnokes" }
];
So you get a little more flexibility than with plain json-server
.
You can add or override routes using the Express API like so:
bogusAPI = require('bogus-api');
var bogusServer = bogusAPI.create({
// These routes will get mounted before the resources are, allowing you to "short-circuit" them
// This is useful for testing how the UI reacts to error states from an API
priorityRoutes: function(server) {
// the server arg is an instance of an Express server
server.get('/someRoute', function(req, res) {
res.status(500).send({ message: 'Some error.' });
});
}
}).start();
Option | Description |
---|---|
port | Port the app runs on. 7001 by default. |
host | 0.0.0.0 by default. |
resourceUriPrefix | Prefixes all resources with a URI. |
resourceDir | Directory containing your resources. Default to sample-resources. |
proxy | Object containing the host and port of the URL to proxy to. No default. |
staticDir | Path to static directory to serve. |
staticUri | URI to serve static directory through. |
FAQs
Mock API server for front-end development
The npm package bogus-api receives a total of 4 weekly downloads. As such, bogus-api popularity was classified as not popular.
We found that bogus-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.