{"id":17949978,"url":"https://github.com/noook/express-server-boilerplate","last_synced_at":"2025-04-03T15:43:41.871Z","repository":{"id":123779155,"uuid":"155455550","full_name":"noook/express-server-boilerplate","owner":"noook","description":null,"archived":false,"fork":false,"pushed_at":"2018-10-30T21:50:48.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T04:28:00.212Z","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/noook.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-30T20:59:51.000Z","updated_at":"2018-10-30T21:52:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"42c86047-1c4f-426e-9193-ad582bfeef6f","html_url":"https://github.com/noook/express-server-boilerplate","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/noook%2Fexpress-server-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noook%2Fexpress-server-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noook%2Fexpress-server-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noook%2Fexpress-server-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noook","download_url":"https://codeload.github.com/noook/express-server-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247031368,"owners_count":20872288,"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-29T09:36:10.744Z","updated_at":"2025-04-03T15:43:41.849Z","avatar_url":"https://github.com/noook.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express server boilerplate\n\n## Init\n\nThis server will try to connect to a postgresql server with the configuration file you provided in `config/index.js`.\nRename `config/index.js.dist` to `config/index.js` and fill in your credentials and database name.\n\nRun `npm i` to install the dependencies.\n\nRun `npm run dev` to run the server. It will reload on each file modification.\n\n## Controllers\n\nFirst level controllers are imported at the server root. An example was provided :\n```js\napp.use('/hello', require('./controllers/hello'));\n```\nThis will redirect request from the `/hello` endpoint to the `./controllers/hello` router.\n\n## Services\n\nServices are helpers and are made to dissociate controllers from logic. You can't require any service in a service file. Services are automatically added whenever you write any javascript file in the `./services` folder. To declare a new service, each file must begin with a header that indicates the name of the service : \n```js\n/**\n * @service servicename\n */\n```\n\nWhen you'll require a service, it will then have the name `$servicename`.\n\nYou can require services in controllers by destructuring the service object. You can then easily edit the list of imported services : \n```js\nconst { $hello, $servicename, $service2 } = require.main.require('./services');\n```\n\n## Database\n\nDatabase uses by default PostgreSQL. We will use here `knex` to connect to the database, make queries, and apply migration scripts. To create a migration script, move to the `database` folder and run `knex migrate:make \u003cmigration-script-name\u003e`\n\nApply migration script, still in the same folder with `knex migrate:latest`\n\nTo use the `$db` services and make queries, this is the only service you can require in another service.\n```js\nconst $db = require.main.require('./database');\n```\n\n## Requests Logging\n\nYou can keep track of received requests with the log middleware :\n```\n[22:46:21] 200 GET request received on /hello 7ms\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoook%2Fexpress-server-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoook%2Fexpress-server-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoook%2Fexpress-server-boilerplate/lists"}