Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Simple and powerful server that just works so you can focus on your awesome project:
// Include it and extract some methods for convenience
const server = require('server');
const { get, post } = server.router;
// Launch server with some opts and a couple of routes
server({ port: 8080, public: './' }, [
get('/', ctx => 'Hello world'),
post('/', ctx => console.log(ctx.req.body))
]);
After getting Node.js (> 7.6
) ready and doing npm init
in your project folder, install server and keep it as a dependency:
npm install server --save
Then you can create a file called app.js
and set the following:
// Include the server in your file
const server = require('server');
const { get, post } = server.router;
// Handle requests to the url "/" ( http://localhost:3000/ )
server([
get('/', ctx => '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!'.
The library is documented here:
Subscribe here to receive tutorials when released. Tutorials are good for learning while the documentation is good for reference/quick use once you know the basics.
You can also download the repository and try the examples by browsing to them and node app.js
inside each of them in /examples
.
The package server
is great for many situations. Let's see some of them:
Everything works out of the box, you get great support for most features and you can easily tap into Express' middleware ecosystem. What's not to love?
Some of the included features: body and file parsers, cookies, sessions, websockets, Redis, gzip, favicon, csrf, SSL, etc. They just work so you will save a headache or two and can focus on your actual project.
From the flexibility and expressivity of the bundle, designing APIs is a breeze:
// books/router.js
const ctrl = require('./controller');
const { get, post, put, del } = require('server').router;
module.exports = [
get('/book', ctrl.list),
get('/book/:id', ctrl.item),
post('/book', ctrl.create),
put('/book/:id', ctrl.update),
del('/book/:id', ctrl.delete)
];
Upcoming feature
Websockets were never this easy to use! With socket.io on the front-end, you can simply do this in the back-end to handle those events:
// chat/router.js
const ctrl = require('./controller');
const { socket } = require('server').router;
module.exports = [
socket('connect', ctrl.join),
socket('message', ctrl.message),
socket('disconnect', ctrl.leave)
];
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.
I love using my work and I'm available for contractor work. Freelancing helps maintain server
and my other open source projects up to date! I am also on Codementor so if you want to learn more Javascript/Node.js/etc contact me there.
You can also sponsor the project, get your logo in here and some other perks with tons of ♥
FAQs
A modern and powerful server for Node.js
The npm package server receives a total of 6,493 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.