{"id":14957572,"url":"https://github.com/watscho/express-mongodb-rest-api-boilerplate","last_synced_at":"2025-04-04T17:08:39.883Z","repository":{"id":44687479,"uuid":"228902426","full_name":"watscho/express-mongodb-rest-api-boilerplate","owner":"watscho","description":"A boilerplate for Node.js apps / Rest API / Authentication from scratch - express, mongodb (mongoose). Typescript","archived":false,"fork":false,"pushed_at":"2023-07-20T06:42:05.000Z","size":490,"stargazers_count":646,"open_issues_count":4,"forks_count":88,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T16:09:24.063Z","etag":null,"topics":["api","authentication","authorization","boilerplate","docker","docker-compose","express","express-js","jwt","jwt-authentication","mongodb","multilanguage","node","nodejs","redis","scratch","token-blacklisting","typescript","verification"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/watscho.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":"2019-12-18T18:52:33.000Z","updated_at":"2025-03-27T21:01:12.000Z","dependencies_parsed_at":"2024-12-21T03:08:45.760Z","dependency_job_id":"ffb3ce4e-e308-4887-9e30-f3047cb7049c","html_url":"https://github.com/watscho/express-mongodb-rest-api-boilerplate","commit_stats":{"total_commits":74,"total_committers":2,"mean_commits":37.0,"dds":"0.027027027027026973","last_synced_commit":"889fd1679326e9e2124ada1d67f59abb297dc0ed"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-mongodb-rest-api-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-mongodb-rest-api-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-mongodb-rest-api-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-mongodb-rest-api-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watscho","download_url":"https://codeload.github.com/watscho/express-mongodb-rest-api-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217184,"owners_count":20903009,"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":["api","authentication","authorization","boilerplate","docker","docker-compose","express","express-js","jwt","jwt-authentication","mongodb","multilanguage","node","nodejs","redis","scratch","token-blacklisting","typescript","verification"],"created_at":"2024-09-24T13:15:10.420Z","updated_at":"2025-04-04T17:08:39.862Z","avatar_url":"https://github.com/watscho.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [express-mongodb-rest-api-typescript-boilerplate](https://github.com/watscho/express-mongodb-rest-api-boilerplate)\n\n[![](https://img.shields.io/badge/author-@watscho-blue.svg)](https://www.linkedin.com/in/watscho)\n[![](https://api.codacy.com/project/badge/Grade/f4ea86b0cf474e928d34f3723aed349e)](https://app.codacy.com/gh/watscho/express-mongodb-rest-api-boilerplate)\n[![GitHub license](https://img.shields.io/github/license/watscho/express-mongodb-rest-api-boilerplate)](https://github.com/watscho/express-mongodb-rest-api-boilerplate/blob/master/LICENSE)\n\n## Authentication from scratch `TypeScript`\n\n- Sign In\n- Sign Up,\n- Reset Password\n- Update Profile\n- Update Password\n- Update Email\n- Update User Avatar\n- Delete Profile\n- Reset Password by E-mail\n- Verification Profile by E-mail\n- Signed Out Access Token blacklisting by Redis\n- Image Upload (public storage, Many-to-many relationships)\n- Multi language by i18Next\n- E-mail notifications\n\n### Package list\n\n| Package                 | Description                                                                                                                                                                                                                                                                                                                                                    |\n| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ts-node                 | TypeScript execution and REPL for node.js, with source map and native ESM support.                                                                                                                                                                                                                                                                             |\n| ts-node-dev             | It restarts target node process when any of required files changes (as standard node-dev) but shares Typescript compilation process between restarts. This significantly increases speed of restarting comparing to node-dev -r ts-node/register ..., nodemon -x ts-node ... variations because there is no need to instantiate ts-node compilation each time. |\n| tsc-alias               | Replace alias paths with relative paths after typescript compilation. You can add aliases that reference other projects outside your tsconfig.json project by providing a relative path to the baseUrl.                                                                                                                                                        |\n| tsconfig-paths          | Use this to load modules whose location is specified in the paths section of tsconfig.json or jsconfig.json. Both loading at run-time and via API are supported.                                                                                                                                                                                               |\n| typescript              | TypeScript is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS                                                                                                                                                    |\n| cross-env               | Run scripts that set and use environment variables across platforms                                                                                                                                                                                                                                                                                            |\n| express                 | Fast, unopinionated, minimalist web framework for Node.js.                                                                                                                                                                                                                                                                                                     |\n| email-templates         | Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for Forward Email and Lad.                                                                                                                                                                                                                                          |\n| nodemailer              | Easy as cake e-mail sending from your Node.js applications                                                                                                                                                                                                                                                                                                     |\n| ejs                     | Embedded JavaScript templates                                                                                                                                                                                                                                                                                                                                  |\n| cors                    | CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.                                                                                                                                                                                                                                     |\n| bcrypt                  | A library to help you hash passwords.                                                                                                                                                                                                                                                                                                                          |\n| dotenv                  | Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.                                                                                                                                              |\n| http-status-codes       | Constants enumerating the HTTP status codes. Based on the Java Apache HttpStatus API.                                                                                                                                                                                                                                                                          |\n| i18next                 | i18next is a very popular internationalization framework for browser or any other javascript environment (eg. Node.js, Deno).                                                                                                                                                                                                                                  |\n| i18next-http-middleware | This is a middleware to be used with Node.js web frameworks like express or Fastify and also for Deno.                                                                                                                                                                                                                                                         |\n| jsonwebtoken            | An implementation of JSON Web Tokens.                                                                                                                                                                                                                                                                                                                          |\n| mongoose                | Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports Node.js and Deno (alpha).                                                                                                                                                                                                                        |\n| randomstring            | A module for generating random strings                                                                                                                                                                                                                                                                                                                         |\n| redis                   | A modern, high performance Redis client                                                                                                                                                                                                                                                                                                                        |\n| validator               | A library of string validators and sanitizers.                                                                                                                                                                                                                                                                                                                 |\n| winston                 | A logger for just about everything.                                                                                                                                                                                                                                                                                                                            |\n| eslint                  | An AST-based pattern checker for JavaScript.                                                                                                                                                                                                                                                                                                                   |\n| eslint-config-prettier  | Turns off all rules that are unnecessary or might conflict with Prettier.                                                                                                                                                                                                                                                                                      |\n| eslint-plugin-import    | This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names. All the goodness that the ES2015+ static module syntax intends to provide, marked up in your editor.                                                                                                        |\n| eslint-plugin-prettier  | Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.                                                                                                                                                                                                                                                                           |\n| eslint-plugin-unicorn   | More than 100 powerful ESLint rules                                                                                                                                                                                                                                                                                                                            |\n| prettier                | Prettier is an opinionated code formatter                                                                                                                                                                                                                                                                                                                      |\n\n\u003chr/\u003e\n\n### Redis\n\nDownload Redis for Windows from the official [website](https://redis.io/docs/getting-started/installation/install-redis-on-windows/).\n\n_Mac (using [homebrew](http://brew.sh/)):_\n\n```bash\nbrew install redis\n```\n\n_Linux:_\n\n```bash\nsudo apt-get install redis-server\n```\n\n### Setup\n\nYou can install Node modules using either [npm](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/), which are both package managers for Node.js.\n\n```bash\nyarn install # or npm install\n```\n\nCOPY .env.example to .env\n\n```bash\ncp .env.example .env\n```\n\n### API Start\n\n```bash\nyarn start # or npm start\nyarn watch # or npm run watch - watch mode\nyarn build # or npm run build - production build\n```\n\n### ESlint Start\n\n```bash\nyarn lint # or npm run link\nyarn lint:write # or npm run lint:write - with prefix --fix\n```\n\n### Prettier Start\n\n```bash\nyarn prettier # or npm run prettier\nyarn prettier:write # or npm run prettier:write - with prefix --fix\n```\n\n## API Endpoints\n\n- POST: \u003chttp://localhost:8000/auth/sign-in\u003e Sign In\n- POST: \u003chttp://localhost:8000/auth/sign-up\u003e Sign Up\n- GET: \u003chttp://localhost:8000/auth/sign-out\u003e Sign Out\n- POST: \u003chttp://localhost:8000/auth/password/reset\u003e Reset Password\n- POST: \u003chttp://localhost:8000/auth/password/new/:accessToken\u003e New Password By Reset\n- GET: \u003chttp://localhost:8000/me\u003e Get User\n- POST: \u003chttp://localhost:8000/user/verification/request\u003e Verification Request\n- GET: \u003chttp://localhost:8000/user/verification/:accessToken\u003e Verify\n- POST: \u003chttp://localhost:8000/user/update\u003e Update User\n- POST: \u003chttp://localhost:8000/user/update/email\u003e Update Email\n- POST: \u003chttp://localhost:8000/user/update/password\u003e Update Password\n- POST: \u003chttp://localhost:8000/user/update/avatar\u003e Update Avatar\n- POST: \u003chttp://localhost:8000/user/delete\u003e Delete Profile\n- POST: \u003chttp://localhost:8000/media/image/upload\u003e Image upload\n\n### Mailcatcher\n\nIf you're looking for an easy-to-use tool to test your email SMTP functionality, I highly recommend using [Mailcatcher](https://mailcatcher.me/). Mailcatcher is a simple SMTP server that catches all your outgoing emails and displays them in a web interface for easy viewing.\n\n### To install [Prettier](https://prettier.io/) and [ESLint](https://eslint.org/) in [Visual Studio Code](https://code.visualstudio.com/), you can follow these steps:\n\n- Open Visual Studio Code and navigate to your project folder.\n- Press Ctrl + Shift + P (Windows) or Cmd + Shift + P (Mac) to open the Command Palette.\n- Type \"Extensions: Install Extensions\" and select the first option that appears.\n- In the search bar, type \"Prettier\" and select the first result that appears.\n- Click the \"Install\" button to install Prettier.\n- Repeat step 4 and 5 to install ESLint.\n\n### API Structure\n\n```bash\n.\n├── src\n│  ├── @types\n│  │  └── global.d.ts\n│  ├── constants\n│  │  └── index.ts\n│  ├── contracts\n│  │  ├── auth.ts\n│  │  ├── jwt.ts\n│  │  ├── media.ts\n│  │  ├── request.ts\n│  │  └── user.ts\n│  ├── controllers\n│  │  ├── authController.ts\n│  │  ├── index.ts\n│  │  ├── mediaController.ts\n│  │  └── userController.ts\n│  ├── dataSources\n│  │  ├── index.ts\n│  │  ├── mongoose.ts\n│  │  └── redis.ts\n│  ├── guards\n│  │  ├── authGuard.ts\n│  │  └── index.ts\n│  ├── i18n\n│  │  ├── index.ts\n│  │  └── translations\n│  │     ├── en.json\n│  │     └── ka.json\n│  ├── index.ts\n│  ├── infrastructure\n│  │  ├── image.ts\n│  │  ├── logger.ts\n│  │  └── upload.ts\n│  ├── mailer\n│  │  ├── index.ts\n│  │  ├── mailer.ts\n│  │  └── userMail.ts\n│  ├── middlewares\n│  │  ├── authMiddleware.ts\n│  │  ├── corsMiddleware.ts\n│  │  ├── index.ts\n│  │  ├── notFoundMiddleware.ts\n│  │  └── uploadSingleImageMiddleware.ts\n│  ├── models\n│  │  ├── index.ts\n│  │  ├── media.ts\n│  │  ├── resetPassword.ts\n│  │  ├── user.ts\n│  │  └── verification.ts\n│  ├── routes\n│  │  ├── auth.ts\n│  │  ├── index.ts\n│  │  ├── media.ts\n│  │  └── users.ts\n│  ├── services\n│  │  ├── index.ts\n│  │  ├── mediaService.ts\n│  │  ├── resetPasswordService.ts\n│  │  ├── userService.ts\n│  │  └── verificationService.ts\n│  ├── storage\n│  │  └── public\n│  ├── templates\n│  │  ├── resetPassword\n│  │  │  └── html.ejs\n│  │  ├── signUp\n│  │  │  └── html.ejs\n│  │  ├── successfullyDeleted\n│  │  │  └── html.ejs\n│  │  ├── successfullyUpdatedEmail\n│  │  │  └── html.ejs\n│  │  ├── successfullyUpdatedPassword\n│  │  │  └── html.ejs\n│  │  ├── successfullyUpdatedProfile\n│  │  │  └── html.ejs\n│  │  ├── successfullyVerified\n│  │  │  └── html.ejs\n│  │  └── verification\n│  │     └── html.ejs\n│  ├── utils\n│  │  ├── cryptoString.ts\n│  │  ├── dates.ts\n│  │  ├── hash.ts\n│  │  ├── headers.ts\n│  │  ├── jwt.ts\n│  │  ├── maths.ts\n│  │  └── paths.ts\n│  └── validations\n│     ├── authValidation.ts\n│     ├── index.ts\n│     └── userValidation.ts\n├── .env\n├── .env.example\n├── .eslintrc\n├── .gitignore\n├── .nvmrc\n├── .prettierrc\n├── api-logs.log\n├── LICENSE\n├── package.json\n├── README.md\n├── tsconfig.json\n└── yarn.lock\n```\n\n**Note:** For any question [issues](https://github.com/watscho/express-mongodb-rest-api-boilerplate/issues)\n\n## License\n\nThis project is an open-source with an [MIT License](https://github.com/watscho/express-mongodb-rest-api-boilerplate/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatscho%2Fexpress-mongodb-rest-api-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatscho%2Fexpress-mongodb-rest-api-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatscho%2Fexpress-mongodb-rest-api-boilerplate/lists"}