Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
The simplest yet a powerful way of launching a server with Node.js:
let server = require('server');
// Launch it in port 3000 to serve static files in /public on http://localhost:3000/
server();
// OR serve static files from the project root on http://localhost:8000/
server({ port: 8000, public: './' });
// OR use some simple routes on on http://localhost:8080/
let { get, post } = server.router;
server({ port: 8080 },
get('/', (req, res) => res.render('index')),
post('/', (req, res) => console.log(req.body))
);
It parses urlencoded, json and files automatically with default middlewares while still letting you personalize the options or change those middlewares for others you prefer (or just remove them).
After getting Node ready and npm init
, run this in your project folder to install the server:
npm install server --save
Then you can create a file called app.js
and set the following:
// Include the server in your file
let server = require('server');
let { get, post } = server.router;
// Initialize the server on port 3000
server(3000,
// Handle requests to the url "/" ( http://localhost:3000/ )
get('/', (req, res) => { res.send('Hello world!'); })
);
Execute this in the terminal to get the server started:
node app.js
And finally, open your browser on localhost:3000 and you should see your server answered 'Hello world!'.
Everything is documented here:
Licensed under the MIT License. See LICENSE
for the full license.
This package was created by Francisco Presencia but hopefully developed and maintained by many others. See the the list of contributors here.
FAQs
A modern and powerful server for Node.js
The npm package server receives a total of 5,612 weekly downloads. As such, server popularity was classified as popular.
We found that server demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.