{"id":15040554,"url":"https://github.com/watscho/express-graphql-mongodb-boilerplate","last_synced_at":"2025-07-10T17:32:51.924Z","repository":{"id":55868138,"uuid":"214124186","full_name":"watscho/express-graphql-mongodb-boilerplate","owner":"watscho","description":"A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).","archived":false,"fork":false,"pushed_at":"2020-12-13T11:02:44.000Z","size":176,"stargazers_count":352,"open_issues_count":1,"forks_count":60,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-19T15:08:28.287Z","etag":null,"topics":["api","authentication","authorization","boilerplate","compose","docker","docker-compose","express","graphql","graphql-compose","mongodb","mongoose","multi-language","node","nodejs","redis","scratch","token","token-blacklisting","verification"],"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/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}},"created_at":"2019-10-10T08:08:30.000Z","updated_at":"2024-10-29T11:13:39.000Z","dependencies_parsed_at":"2022-08-15T08:10:24.673Z","dependency_job_id":null,"html_url":"https://github.com/watscho/express-graphql-mongodb-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/watscho/express-graphql-mongodb-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-graphql-mongodb-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-graphql-mongodb-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-graphql-mongodb-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-graphql-mongodb-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watscho","download_url":"https://codeload.github.com/watscho/express-graphql-mongodb-boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watscho%2Fexpress-graphql-mongodb-boilerplate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264619495,"owners_count":23638464,"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","compose","docker","docker-compose","express","graphql","graphql-compose","mongodb","mongoose","multi-language","node","nodejs","redis","scratch","token","token-blacklisting","verification"],"created_at":"2024-09-24T20:44:44.218Z","updated_at":"2025-07-10T17:32:51.903Z","avatar_url":"https://github.com/watscho.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [express-graphql-mongodb-boilerplate](https://github.com/watscho/express-graphql-mongodb-boilerplate)\n\n**Also [express-mongodb-rest-api-boilerplate](https://github.com/watscho/express-mongodb-rest-api-boilerplate) - 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/0b49c33797cc49b98502e249f27326de)](https://www.codacy.com/manual/watscho/express-graphql-mongodb-boilerplate?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=watscho/express-graphql-mongodb-boilerplate\u0026utm_campaign=Badge_Grade)\n[![GitHub license](https://img.shields.io/github/license/watscho/express-graphql-mongodb-boilerplate)](https://github.com/watscho/express-graphql-mongodb-boilerplate/blob/master/LICENSE)\n\n## Authentication from scratch\n\n### Sign In, Sign Up, Reset Password, Change Password, Update User\n\n### E-mail verification, Multi language, Redis for token blacklisting\n\n### Package list\n\n| Package                    | Description                                                                                                                                                                                                                                                                                                                                                           |\n| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| bcryptjs                   | Optimized bcrypt in JavaScript with zero dependencies. Compatible to the C++ bcrypt binding on node.js and also working in the browser.                                                                                                                                                                                                                               |\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| crypto-random-string       | Generate a cryptographically strong random string                                                                                                                                                                                                                                                                                                                     |\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| ejs                        | Embedded JavaScript templates                                                                                                                                                                                                                                                                                                                                         |\n| email-templates            | Create, preview, and send custom email templates for Node.js. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for sending beautiful emails with Lad.                                                                                                                                               |\n| express                    | Fast, unopinionated, minimalist web framework for node.                                                                                                                                                                                                                                                                                                               |\n| express-graphql            | Create a GraphQL HTTP server with any HTTP web framework that supports connect styled middleware, including Connect itself, Express and Restify.                                                                                                                                                                                                                      |\n| graphql                    | The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.                                                                                                                                                                                                                                                                   |\n| graphql-compose            | GraphQL – is a query language for APIs. graphql-js is the reference implementation of GraphQL for nodejs which introduce GraphQL type system for describing schema (definition over configuration) and executes queries on the server side. express-graphql is a HTTP server which gets request data, passes it to graphql-js and returned result passes to response. |\n| graphql-compose-mongoose   | This is a plugin for graphql-compose, which derives GraphQLType from your mongoose model. Also derives bunch of internal GraphQL Types. Provide all CRUD resolvers, including graphql connection, also provided basic search via operators ($lt, $gt and so on).                                                                                                      |\n| i18next                    | i18next is a very popular internationalization framework for browser or any other javascript environment (eg. node.js).                                                                                                                                                                                                                                               |\n| i18next-express-middleware | This is a middleware to use i18next in express.js.                                                                                                                                                                                                                                                                                                                    |\n| ioredis                    | A robust, performance-focused and full-featured Redis client for Node.js.                                                                                                                                                                                                                                                                                             |\n| jsonwebtoken               | This was developed against draft-ietf-oauth-json-web-token-08. It makes use of node-jws                                                                                                                                                                                                                                                                               |\n| module-alias               | Create aliases of directories and register custom module paths in NodeJS like a boss!                                                                                                                                                                                                                                                                                 |\n| moment                     | A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.                                                                                                                                                                                                                                                                    |\n| mongoose                   | Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks.                                                                                                                                                                                                                            |\n| nodemailer                 | Send e-mails from Node.js – easy as cake!                                                                                                                                                                                                                                                                                                                             |\n| validator                  | A library of string validators and sanitizers.                                                                                                                                                                                                                                                                                                                        |\n| winston                    | A logger for just about everything.                                                                                                                                                                                                                                                                                                                                   |\n\n### Redis\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### First, we use [yarn](https://yarnpkg.com/) - [workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) with [lerna](https://www.npmjs.com/package/lerna)\n\n[Introducing Yarn Workspaces](https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/)\n\n```bash\ncd workspaces/api\n```\n\n### COPY .env.example to .env\n\n```bash\ncp .env.example .env\n```\n\n**Note:** I highly recommend installing [nodemon](https://github.com/remy/nodemon).\n\nnodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.\nnodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for `node`, to use `nodemon` replace the word `node` on the command line when executing your script.\n`yarn global add nodemon`.\n\n### API Start\n\n```bash\nyarn start\nyarn start:local # with nodemon\n```\n\n### Docker compose\n\n```bash\ndocker-compose up -d --build\ndocker-compose -f docker-compose.dev.yml up --build # with nodemon\n```\n\n### ESlint Start\n\n```bash\nyarn lint\nyarn lint:write # with prefix --fix\n```\n\n### API Structure\n\n```bash\n├─ src\n│  ├─ graphql\n│  │  ├─ index.js\n│  │  ├─ schema.js\n│  │  └─ types.js\n│  ├─ i18next\n│  │  ├─ locales\n│  │  │  ├─  en.json\n│  │  │  └─  ge.json\n│  │  └─ index.js\n│  ├─ middleware\n│  │  ├─ authentication.js\n│  │  ├─ authMiddleware.js\n│  │  └─  index.js\n│  ├─ module\n│  │  ├─ auth\n│  │  │  ├─ mail\n│  │  │  │  ├─ index.js\n│  │  │  │  └─ userMail.js\n│  │  │  ├─ service\n│  │  │  │  ├─ index.js\n│  │  │  │  └─ userService.js\n│  │  │  ├─ index.js\n│  │  │  ├─ resolvers.js\n│  │  │  ├─ types.js\n│  │  │  └─ user.js\n│  │  └─ index.js\n│  ├─ service\n│  │  ├─ logger.js\n│  │  └─ nodemailer.js\n│  ├─ validator\n│  │  ├─ index.js\n│  │  └─ userValidator.js\n│  ├─ view\n│  │  └─ template\n│  │     ├─ reset-password\n│  │     │  └─ html.ejs\n│  │     ├─ verify\n│  │     │  └─ html.ejs\n│  │     └─ verify-request\n│  │        └─ html.ejs\n│  ├─ index.js\n│  ├─ mongoose.js\n│  └─ redis.js\n├─ .dockerignore\n├─ .env.example\n├─ .eslintignore\n├─ .eslint\n├─ .gitignore\n├─ Dockerfile\n├─ Dockerfile.dev\n├─ LICENSE\n├─ README.md\n├─ docker-compose.dev.yml\n├─ docker-compose.yml\n└─ package.json\n```\n\n**Note:** To continue development, you should learn about [graphql-compose](https://graphql-compose.github.io) - this is the library that I use to write the API, you can read about it at the link: [docs](https://graphql-compose.github.io/docs/intro/quick-start.html)\n\n## Queries\n\n```graphql\nquery user {\n  user {\n    _id\n    email\n    firstName\n    lastName\n    locale\n    account {\n      verification {\n        verified\n      }\n    }\n    updatedAt\n    createdAt\n  }\n}\n```\n\n## Mutations\n\n```graphql\nmutation signIn($email: String!, $password: String!) {\n  signIn(email: $email, password: $password) {\n    accessToken\n  }\n}\n\nmutation signUp($email: String!, $password: String!) {\n  signUp(email: $email, password: $password) {\n    accessToken\n  }\n}\n\nmutation logout {\n  logout {\n    succeed\n  }\n}\n\nmutation verifyRequest {\n  verifyRequest {\n    succeed\n  }\n}\n\nmutation verify($token: String!) {\n  verify(token: $token) {\n    accessToken\n  }\n}\n\nmutation resetPassword($email: String!) {\n  resetPassword(email: $email) {\n    succeed\n  }\n}\n\nmutation newPassword($token: String!, $newPassword: String!) {\n  newPassword(token: $token, newPassword: $newPassword) {\n    accessToken\n  }\n}\n\nmutation changePassword($currentPassword: String!, $newPassword: String!) {\n  changePassword(currentPassword: $currentPassword, newPassword: $newPassword) {\n    succeed\n  }\n}\n\nmutation updateUser($email: String!, $firstName: String!, $lastName: String!) {\n  updateUser(email: $email, firstName: $firstName, lastName: $lastName) {\n    _id\n    email\n    firstName\n    lastName\n    locale\n    account {\n      verification {\n        verified\n      }\n    }\n    updatedAt\n    createdAt\n  }\n}\n\nmutation switchLocale($locale: Locale!) {\n  switchLocale(locale: $locale) {\n    _id\n    email\n    firstName\n    lastName\n    locale\n    account {\n      verification {\n        verified\n      }\n    }\n    updatedAt\n    createdAt\n  }\n}\n```\n\n**Note:** For any question [issues](https://github.com/watscho/express-graphql-mongodb-boilerplate/issues)\n\n## License\n\nThis project is an open-source with an [MIT License](https://github.com/watscho/express-graphql-mongodb-boilerplate/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatscho%2Fexpress-graphql-mongodb-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatscho%2Fexpress-graphql-mongodb-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatscho%2Fexpress-graphql-mongodb-boilerplate/lists"}