{"id":17349209,"url":"https://github.com/co2-git/express-emitter","last_synced_at":"2025-03-27T11:44:25.317Z","repository":{"id":57154849,"uuid":"49766104","full_name":"co2-git/express-emitter","owner":"co2-git","description":"one-liner HTTP server ","archived":false,"fork":false,"pushed_at":"2016-08-17T22:44:30.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T16:23:15.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/co2-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-16T08:42:30.000Z","updated_at":"2016-01-16T08:43:57.000Z","dependencies_parsed_at":"2022-09-07T18:31:14.760Z","dependency_job_id":null,"html_url":"https://github.com/co2-git/express-emitter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fexpress-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fexpress-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fexpress-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fexpress-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co2-git","download_url":"https://codeload.github.com/co2-git/express-emitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841690,"owners_count":20681184,"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":[],"created_at":"2024-10-15T16:55:02.718Z","updated_at":"2025-03-27T11:44:25.287Z","avatar_url":"https://github.com/co2-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"express-emitter\n===\n\nStart a new HTTP server in one-line. Based on express. Emittable and controllable. Also supports cluster mode.\n\n# One-liner\n\nCreate a new HTTP server that is ready to accept incoming connections in one line:\n\n```js\nimport Server from 'express-emitter';\n\n// Launches a new HTTP server\nnew Server();\n```\n\n# Listen\n\n`Server` extends node's `EventEmitter` so you can listen to it:\n\n```js\nnew Server()\n  .on('listening', () =\u003e console.log('Server is listening'))\n  .on('error', error =\u003e console.log(error.stack))\n  .on('closed', () =\u003e console.log('Server is closed'));\n```\n\n# Events\n\n- listening\n- error\n- closed\n- starting\n- closing\n- reloading\n- reloaded\n- reloading-fork\n- fork-reloaded\n\n# Stop and restart server\n\n```js\nconst server = new Server();\n\n// Stop server\nserver.stop();\n\n// Start server\nserver.start();\n\n// Restart server\nserver.restart();\n\n// You can chain control actions with listeners\nserver\n  .restart()\n  .on('closed', () =\u003e console.log('closed'))\n  .on('listening', () =\u003e console.log('listening'));\n```\n\n# Customize app\n\nYou can customize the express app:\n\n```js\nnew Server(app =\u003e {\n  app.set('port', 4000);\n  app.get('/', (req, res) =\u003e res.send('Welcome to my server!'));\n  app.use('/', (req, res, next) =\u003e next(new Error('Only GET accepted !')));\n});\n```\n\nCheckout express documentation for more.\n\n# Cluster support\n\n```js\nnew Server((app) =\u003e {}, {cluster: true});\n```\n\nBy default, it will create as many forks as they are CPUs in the machine, but you can customize the number of forks:\n\n```js\nnew Server((app) =\u003e {}, {cluster: 2});\n```\n\nTo reload forks:\n\n```js\nserver.reload();\n```\n\nThis will emit:\n\n- `reloading`\n- `reloading-fork` for each fork\n- `reloaded-fork` for each fork complete\n- `reloaded` when all forks are done\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fexpress-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco2-git%2Fexpress-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fexpress-emitter/lists"}