{"id":20581251,"url":"https://github.com/jonathas/node-project-skeleton","last_synced_at":"2025-04-14T19:51:54.424Z","repository":{"id":141968001,"uuid":"108392378","full_name":"jonathas/node-project-skeleton","owner":"jonathas","description":"This project contains the skeleton I usually have in my Node projects","archived":false,"fork":false,"pushed_at":"2023-01-07T13:44:53.000Z","size":386,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T08:11:36.029Z","etag":null,"topics":["apidoc","docker","docker-compose","gulp","javascript","mongodb","nginx","nginx-proxy","nodejs","pm2","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/jonathas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-10-26T09:45:37.000Z","updated_at":"2023-01-07T13:48:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e2677c1-2ffc-4846-afe6-afc94700ddc3","html_url":"https://github.com/jonathas/node-project-skeleton","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/jonathas%2Fnode-project-skeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathas%2Fnode-project-skeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathas%2Fnode-project-skeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathas%2Fnode-project-skeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathas","download_url":"https://codeload.github.com/jonathas/node-project-skeleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248951776,"owners_count":21188418,"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":["apidoc","docker","docker-compose","gulp","javascript","mongodb","nginx","nginx-proxy","nodejs","pm2","redis","typescript"],"created_at":"2024-11-16T06:27:45.698Z","updated_at":"2025-04-14T19:51:54.410Z","avatar_url":"https://github.com/jonathas.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Project Skeleton\n\n## Disclaimer (January of 2023)\n\nI've implemented this example in 2017, when API development was very different from today.\nNow in the beginning of 2023 I thought about updating it but then decided to keep it as it is for historical reasons and because there are just way too many things I'd change, so it would be better to start a similar project from scratch.\n\nLet me list below what I would do different if this was done today:\n\n- Use swagger (documentation in a json file) instead of apidoc\n- Follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/#summary) for writing the commit messages\n- Versioning done with the help of [release-it](https://www.npmjs.com/package/release-it)\n- Drop gulp and use only typescript instead.\n- jest instead of mocha for the tests\n- jest instead of istanbul for code coverage\n- fastify instead of express\n- eslint instead of tslint\n- Enforce proper rules with eslint. [Example here](https://gist.github.com/jonathas/c6b5f110e1eaf92d94ac976a19a3a178)\n- nodemon is not needed anymore\n- bluebird is not needed anymore\n\nTruth be told, nowadays I'd recommend to start an API in Node.js using [Nest](https://nestjs.com/), which already gives you a well implemented architecture to start your project with. So I might be creating a similar project soon, but using Nest instead, and then we can compare the differences.\n\n## Intro\n\nThis project contains the skeleton I usually have in my Node projects.\n\nWhat is used here: Express, Mocha, Istanbul, apiDoc, gulp, TypeScript, MongoDB, Redis, pm2, Docker, Nginx, SSL, etc.\n\n## Initial dependencies\n\n- [yarn](https://yarnpkg.com/)\n- [nvm](https://github.com/creationix/nvm)\n- [docker](https://www.docker.com)\n- [docker-compose](https://docs.docker.com/compose/install/)\n\n## Setting up\n\nInside the infra directory, there are 3 ways of running the infrastructure for the project:\n\n- standalone, which is for when you want to deploy all the containers in the same server.\n- server-ssl, which is when you want to deploy to servers behind a load balancer, but this load balancer doesn't accept ssl termination.\n- server, which is when you want to deploy to servers behind a load balancer and this load balancer accepts ssl termination, so the servers receive unencrypted requests from it.\n\nOf course, you can always deploy to a PaaS instead, if you don't want to run the infrastructure by yourself.\n\nIf you want to run the project using the standalone or the server-ssl mode, you will need to have your SSL certificate and its private key inside infra/common/ssl. You can generate a self-singned one by following the tutorial inside the infra/common/ssl/test directory.\n\nYou also need to generate a dhparam.pem file, which can be done by running the gen_dhparam.sh script inside infra/common/ssl. This will take a while to run.\n\nInside api/process.yml you can configure how many instances pm2 will start.\n\nThen you can install the packages inside the api directory:\n\n```bash\n$ yarn install\n```\n\nand generate the necessary files before starting the server:\n\n```bash\n$ ./node_modules/.bin/gulp\n```\n\n## Running\n\nIf you choose to run the infra from server-ssl, you will have to start the database containers as well, as server-ssl is not standalone.\n\nIf you choose to run the infra inside the standalone directory, then it contains also the container for the database and cache.\n\nThe way you can run any of these infrastructures is by pointing docker-compose to the chosen yml file inside the infra directory:\n\n```bash\n$ docker-compose -f \u003cyour file here\u003e up\n```\n\nThen you can use a service file like the one inside infra/standalone/host for configuring the infra to start on boot, in case the server restarts.\n\nJust change the path inside of it so it points to the right directory, then copy it to /etc/systemd/system, reload and enable the daemon:\n\n```bash\n$ sudo systemctl daemon-reload\n$ sudo systemctl enable docker-infra\n```\n\n## Developing\n\nIf you want to run the project for development, the standalone infra is the best way to do it, with the docker-dev.yml file, as it is configured to reload pm2 on every code change:\n\n```bash\n$ cd infra/standalone\n$ docker-compose -f docker-dev.yml up\n```\n\nPs: Generate the SSL certificate before doing that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathas%2Fnode-project-skeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathas%2Fnode-project-skeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathas%2Fnode-project-skeleton/lists"}