Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

server

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server

A modern and powerful server for Node.js


Version published
Weekly downloads
5.8K
decreased by-6%
Maintainers
1
Weekly downloads
 
Created
Source

Server for Node.js

[Subscribe] [Status] [Downloads] [Roadmap]

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 => ctx.res.render('index')),
  post('/', ctx => console.log(ctx.req.body))
]);

Getting started

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 => ctx.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!'.

Documentation

The library documented is here:

Full Documentation

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.

License

Licensed under the MIT License. See LICENSE for the full license.

Author

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!

You can also sponsor the project, get your logo in here and some other perks with tons of ♥

FAQs

Package last updated on 25 Apr 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc