Installations
npm install simples
Releases
Unable to fetch releases
Developer
micnic
Developer Guide
Module System
CommonJS
Min. Node Version
>=0.10
Typescript Support
No
Node Version
4.6.2
NPM Version
2.15.11
Statistics
47 Stars
127 Commits
5 Forks
3 Watching
2 Branches
2 Contributors
Updated on 22 Apr 2022
Bundle Size
80.81 kB
Minified
22.60 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
346,987
Last day
0%
9
Compared to previous day
Last week
63.4%
67
Compared to previous week
Last month
16.5%
247
Compared to previous month
Last year
-39.5%
3,649
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
0.9.0-alpha-10
simpleS is a simple web framework for Node.JS designed to create HTTP(S) servers and clients with WebSocket support and other 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)
- WebSocket implementation (RFC 6455)
- Server mirroring
- Virtual Hosting
- Response compression (deflate and gzip)
- CORS support
- Sessions
- Logging
- Middlewares
- Template engine support
- Node.js client API for HTTP requests and WebSocket connections
Any feedback is welcome!
Works with node.js 8.0+!
More simple modules:
Changelog (link will be added soon, check repo for changelog)
Documentation (work in progress)
Installation
npm install simples@alpha
Usage
Server Creation
1const simples = require('simples'); 2 3const server = simples(); // Your server is set up on port 80 4 5// Catch 404 Error 6server.error(404, (connection) => { 7 connection.end('Error 404 caught'); 8}); 9 10// Create the first route 11server.get('/', (connection) => { 12 connection.end('Simples Works'); 13});
Virtual Hosting
1const host0 = server; // The server is in the same time the main host 2const host1 = server.host('example.com'); // Other hosts 3const host2 = server.host('example2.com'); 4 5// Now for each host you can apply individual routing 6host0.get('/', (connection) => { 7 connection.end('Main Host'); 8}); 9 10host1.get('/', (connection) => { 11 connection.end('Host 1'); 12}); 13 14host2.get('/', (connection) => { 15 connection.end('Host 2'); 16});
WebSocket
Let's create an echo WebSocket server:
1server.ws('/', { 2 limit: 1024, // The maximum size of a message 3 advanced: false, // Set connection advanced mode, see docs for more info 4 origins: ['null'] // Set accepted origins, "null" for localhost 5}, (connection) => { 6 7 // Log the new connection 8 console.log('New connection'); 9 10 // Listen for messages to send them back 11 connection.on('message', (message) => { 12 console.log('Message: ' + message.data); 13 connection.send(message.data); 14 }); 15 16 // Log connection close 17 connection.on('close', () => { 18 console.log('Connection closed'); 19 }); 20});
Access the server from the browser built-in WebSocket API:
1const socket = new WebSocket('ws://localhost/', 'echo'); 2 3// Listen for messages 4socket.onmessage = (event) => { 5 console.log(event.data); 6}; 7 8// Send the first message 9socket.send('ECHO');
Access the server using simples-ws:
1import ws from 'simples-ws'; 2 3const socket = ws('/', { 4 protocols: [ 5 'echo' 6 ] 7}); 8 9// Listen for messages 10socket.on('message', (message) => { 11 console.log(message.data); 12}); 13 14// Send the first message 15socket.send('ECHO');
Access the server from server-side simpleS client WebSocket API:
1const simples = require('simples'); 2 3const client = simples.client(); 4 5const socket = client.ws('/'); 6 7// Listen for messages 8socket.on('message', (message) => { 9 console.log(message.data); 10}); 11 12// Send the first message 13socket.send('ECHO');
Client Creation
1const simples = require('simples'); 2 3const client = simples.client(); 4 5// GET request 6client.get('/').on('body', (response, body) => { 7 console.log('Response status: ' + response.status); 8 console.log('Response body: ' + body.toString()); 9}); 10 11// POST request 12client.post('/send').send(/* data */).on('response', (response) => { 13 // Do something with the response 14}).on('body', (response, body) => { 15 console.log('Response body: ' + body.toString()); 16});
No vulnerabilities found.
Reason
tokens are read-only in GitHub workflows
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: : LICENSE:1
Reason
all dependencies are pinned
Details
- Info: GitHub-owned GitHubActions are pinned
- Info: Third-party GitHubActions are pinned
- Info: Dockerfile dependencies are pinned
- Info: no insecure (not pinned by hash) dependency downloads found in Dockerfiles
- Info: no insecure (not pinned by hash) dependency downloads found in shell scripts
Reason
no binaries found in the repo
Reason
no vulnerabilities detected
Reason
0 commit(s) out of 30 and 0 issue activity out of 9 found in the last 90 days -- score normalized to 0
Reason
no reviews found
Details
- Warn: no reviews found for commit: e2651abfbf4ea2dfac4ddd4fb787ed0d2be4d935
- Warn: no reviews found for commit: 0f5469851ceb90fa4b9a2b278eaff2301ec5f393
- Warn: no reviews found for commit: ab92944254b7ec7930d38d348002100162619ee0
- Warn: no reviews found for commit: b431e3efbb290b0065943d58932848c399d0ea14
- Warn: no reviews found for commit: d99d2d8451dd0f03d45cdea09b558a96c2085713
- Warn: no reviews found for commit: 6a9ee668c1b53355572c4b4ebc6f1fd2cf905145
- Warn: no reviews found for commit: 8e2d2aa9e728740ea5bf44cb4a909f45ac4f0802
- Warn: no reviews found for commit: dabb83acb2e96a077a7b81fa20e5c22b073ad4dc
- Warn: no reviews found for commit: f2c8bcee2a396a42778fffbf7093f3b3a644a6a2
- Warn: no reviews found for commit: d4fe6da2fa4b601f2e9ce2c0fe1c5b9d7e7d25ea
- Warn: no reviews found for commit: 05f9ad02a43991f0de371755696085258d5621ce
- Warn: no reviews found for commit: 5722b35c3a722f77513105a8b43d1a1832d9e1ad
- Warn: no reviews found for commit: 372eb04a06b73778f9b2ce60cf2a79f14a7bfe35
- Warn: no reviews found for commit: 8d6da2548443666e9c0b1bb0c30be8c26b468d1c
- Warn: no reviews found for commit: 7d515485b14e33193d4cb0dff1ff29de30177901
- Warn: no reviews found for commit: 528616d98fdbb6533c13e205a13ea4f7d0d5f59b
- Warn: no reviews found for commit: 8b96a2743c5e1865f23a41fdbbca4d4600064c0f
- Warn: no reviews found for commit: eb3153890bdf075c042646033934434276d207ea
- Warn: no reviews found for commit: 3579c657dd20302d57672b1561cb5e55f8a07a20
- Warn: no reviews found for commit: 282c59d81eab2faf589d63141d96ba2c41872f44
- Warn: no reviews found for commit: ac88890bcb148763fcf9ed0e6c9da235d6df88de
- Warn: no reviews found for commit: 90a2fe1ecb4ce380a7bd29480a6d83ee77f7e3c7
- Warn: no reviews found for commit: 1a3308ee10445e34dc28844e9ffa037d4f52489c
- Warn: no reviews found for commit: 2aee2a2aa2d1461b054571b87b53cee15eb02d00
- Warn: no reviews found for commit: b89d7396f6981a5f0a46b8c606f489dfb50cfcf8
- Warn: no reviews found for commit: b804a0f0c5bbe175180205e6cac65a72bea517dc
- Warn: no reviews found for commit: 6ad6db087224394ce6113625eece7cdd14916f9e
- Warn: no reviews found for commit: 50893e725fbf7a6752bb542e94555dd99d205060
- Warn: no reviews found for commit: a2033c01d93dbd1cf996e6a9ea0b94054ede2b98
- Warn: no reviews found for commit: ce37e4a59ce1d9f5eebd8f8a825f97c8ef48b0f8
Reason
no badge detected
Reason
security policy file not detected
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Score
5.3
/10
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More