{"id":13452174,"url":"https://github.com/franciscop/server","last_synced_at":"2025-05-14T07:07:48.487Z","repository":{"id":41458003,"uuid":"76990724","full_name":"franciscop/server","owner":"franciscop","description":":desktop_computer: Simple and powerful server for Node.js","archived":false,"fork":false,"pushed_at":"2025-02-09T11:02:35.000Z","size":31961,"stargazers_count":3553,"open_issues_count":2,"forks_count":175,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-04-22T14:56:04.327Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://serverjs.io/","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/franciscop.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"Contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://www.paypal.me/franciscopresencia/19"}},"created_at":"2016-12-20T20:51:08.000Z","updated_at":"2025-04-22T09:49:47.000Z","dependencies_parsed_at":"2024-06-18T11:15:12.605Z","dependency_job_id":"5c6d7c90-e7bd-4302-8b2b-722e404a7848","html_url":"https://github.com/franciscop/server","commit_stats":{"total_commits":550,"total_committers":15,"mean_commits":"36.666666666666664","dds":0.5,"last_synced_commit":"87c82244f60a7fbb292247d92cb854e5afc3a629"},"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franciscop%2Fserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franciscop%2Fserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franciscop%2Fserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franciscop%2Fserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franciscop","download_url":"https://codeload.github.com/franciscop/server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251560170,"owners_count":21609159,"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-07-31T07:01:15.956Z","updated_at":"2025-05-06T17:28:52.258Z","avatar_url":"https://github.com/franciscop.png","language":"JavaScript","readme":"# **server.js** for Node.js\n\n[![Subscribe](https://img.shields.io/badge/%20subscribe%20-%20mailchimp%20-blue.svg )](http://eepurl.com/cGRggH)\n[![Downloads](https://img.shields.io/npm/dm/server.svg)](https://npm-stat.com/charts.html?package=server)\n[![Status](https://github.com/franciscop/server/workflows/tests/badge.svg)](https://github.com/franciscop/server/actions) [![Dependencies status](https://david-dm.org/franciscop/server/status.svg)](https://david-dm.org/franciscop/server)\n\nPowerful server for Node.js that just works so **you can focus on your awesome project**:\n\n```js\n// Include it and extract some methods for convenience\nconst server = require('server');\nconst { get, post } = server.router;\n\n// Launch server with options and a couple of routes\nserver({ port: 8080 }, [\n  get('/', ctx =\u003e 'Hello world'),\n  post('/', ctx =\u003e {\n    console.log(ctx.data);\n    return 'ok';\n  })\n]);\n```\n\n\u003cblockquote class=\"external\"\u003e\n  \u003cp\u003eSimplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better.\u003c/p\u003e\n  \u003ccite\u003e― Edsger W. Dijkstra\u003c/cite\u003e\n\u003c/blockquote\u003e\n\n\n## Getting started\n\nThere's a [whole tutorial on getting started for beginners](https://serverjs.io/tutorials/getting-started/) but the quick version is to first install `server` as a dependency:\n\n```bash\nnpm install server\n```\n\n\u003e Server requires **Node.js 7.6.0** or newer. **Node.js 8.x.y** LTS is recommended.\n\nThen you can create a file called `index.js` with this code:\n\n```js\n// Include the server in your file\nconst server = require('server');\nconst { get, post } = server.router;\n\n// Handle requests to the url \"/\" ( http://localhost:3000/ )\nserver([\n  get('/', ctx =\u003e 'Hello world!')\n]);\n```\n\nExecute this in the terminal to get the server started:\n\n```bash\nnode .\n```\n\nAnd finally, open your browser on [localhost:3000](http://localhost:3000/) and you should see 'Hello world!' on your browser.\n\n\n\n## Documentation\n\nThe library is documented here:\n\n\u003cstrong\u003e\u003ca class=\"button\" href=\"https://serverjs.io/documentation/\"\u003eFull Documentation\u003c/a\u003e\u003c/strong\u003e\n\n\u003e [**Subscribe here**](http://eepurl.com/cGRggH) to receive tutorials when released. Tutorials are *good for learning* while the documentation is good for reference/quick use *once you know the basics*.\n\nYou can also download the repository and try the examples by browsing to them and `node .` inside each of them in `/examples`.\n\n\n\n## Use cases\n\nThe package `server` is great for many situations. Let's see some of them:\n\n\n### Small to medium projects\n\nEverything works out of the box, you get great support for most features and you can easily tap into Express' middleware ecosystem. What's not to love?\n\nSome of the included features: body and file parsers, cookies, sessions, websockets, Redis, gzip, favicon, csrf, SSL, etc. They just work so you will save a headache or two and can focus on your actual project. Get a simple form going:\n\n```js\nconst server = require('server');\nconst { get, post } = server.router;\nconst { render, redirect } = server.reply;\n\nserver(\n  get('/', () =\u003e render('index.pug')),\n  post('/', ctx =\u003e {\n    console.log(ctx.data);\n    return redirect('/');\n  })\n);\n```\n\n\n\n### API design\n\nFrom the flexibility and expressivity of the bundle, designing APIs is a breeze:\n\n```js\n// books/router.js\nconst { get, post, put, del } = require('server/router');\nconst ctrl = require('./controller');\n\nmodule.exports = [\n  get('/book', ctrl.list),\n  get('/book/:id', ctrl.item),\n  post('/book', ctrl.create),\n  put('/book/:id', ctrl.update),\n  del('/book/:id', ctrl.delete)\n];\n```\n\n\n\n### Real time\n\nWebsockets were never this easy to use! With socket.io on the front-end, you can simply do this in the back-end to handle those events:\n\n```js\n// chat/router.js\nconst { socket } = require('server/router');\nconst ctrl = require('./controller');\n\nmodule.exports = [\n  socket('connect', ctrl.join),\n  socket('message', ctrl.message),\n  socket('disconnect', ctrl.leave)\n];\n```\n\n\n\n## Author \u0026 support\n\nThis package was created by [Francisco Presencia](http://francisco.io/) but hopefully developed and maintained by many others. See the [the list of contributors here](https://github.com/franciscop/server/graphs/contributors).\n\nYou can also [sponsor the project](https://serverjs.io/sponsor), get your logo in here and some other perks with tons of ♥\n","funding_links":["https://www.paypal.me/franciscopresencia/19"],"categories":["JavaScript","Repository","[Node.js](http://nodejs.org/) feature module and bundler"],"sub_categories":["Web Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscop%2Fserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranciscop%2Fserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscop%2Fserver/lists"}