{"id":14981846,"url":"https://github.com/shyam-chen/express-starter","last_synced_at":"2025-04-04T20:14:31.508Z","repository":{"id":10222522,"uuid":"65018951","full_name":"Shyam-Chen/Express-Starter","owner":"Shyam-Chen","description":":truck: A boilerplate for API Server with Node.js, Express, and Mongoose on Nodemon.","archived":false,"fork":false,"pushed_at":"2024-01-22T12:21:10.000Z","size":4043,"stargazers_count":532,"open_issues_count":31,"forks_count":110,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-04T20:14:25.298Z","etag":null,"topics":["babel","express","heroku","mlab","mongoose","nodejs","nodemon","pm2"],"latest_commit_sha":null,"homepage":"","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/Shyam-Chen.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":"2016-08-05T13:03:56.000Z","updated_at":"2025-02-02T15:32:03.000Z","dependencies_parsed_at":"2024-01-22T14:24:25.621Z","dependency_job_id":"df3931fa-7779-4e44-96a6-f64596599969","html_url":"https://github.com/Shyam-Chen/Express-Starter","commit_stats":{"total_commits":695,"total_committers":2,"mean_commits":347.5,"dds":"0.0014388489208633226","last_synced_commit":"90d73b02836c734c2256fe71b741cd3b0823dd19"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FExpress-Starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FExpress-Starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FExpress-Starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FExpress-Starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shyam-Chen","download_url":"https://codeload.github.com/Shyam-Chen/Express-Starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242680,"owners_count":20907134,"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":["babel","express","heroku","mlab","mongoose","nodejs","nodemon","pm2"],"created_at":"2024-09-24T14:04:22.818Z","updated_at":"2025-04-04T20:14:31.485Z","avatar_url":"https://github.com/Shyam-Chen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Starter\n\n:truck: A boilerplate for Node.js, Express, Mongoose, Heroku, Atlas, Nodemon, PM2, and Babel.\n\n![Build Status](https://img.shields.io/circleci/build/github/Shyam-Chen/Express-Starter/main)\n![Coverage Status](https://img.shields.io/codecov/c/github/Shyam-Chen/Express-Starter/main)\n\n:rainbow: [Live Demo](https://backend-starter-kit.herokuapp.com/)\n\n:muscle: This seed repository provides the following features:\n\n- ---------- **Essentials** ----------\n- [x] Web application framework with [**Express**](http://expressjs.com/).\n- [x] Object-document mapping with [**Mongoose**](http://mongoosejs.com/).\n- [x] Make authenticated requests with [**Passport**](http://passportjs.org/).\n- [x] File upload with [**Multer**](https://github.com/expressjs/multer).\n- [x] Real-time communication with [**WS**](https://github.com/websockets/ws).\n- ---------- **Tools** ----------\n- [x] Next generation JavaScript with [**Babel**](https://github.com/babel/babel).\n- [x] JavaScript static code analyzer with [**ESLint**](https://github.com/eslint/eslint).\n- [x] Code formatter with [**Prettier**](https://prettier.io/).\n- [x] Unit testing with [**Jest**](https://github.com/facebook/jest).\n- [x] End-to-End testing with [**Supertest**](https://github.com/visionmedia/supertest).\n- [x] Mocking external requests with [**Nock**](https://github.com/nock/nock).\n- [x] Automatically restart application with [**Nodemon**](https://github.com/remy/nodemon).\n- [x] Keeping application alive with [**PM2**](https://github.com/Unitech/pm2).\n- [x] Reverse proxy with [**Caddy**](https://caddyserver.com/).\n- ---------- **Environments** ----------\n- [x] Cloud application hosting with [**Heroku**](https://www.heroku.com/).\n- [x] Cloud NoSQL database hosting with [**Atlas**](https://www.mongodb.com/cloud/atlas).\n- [x] Cloud storage hosting with [**Cloudinary**](https://cloudinary.com/).\n- [x] Error tracking service with [**Sentry**](https://sentry.io/).\n- [x] Software container with [**Docker**](https://github.com/docker/docker).\n- [x] Continuous integration with [**CircleCI**](https://circleci.com/).\n- [x] Fix and prevent known vulnerabilities with [**Snyk**](https://snyk.io/).\n- [x] Test coverage integration with [**Codecov**](https://codecov.io/).\n\n\u003e [!NOTE]\n\u003e\n\u003e :thinking: Think about next-generation application development:\n\u003e\n\u003e - [Fastify](https://github.com/fastify/fastify) is one of the fastest Node.js web frameworks.\n\u003e - [Nest](https://github.com/nestjs/nest) uses a modular architecture and allows the choice of either Express or **Fastify** as the server framework.\n\u003e\n\u003e If you're interested in Fastify, you can refer to my [Fastify Starter](https://github.com/Shyam-Chen/Fastify-Starter).\n\n## Table of Contents\n\n- [Project Setup](#project-setup)\n- [Dockerization](#dockerization)\n- [Configuration](#configuration)\n- [Examples](#examples)\n- [Directory Structure](#directory-structure)\n- [Microservices](#microservices)\n\n## Project Setup\n\nFollow steps to execute this boilerplate.\n\n### Install dependencies\n\n```sh\n$ npm install\n```\n\n### Start a development server\n\n```sh\n$ brew services start mongodb-community\n$ yarn serve\n```\n\n### Produce a production-ready bundle\n\n```sh\n$ yarn build\n```\n\n### Lints and fixes files\n\n```sh\n$ yarn lint\n```\n\n### Runs unit tests\n\nFiles: `src/**/*.spec.js`\n\n```sh\n$ yarn unit\n```\n\n### Runs end-to-end tests\n\nFiles: `e2e/**/*.spec.js`\n\n```sh\n# Before running the `meas` command, make sure to run the following commands.\n$ yarn build\n$ yarn preview\n\n# If it's not setup, run it.\n$ yarn setup\n\n$ yarn e2e\n```\n\n### Measures APIs\n\nFiles: `e2e/**/*.meas.js`\n\n```sh\n# Before running the `meas` command, make sure to run the following commands.\n$ yarn build\n$ yarn preview\n\n# If it's not setup, run it.\n$ yarn setup\n\n$ yarn meas\n```\n\n### Mocks third-party APIs\n\n```sh\n# If it's not active, run it.\n$ yarn active\n\n$ yarn mock\n```\n\n## Dockerization\n\nDockerize an application.\n\n1. Build and run the container in the background\n\n```bash\n$ docker-compose up -d mongodb app\n```\n\n2. Run a command in a running container\n\n```bash\n$ docker-compose exec app \u003cCOMMAND\u003e\n```\n\n3. Remove the old container before creating the new one\n\n```bash\n$ docker-compose rm -fs\n```\n\n4. Restart up the container in the background\n\n```bash\n$ docker-compose up -d --build app\n```\n\n## Configuration\n\nControl the environment.\n\n### Default environments\n\nSet your local environment variables. (use `export const \u003cENV_NAME\u003e = process.env.\u003cENV_NAME\u003e || \u003cLOCAL_ENV\u003e;`)\n\n```js\n// src/env.js\n\nexport const NODE_ENV = process.env.NODE_ENV || 'development';\nexport const INDEX_NAME = process.env.INDEX_NAME || 'local';\n\nexport const HOST = process.env.HOST || '0.0.0.0';\nexport const PORT = process.env.PORT || 3000;\n\nexport const SECRET_KEY = process.env.SECRET_KEY || 'jbmpHPLoaV8N0nEpuLxlpT95FYakMPiu';\n\nexport const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/test';\n\n// ---\n\nexport const FACEBOOK_APP_ID = process.env.FACEBOOK_APP_ID || 'XXX';\nexport const FACEBOOK_APP_SECRET = process.env.FACEBOOK_APP_SECRET || 'XXX';\n\nexport const GOOGLE_CLIENT_ID = process.env.GOOGLE_CLIENT_ID || 'XXX';\nexport const GOOGLE_CLIENT_SECRET = process.env.GOOGLE_CLIENT_SECRET || 'XXX';\n\nexport const APPLE_SERVICES_ID = process.env.APPLE_SERVICES_ID || 'XXX';\nexport const APPLE_TEAM_ID = process.env.APPLE_TEAM_ID || 'XXX';\nexport const APPLE_KEY_ID = process.env.APPLE_KEY_ID || 'XXX';\nexport const APPLE_PRIVATE_KEY = process.env.APPLE_PRIVATE_KEY || 'XXX';\n\nexport const CLOUDINARY_URL = process.env.CLOUDINARY_URL || 'cloudinary://key:secret@domain_name';\n\nexport const RATE_LIMIT = process.env.RATE_LIMIT || 0;\n\nexport const SENTRY_DSN = process.env.SENTRY_DSN || null;\n```\n\n### Continuous integration environments\n\nAdd environment variables to the CircleCI build.\n\n```sh\n# Project Settings \u003e Environment Variables \u003e Add Environment Variable\n\nSECRET_KEY\nMONGODB_URI\nCLOUDINARY_URL\nSENTRY_DSN\n```\n\n### File-based environments\n\nIf you want to set environment variables from a file.\n\n```ts\n.\n├── e2e\n├── envs\n│   ├── dev.js\n│   ├── stage.js\n│   └── prod.js\n├── mock\n└── src\n```\n\n```js\n// envs/\u003cENV_NAME\u003e.js\n\nfunction Environment() {\n  this.NODE_ENV = 'production';\n  // more...\n}\n\nmodule.exports = new Environment();\n```\n\n```sh\n$ npm install babel-plugin-transform-inline-environment-variables env-cmd -D\n```\n\n```js\n// babel.config.js\n\n    plugins: [\n      // ...\n      'transform-inline-environment-variables',\n    ],\n```\n\n```js\n// package.json\n\n  \"scripts\": {\n    // \"env-cmd -f ./envs/\u003cENV_NAME\u003e.js\" + \"yarn build\"\n    \"build:dev\": \"env-cmd -f ./envs/dev.js yarn build\",\n    \"build:stage\": \"env-cmd -f ./envs/stage.js yarn build\",\n    \"build:prod\": \"env-cmd -f ./envs/prod.js yarn build\",\n  },\n```\n\n## Examples\n\n- [Hello World](./src/hello-world)\n- [CRUD Operations](./src/crud-operations)\n- [Authentication](./src/authentication)\n- [File Uploads](./src/file-uploads)\n- [Realtime Data](./src/realtime-data)\n\n## Directory Structure\n\nThe structure follows the LIFT Guidelines.\n\n```coffee\n.\n├── e2e\n├── mock\n│   ├── requests\n│   └── responses\n├── src\n│   ├── core\n│   │   └── ...\n│   ├── \u003cFEATURE\u003e -\u003e feature modules\n│   │   ├── __tests__\n│   │   │   ├── controller.spec.js\n│   │   │   ├── service.spec.js\n│   │   │   └── model.spec.js\n│   │   ├── controller.js\n│   │   ├── service.js\n│   │   ├── model.js\n│   │   └── index.js\n│   ├── \u003cGROUP\u003e -\u003e module group\n│   │   └── \u003cFEATURE\u003e -\u003e feature modules\n│   │       ├── __tests__\n│   │       │   ├── controller.spec.js\n│   │       │   ├── service.spec.js\n│   │       │   └── model.spec.js\n│   │       ├── controller.js\n│   │       ├── service.js\n│   │       ├── model.js\n│   │       └── index.js\n│   ├── app.js\n│   ├── env.js\n│   └── server.js\n├── .editorconfig\n├── .eslintrc\n├── .gitignore\n├── .prettierrc\n├── babel.config\n├── Caddyfile\n├── circle.yml\n├── develop.Dockerfile\n├── docker-compose.yml\n├── Dockerfile\n├── jest.config.js\n├── LICENSE\n├── package-lock.json\n├── package.json\n├── processes.js\n├── produce.Dockerfile\n└── README.md\n```\n\n## Microservices\n\n\u003e Microservice architecture – a variant of the service-oriented architecture structural style – arranges an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight.\n\nSee [Server-side Micro-Fullstack](https://github.com/Shyam-Chen/Micro-Fullstack/tree/master/mbe) for instructions on how to create microservices from source code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyam-chen%2Fexpress-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyam-chen%2Fexpress-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyam-chen%2Fexpress-starter/lists"}