server.js Node.js Framework

1.0.42 · active · verified Sun Apr 19

server.js is a Node.js framework designed for building web applications and APIs with a focus on simplicity and ease of use. It provides a comprehensive set of features out-of-the-box, including body and file parsers, cookies, sessions, WebSockets (via Socket.io), Redis integration, gzip compression, favicon handling, CSRF protection, and SSL support. This approach aims to minimize configuration and allow developers to concentrate on business logic. The package is currently stable at version 1.0.42, with frequent minor updates addressing bug fixes and introducing small enhancements, as seen in its recent release history. It differentiates itself by bundling many common utilities that often require separate middleware in other frameworks, while still offering compatibility with the Express middleware ecosystem for extended functionality. It explicitly recommends Node.js 8.x.y LTS or newer (minimum 7.6.0), indicating a CommonJS-first approach in its current major version.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart code initializes a server listening on port 8080 with a GET route responding 'Hello world' and a POST route logging request data.

const server = require('server');
const { get, post } = server.router;

// Launch server with options and a couple of routes
server({ port: 8080 }, [
  get('/', ctx => 'Hello world'),
  post('/', ctx => {
    console.log(ctx.data);
    return 'ok';
  })
]);

view raw JSON →