
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A simple CLI utility for quickly creating Express-based servers with a single configuration file
Fastapi is a simple command-line utility that allows you to create an Express-based server based off of a single configuration file. It's useful for quickly spinning up mock APIs, among other things.
Install the fastapi
command-line utility via npm i -g fastapi
. Next, create a configuration file like the one we see here.
// config.js
module.exports = {
// A unique ID for this API
'id': 'my-api',
// The port on which Express is to listen
'port': 7050,
// Whether or not to log incoming requests to the console (default: true)
'log': true,
'routes': {
'/api/v1/ping': {
'get': (req, res, next) => {
return res.send('pong');
}
}
}
};
Next, launch your server as shown below.
$ fastapi -c ./config.js
A configuration file can define multiple APIs by exporting an array of configuration objects, like we see here.
module.exports = [
{
'id': 'api1',
'port': 7050,
'log': true,
'routes': {
'/api/v1/ping': {
'get': (req, res, next) => {
return res.send('pong');
}
}
}
},
{
'id': 'api2',
'port': 7051,
'log': true,
'routes': {
'/api/v1/foo': {
'get': (req, res, next) => {
return res.send('bar');
}
}
}
}
];
FAQs
A simple CLI utility for quickly creating Express-based servers with a single configuration file
The npm package fastapi receives a total of 443 weekly downloads. As such, fastapi popularity was classified as not popular.
We found that fastapi 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.