
0.8.8
simpleS is a simple web framework for Node.JS designed to create HTTP(S) servers and clients with some special features:
- High performance and simple structure with minimum configuration
- Advanced routing for http requests, static files and errors
- Unique interface for requests and responses (named as connection)
- Response compression (deflate and gzip, disabled by default)
- Virtual Hosting
- CORS support
- Sessions (disabled by default)
- Template engine support
- WebSocket implementation (version 13, RFC 6455)
- Client API for HTTP requests and WebSocket connections
- Browser simple API for AJAX and WebSocket
Works with node.js 0.10+ and io.js 1.0+ !
Any feedback is welcome!
More simple modules:
Changelog
Documentation
Instalation
npm install simples
Examples
See the folder examples/
in the module directory, it contains examples that cover most simpleS features.
Usage
Server Creation
var simples = ; var server = ; // Your server is set up on port 80 // Enable compression (default is deflate)server; // Serve static files located in the folder "static"server; // Catch 404 Errorserver; // Create the first routeserver;
Client Creation
var simples = ; var client = simples; // GET requestclient; // POST requestclient;
Virtual Hosting
var host0 = server; // The server is in the same time the main hostvar host1 = serverhost'example.com'; // Other hostsvar host2 = serverhost'example2.com'; // Now for each host you can apply individual routinghost0; host1; host2;
WebSocket
Let's create an echo WebSocket server:
server;
Access the server from the browser built-in WebSocket API:
var socket = 'ws://localhost/' 'echo'; // Listen for messagessocket { console;}; // Send the first messagesocket;
Access the server from the browser simpleS WebSocket API:
var socket = simples; // Listen for messagessocket; // Send the first messagesocket;
Access the server from server-side simpleS client WebSocket API:
var simples = ; var client = simples; var socket = client; // Listen for messagessocket; // Send the first messagesocket;