Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

simpleS 0.0.2

simpleS is a simple http server for node.js that has some special features:

  • Simple structure with minimum configuration
  • Router for http (get, post, other) requests, static files and inexistent routes
  • WebSocket implementation (version 13, RFC 6455)
  • Automatic response compression (deflate and gzip)
  • Easy to use interfaces for requests and responses

THIS DESCRIPTION IS NOT COMPLETE, MORE CONTENT WILL BE ADDED

##Documentation

Instalation

npm install simples

Usage

varsimples=require('simples');varserver=simples(12345);// Your server is set up on port 12345

Routing

server.get('/',function(request,response){response.end('root');});server.getStatic('static_files');// Route for static files located in the folder "static_files"server.notFound(function(request,response){response.end('404');});

WebSocket

server.ws('/',{messageMaxLength: 1024,// The maximum size of a messageorigins: ['null'],// The accepted originsprotocols: ['chat']// The accepted protocols},function(connection){console.log('New connection');connection.on('message',function(message){console.log(message.toString());});connection.on('close',function(){console.log('Connection closed');});});

On client:

varsocket=newWebSocket('ws://localhost:12345/','chat');// Enjoy the real-time connection

About

Simple server for node.js

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages