{"id":23611563,"url":"https://github.com/rawsashimi1604/express-server-boilerplate","last_synced_at":"2026-04-05T23:02:16.841Z","repository":{"id":60275053,"uuid":"540613617","full_name":"rawsashimi1604/express-server-boilerplate","owner":"rawsashimi1604","description":"Dockerized boilerplate RESTful API made using express.js. Built based on TDD (Test Driven Development) methodology and links to PostgreSQL database.","archived":false,"fork":false,"pushed_at":"2022-09-27T14:17:18.000Z","size":231,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-03T15:37:20.561Z","etag":null,"topics":["docker","expressjs","jest","nodejs","postgresql","supertest","tdd"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rawsashimi1604.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-23T20:52:54.000Z","updated_at":"2023-03-07T07:50:55.000Z","dependencies_parsed_at":"2022-09-27T13:50:17.130Z","dependency_job_id":null,"html_url":"https://github.com/rawsashimi1604/express-server-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rawsashimi1604/express-server-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawsashimi1604%2Fexpress-server-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawsashimi1604%2Fexpress-server-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawsashimi1604%2Fexpress-server-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawsashimi1604%2Fexpress-server-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rawsashimi1604","download_url":"https://codeload.github.com/rawsashimi1604/express-server-boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawsashimi1604%2Fexpress-server-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31452901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","expressjs","jest","nodejs","postgresql","supertest","tdd"],"created_at":"2024-12-27T16:16:08.464Z","updated_at":"2026-04-05T23:02:16.808Z","avatar_url":"https://github.com/rawsashimi1604.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express.js Backend Server Boilerplate\nThis is a boilerplate Express.js / PostgreSQL REST API starter project. It is built using the TDD (Test Driven Development) methodology and includes an example `GET`, `POST` and `DELETE` routes. The project is also Dockerized. \n\n\u003cbr\u003eYou can fork this project to begin building RESTful APIS using Express.js/Node.js.\n\n## Technologies used\n- Docker\n- PostgreSQL\n- Node.js\n- Express.js \n- Prettier\n- Jest\n- Supertest\n- Prettier\n\n## Requirements\n- You should have Docker Desktop installed on your local machine.\n- You should create a Docker volume: `postgres-data` to persist database data.\n- You should have Node and npm installed on your machine to run the npm scripts.\n- You should run the docker container in a Linux/MacOS environment to enable hot reloading (Nodemon) in the container.\n- You should have an `.env` file created in the root directory of this project. Details of `.env` file will be provided below.\n\n### Environment File Contents\n\nCreate `.env` file, put in root directory. Contents:\n\n```\nBACKEND_PORT=8085\nFRONTEND_PORT=5000\n\nPOSTGRES_USER=postgres\nPOSTGRES_PASSWORD=\u003cchoose any password\u003e\nPOSTGRES_HOST=db\nPOSTGRES_PORT=5432\nPOSTGRES_DB=defaultdb\n\nFRONTEND_APP_URL=\u003cFor deployment, not needed for local development.\u003e\n```\n## Scripts\n- `npm run test` to run automated tests built using Jest and Supertest.\n- `npm run start` to start project using Node\n- `npm run dev` to start project using Nodemon (Auto Refresh on change)\n- `npm run beautify` to run Prettier on project (CI/CD code beautification tool)\n- `npm run docker-compose-down` to stop running Dockerized containers built by `docker-compose.yml` and removes the stopped containers.\n- `npm run docker-compose-up:dev` to create and start containers built by `docker-compose.yml`.\n- `npm run docker:dev` to automate building of containers, running `docker-compose up` and `docker-compose down` as well as real time logging including `docker-compose logs`.\n\nYou should be able to start the application using `npm run docker:dev`\n\n## General development guide\n### Setup\n- Make sure you have Docker on your machine. Use the command `docker ps` to check.\n- Create the postgres volume.\n```\n// Creating the docker volume\ndocker volume create postgres-data\n\n// Check if volume was created\ndocker volume ls\n```\n\n- Create the `.env` file and put it in the root directory.\n- Run the command `npm run docker:dev` to start the docker container.\n- You should see this if the container was run correctly.\n\n```\nServer has successfully started on port: 8085\n```\n\n### Prettier, code beautification\nTo achieve a similar standard of coding standards throughout the codebase, run `npm run beautify` before every code commit.\n### Test Driven Development (TDD)\n#### Methodology\nThis project was created with TDD in mind. This means that software test cases are written before developing the software completely. For more information: https://blog.logrocket.com/node-js-express-test-driven-development-jest/\n\n### Running tests\n- Try to use a Linux / MacOS distribution to start the container.\n- Run the tests inside the container\n- To run tests inside container, use the command: \n```\n// To get container name\ndocker ps\n\n// This will start the terminal shell in container\ndocker exec -it \u003cyour container name\u003e sh\n\n# npm run tests\n```\n\n### Structure of the project\n\nThe project is divided into 3 main sections:\n- `src`: all source code pertaining to the REST API server.\n- `db`: all databases configuration and code.\n- `test`: all tests.\n\n#### src\n```\n├── src (source code directory)\n|   ├── controller (contains all business logic)\n|   |   ├── vehicle.js (Vehicle Controller)\n|   |   ├── ... \n|   ├── lib (contains a library of other functions used throughout the project)\n|   |   ├── utils (utility functions)\n|   |   ├── vehicle (Vehicle functions)\n|   |   ├── ... \n|   ├── middleware (Express middleware)\n|   ├── routes (Routers used throughout the project)\n|   ├── app.js (main application builder)\n|   ├── server.js (Build app and server to ports)\n```\n\n- `controller` contains all business logic in the project. For example, logic needed to complete certain features (getting vehicles, deleting vehicles, etc...)\n- `lib` contains all other functions needed in the project. It can be further subdivided into `utils` (which contains utility functions used throughout all modules) and `\u003ccontroller based functions\u003e` which contains functions used in the specific controller/service subdomain only.\n- `middleware` contains all Express middleware used thorughout the project\n- `routes` contains all the API routes used in the project. They are linked to the controller\n- `app.js` is the application builder based on a Database object `(Depedency Injection)`\n- `server.js` is the main entrypoint of the application. It builds an app and serves to it to ports.\n  - CORS (Cross origin resoure sharing) is also enabled for the frontend. It is controlled using the `FRONTEND_PORT` (local) and `FRONTEND_APP_URL` (production) environment variables. \n\n#### db\n```\n├── db (database directory)\n|   ├── psql (PostgreSQL database Object)\n|   |   ├── relations\n|   |   |   ├── index (entrypoint to database.js)\n|   |   |   ├── vehicle (Vehicle Table relation)\n|   |   |   ├── ...\n|   ├── config.js (config file)\n|   ├── database.js (helps map database relations)\n|   ├── index.js (Main entrypoint to server.js.)\n```\n- More info on dependency injection: https://www.youtube.com/watch?v=yOC0e0NMZ-E\u0026ab_channel=SamMeech-Ward\n- The database is injected into the express app. \n- Each relation is accessed through its own file and has their own functions to query the database. \n- A config file helps build the database using `.env` variables set.\n\n#### tests\nTests are also subdivided into their own directories mapped to the project structure.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawsashimi1604%2Fexpress-server-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frawsashimi1604%2Fexpress-server-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawsashimi1604%2Fexpress-server-boilerplate/lists"}