Gathering detailed insights and metrics for simples
Gathering detailed insights and metrics for simples
Gathering detailed insights and metrics for simples
Gathering detailed insights and metrics for simples
npm install simples
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
47 Stars
127 Commits
5 Forks
3 Watching
2 Branches
2 Contributors
Updated on 22 Apr 2022
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
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
simpleS is a simple web framework for Node.JS designed to create HTTP(S) servers and clients with WebSocket support and other special features:
npm install simples@alpha
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});
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});
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');
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
Reason
all dependencies are pinned
Details
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
Reason
no badge detected
Reason
security policy file not detected
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Score
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