
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
basic-dev-server
Advanced tools
Current Version : 2.0.0
This project aims at providing a very (very (very)) basic development server with minimal configuration and maximum ease of use in order to make the setup of a simple develpoment environment deadly fast and easy.
The project is built with the Express framework and is intended to be modular and adaptable.
To use this dev server you need to have Node.js
installed on your machine.
Then clone this repository in the directory of your choice and launch : npm install
in that directory.
To run the server launch : npm start
.
The server should now be up on localhost and listening on port 8081
(default).
You can stop the server by typing Ctrl+C
.
This little dev server was first developed in order to mock basic REST APIs. The idea is to provide a simple way to build a fake API that will be used to test another app that use this API. By extension it allows you to prototype your API and test some aspects of its behavior before you start a project.
To create a new API, just create a new JS file in the /src/http
directory.
This file will contain your API implemention, it must exports a function that
take a server
parameter and that defines your API as in an Express app.
Below is an example for default-api.js
:
// A basic API for development purpose
module.exports = (server) => {
server.get('/api', (req, res, next) => {
res.send('Default API');
});
server.get('/', (req, res, next) => {
res.send('<h1>Hello World !</h1>');
});
server.get('/:name', (req, res, next) => {
res.send(`<h1>Hello ${req.params.name} !</h1>`);
});
};
Note : the basic-dev-server
use the nodemon
server
to provide an even easier development experience, once the server is started you
can start editing your API code and it will be automatically reloaded when saving,
so that you can immediately test it (e.g in your favorite browser).
You control the port on which the server is listening as well as the API that is
loaded by providing a configuration file.
Here is an example of such a configuration (see default-conf.js) :
// Default HTTP Config
module.exports = {
http: {
port: 8081,
api: 'default-api'
}
};
http.port
: port on which the server will be listening for incoming requestshttp.api
: list of APIs to loadFor example if I just defined my new awesome API in a file named my-awesome-api.js
and put it in the /src/http
directory, then I would load this API by adding the
string 'my-awesome-api'
to the http.api
array.
Once you created your configuration you can tell the server to use it at startup
with the following command : npm start <my-config>
.
Here <my-config>
is the name of the configuration file.
The server will look into the conf/
directory for the specified config file.
Note :
This basic-dev-server
is published under the GPLv3 so feel free to use, copy,
redistribute and/or improve it as you like !
(see LICENSE for more details).
FAQs
A basic Node Express server for development
The npm package basic-dev-server receives a total of 0 weekly downloads. As such, basic-dev-server popularity was classified as not popular.
We found that basic-dev-server 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.