{"id":21838510,"url":"https://github.com/micnic/simples","last_synced_at":"2025-04-14T10:33:18.930Z","repository":{"id":5329719,"uuid":"6513577","full_name":"micnic/simples","owner":"micnic","description":"Simple Web Framework for Node.JS","archived":false,"fork":false,"pushed_at":"2019-10-07T21:11:01.000Z","size":1352,"stargazers_count":47,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T14:35:50.255Z","etag":null,"topics":["client","framework","http","https","javascript","nodejs","web","websockets"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micnic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-02T22:28:10.000Z","updated_at":"2022-04-22T01:15:55.000Z","dependencies_parsed_at":"2022-09-09T09:31:36.962Z","dependency_job_id":null,"html_url":"https://github.com/micnic/simples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnic%2Fsimples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnic%2Fsimples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnic%2Fsimples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnic%2Fsimples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micnic","download_url":"https://codeload.github.com/micnic/simples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862812,"owners_count":21173888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","framework","http","https","javascript","nodejs","web","websockets"],"created_at":"2024-11-27T21:11:29.478Z","updated_at":"2025-04-14T10:33:18.912Z","avatar_url":"https://github.com/micnic.png","language":"JavaScript","readme":"\u003cimg src=\"https://raw.github.com/micnic/simpleS/master/logo.png\"/\u003e\n\n# 0.9.0-alpha-10\n\nsimpleS is a simple web framework for Node.JS designed to create HTTP(S) servers\nand clients with WebSocket support and other special features:\n\n- High performance and simple structure with minimum configuration\n- Advanced routing for http requests, static files and errors\n- Unique interface for requests and responses (named as connection)\n- WebSocket implementation (RFC 6455)\n- Server mirroring\n- Virtual Hosting\n- Response compression (deflate and gzip)\n- CORS support\n- Sessions\n- Logging\n- Middlewares\n- Template engine support\n- Node.js client API for HTTP requests and WebSocket connections\n\n#### Any feedback is welcome!\n#### Works with node.js 8.0+!\n\n#### More simple modules:\n- [recache](https://www.npmjs.com/package/recache)\n- [simpleR](https://www.npmjs.com/package/simpler)\n- [simpleT](https://www.npmjs.com/package/simplet)\n\n### Changelog (link will be added soon, check repo for changelog)\n### [Documentation](https://simples.js.org/) (work in progress)\n\n## Installation\n\n    npm install simples@alpha\n\n## Usage\n\n### Server Creation\n\n```js\nconst simples = require('simples');\n\nconst server = simples(); // Your server is set up on port 80\n\n// Catch 404 Error\nserver.error(404, (connection) =\u003e {\n    connection.end('Error 404 caught');\n});\n\n// Create the first route\nserver.get('/', (connection) =\u003e {\n    connection.end('Simples Works');\n});\n```\n\n### Virtual Hosting\n\n```js\nconst host0 = server; // The server is in the same time the main host\nconst host1 = server.host('example.com'); // Other hosts\nconst host2 = server.host('example2.com');\n\n// Now for each host you can apply individual routing\nhost0.get('/', (connection) =\u003e {\n    connection.end('Main Host');\n});\n\nhost1.get('/', (connection) =\u003e {\n    connection.end('Host 1');\n});\n\nhost2.get('/', (connection) =\u003e {\n    connection.end('Host 2');\n});\n```\n\n### WebSocket\n\nLet's create an echo WebSocket server:\n\n```js\nserver.ws('/', {\n    limit: 1024, // The maximum size of a message\n    advanced: false, // Set connection advanced mode, see docs for more info\n    origins: ['null'] // Set accepted origins, \"null\" for localhost\n}, (connection) =\u003e {\n\n    // Log the new connection\n    console.log('New connection');\n\n    // Listen for messages to send them back\n    connection.on('message', (message) =\u003e {\n        console.log('Message: ' + message.data);\n        connection.send(message.data);\n    });\n\n    // Log connection close\n    connection.on('close', () =\u003e {\n        console.log('Connection closed');\n    });\n});\n```\n\nAccess the server from the browser built-in WebSocket API:\n\n```js\nconst socket = new WebSocket('ws://localhost/', 'echo');\n\n// Listen for messages\nsocket.onmessage = (event) =\u003e {\n    console.log(event.data);\n};\n\n// Send the first message\nsocket.send('ECHO');\n```\n\nAccess the server using [simples-ws](https://www.npmjs.com/package/simples-ws):\n\n```js\nimport ws from 'simples-ws';\n\nconst socket = ws('/', {\n    protocols: [\n        'echo'\n    ]\n});\n\n// Listen for messages\nsocket.on('message', (message) =\u003e {\n    console.log(message.data);\n});\n\n// Send the first message\nsocket.send('ECHO');\n```\n\nAccess the server from server-side simpleS client WebSocket API:\n\n```js\nconst simples = require('simples');\n\nconst client = simples.client();\n\nconst socket = client.ws('/');\n\n// Listen for messages\nsocket.on('message', (message) =\u003e {\n    console.log(message.data);\n});\n\n// Send the first message\nsocket.send('ECHO');\n```\n\n### Client Creation\n\n```js\nconst simples = require('simples');\n\nconst client = simples.client();\n\n// GET request\nclient.get('/').on('body', (response, body) =\u003e {\n    console.log('Response status: ' + response.status);\n    console.log('Response body: ' + body.toString());\n});\n\n// POST request\nclient.post('/send').send(/* data */).on('response', (response) =\u003e {\n    // Do something with the response\n}).on('body', (response, body) =\u003e {\n    console.log('Response body: ' + body.toString());\n});\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicnic%2Fsimples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicnic%2Fsimples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicnic%2Fsimples/lists"}