Conceptually server is a function that accepts options and other functions. The heavy lifting is already implemented so you can focus on your project:

// Import the variable into the file
const server = require('server');

// options and fn1, fn2, etc are optional
server(options, fn1, fn2, fn3, ...);

You can also learn Node.js development by following the tutorials.

Getting started

Here's a getting started tutorial for total beginners. If you know your way around Node.js, first install server:

npm install server

Then create some demo code in your index.js:

// Import the library
const server = require('server');

// Launch it with a middleware that answers anything
server(ctx => 'Hello world');

Run it from the terminal:

node .

And open your browser on localhost:3000 to see it in action.


In its basic form it's a plain object with several key:values pairs:

const server = require('server');

// Set the options (shown here with the defaults)
const options = {
  port: 3000,
  public: 'public',
  engine: 'pug',
  env: 'development'

// Launch the server with the options

Options documentation


Middleware are functions that accepts a context, does some work and is resolved either synchronous or asynchronous. Mandatory Hello World here:

// Load the server from the dependencies
const server = require('server');

// Display "Hello 世界" for any request
const middleware = ctx => 'Hello 世界';

// Launch the server with a single middleware

Middleware documentation


The last but maybe most important part is the router that is used to create routes. A route is really a middleware and is used for handling user requests to specific places:

const server = require('server');

// Import some of the routers available
const { get, post, put, del } = server.router;

// Handle requests to http://localhost:3000/
const home = get('/', ctx => 'Homepage!');

// Handle requests to http://localhost:3000/SOMETHING
const page = get('/:page', ctx => `Page ${}`);

server(home, page);

Router documentation


Some recommendations on using and debugging server. A peak into the technology inside for understanding it better. Explanation on some of the design constrains for server.

Advanced documentation