├── .circleci └── config.yml ├── .commitlintrc.json ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github └── CODEOWNERS ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .lintstagedrc ├── .npmignore ├── .npmrc ├── .prepare ├── .prepare.bat ├── .prettierrc ├── .release-it.json ├── .vscode ├── extensions.json └── settings.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENCE ├── README.md ├── index.d.ts ├── index.js ├── index.ts ├── jest.config.json ├── lib ├── decorators │ ├── authenticate.decorator.ts │ ├── authorize.decorator.ts │ ├── index.ts │ ├── model.decorator.ts │ └── token.decorator.ts ├── guards │ ├── authentication.guard.ts │ ├── authorization.guard.ts │ ├── base.guard.ts │ ├── index.ts │ └── token.guard.ts ├── index.ts ├── interfaces │ ├── index.ts │ └── oauth2-server.interfaces.ts ├── model-provider.module.ts ├── oauth2-server-core.module.ts ├── oauth2-server.constants.ts └── oauth2-server.module.ts ├── oauth2.png ├── package.json ├── renovate.json ├── tests ├── e2e │ ├── module.e2e-spec.ts │ └── oauth2-server.e2e-spec.ts ├── jest-e2e.config.json └── src │ ├── data-provider.module.ts │ ├── data.ts │ ├── existing.module.ts │ ├── test-config.service.ts │ ├── test-model.service.ts │ ├── test.constants.ts │ ├── test.controller.ts │ ├── test.interfaces.ts │ └── test.module.ts ├── tsconfig.build.json └── tsconfig.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | coveralls: coveralls/coveralls@1.0.6 5 | 6 | aliases: 7 | - &restore-cache 8 | restore_cache: 9 | key: dependency-cache-{{ checksum "package.json" }} 10 | - &install-deps 11 | run: 12 | name: Install dependencies 13 | command: npm install --force --unsafe-perm 14 | - &update-npm 15 | run: 16 | name: Update NPM version 17 | command: 'sudo npm install -g npm@latest' 18 | - &run-lint 19 | run: 20 | name: Linting 21 | command: npm run lint 22 | - &run-integration 23 | run: 24 | name: Integration tests 25 | command: npm run test:integration 26 | - &save-cache 27 | save_cache: 28 | key: dependency-cache-{{ checksum "package.json" }} 29 | paths: 30 | - ./node_modules 31 | - &remove-latest-nestjs 32 | run: 33 | name: Remove latest nestjs 34 | command: npm remove @nestjs/common @nestjs/core @nestjs/platform-express @nestjs/testing rxjs 35 | 36 | jobs: 37 | integration_tests_node_12: 38 | resource_class: small 39 | working_directory: ~/nest 40 | docker: 41 | - image: cimg/node:12.22.0 42 | steps: 43 | - checkout 44 | - *update-npm 45 | - *restore-cache 46 | - *install-deps 47 | - *save-cache 48 | - *run-lint 49 | - *run-integration 50 | 51 | integration_tests_node_14: 52 | resource_class: small 53 | working_directory: ~/nest 54 | docker: 55 | - image: cimg/node:14.19 56 | steps: 57 | - checkout 58 | - *update-npm 59 | - *restore-cache 60 | - *install-deps 61 | - *save-cache 62 | - *run-lint 63 | - *run-integration 64 | 65 | integration_tests_node_16: 66 | resource_class: small 67 | working_directory: ~/nest 68 | docker: 69 | - image: cimg/node:16.14 70 | steps: 71 | - checkout 72 | - *update-npm 73 | - *restore-cache 74 | - *install-deps 75 | - *save-cache 76 | - *run-lint 77 | - *run-integration 78 | 79 | coverage: 80 | working_directory: ~/nest 81 | docker: 82 | - image: cimg/node:16.14 83 | steps: 84 | - checkout 85 | - *update-npm 86 | - *restore-cache 87 | - *install-deps 88 | - *save-cache 89 | - run: 90 | name: Test coverage 91 | command: npm run test:cov 92 | - coveralls/upload: 93 | path_to_lcov: ./coverage/e2e/lcov.info 94 | 95 | workflows: 96 | version: 2 97 | test: 98 | jobs: 99 | - integration_tests_node_12 100 | - integration_tests_node_14 101 | - integration_tests_node_16 102 | coverage: 103 | jobs: 104 | - coverage 105 | -------------------------------------------------------------------------------- /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@commitlint/config-conventional"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 4 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | 9 | [*.{yml,json}] 10 | indent_size=2 11 | 12 | [*.json] 13 | insert_final_newline = ignore 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | tests/** 2 | node_modules 3 | coverage 4 | husky 5 | dist 6 | index.ts 7 | index.js 8 | index.d.ts 9 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "parserOptions": { 4 | "project": "tsconfig.json", 5 | "sourceType": "module" 6 | }, 7 | "plugins": ["@typescript-eslint/eslint-plugin"], 8 | "extends": [ 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended", 11 | "prettier" 12 | ], 13 | "root": true, 14 | "env": { 15 | "node": true, 16 | "jest": true 17 | }, 18 | "rules": { 19 | "@typescript-eslint/interface-name-prefix": "off", 20 | "@typescript-eslint/explicit-function-return-type": "off", 21 | "@typescript-eslint/no-explicit-any": "off", 22 | "@typescript-eslint/no-use-before-define": "off", 23 | "@typescript-eslint/no-non-null-assertion": "off" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @toondaey 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode/* 8 | !.vscode/settings.json 9 | !.vscode/extensions.json 10 | !.vscode/launch.json 11 | .dev-dependencies 12 | 13 | # misc 14 | npm-debug.log 15 | /**/*.DS_Store 16 | .dccache 17 | 18 | # tests 19 | /test 20 | /coverage 21 | /.nyc_output 22 | 23 | # dist 24 | dist 25 | .env 26 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx --no-install commitlint --edit 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "lib/**/*.ts": [ 3 | "prettier --write", 4 | "eslint --fix . --ext .js,.jsx,.ts,.tsx" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # source 2 | lib 3 | test 4 | index.ts 5 | package-lock.json 6 | tslint.json 7 | tsconfig.json 8 | tsconfig.build.json 9 | .prettierrc 10 | .prettierignore 11 | .dev-dependencies 12 | .dependencies 13 | .eslintignore 14 | .dccache 15 | .env 16 | .vscode 17 | .editorconfig 18 | .release-it.json 19 | .eslintrc 20 | .commitlintrc 21 | pdf-icon.svg 22 | jest.config.json 23 | 24 | # github 25 | .github 26 | CONTRIBUTING.md 27 | README.md 28 | renovate.json 29 | .husky 30 | .lintstagedrc 31 | LICENCE 32 | 33 | # ci 34 | .circleci 35 | coverage 36 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact=true 2 | always-auth=true 3 | package-lock=false 4 | -------------------------------------------------------------------------------- /.prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ## This checks if husky is installed in the npm modules 4 | ## before setting it up. This is so no installation 5 | ## fails in production. 6 | npm ls husky --depth 0 >> /dev/null 7 | 8 | if [ $? = 0 ]; then 9 | husky install; 10 | fi; 11 | -------------------------------------------------------------------------------- /.prepare.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | @REM This checks if husky is installed in the npm modules 4 | @REM before setting it up. This is so no installation 5 | @REM fails in production. 6 | 7 | CALL npm ls husky --depth 0 > NUL 8 | IF %ERRORLEVEL% EQU 0 ( 9 | husky install 10 | ) 11 | @ECHO ON 12 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "singleQuote": true, 4 | "arrowParens": "avoid", 5 | "printWidth": 70 6 | } 7 | -------------------------------------------------------------------------------- /.release-it.json: -------------------------------------------------------------------------------- 1 | { 2 | "git": { 3 | "commitMessage": "chore(): release v${version}" 4 | }, 5 | "github": { 6 | "release": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "esbenp.prettier-vscode", 5 | "ms-vscode.vscode-typescript-next", 6 | "eg2.vscode-npm-script", 7 | "snyk-security.snyk-vulnerability-scanner", 8 | "christian-kohler.npm-intellisense" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "npm-intellisense.importES6": true, 4 | "npm-intellisense.importQuotes": "'", 5 | "npm-intellisense.importLinebreak": ";\r\n", 6 | "npm-intellisense.importDeclarationType": "const" 7 | } 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [[0.0.4]](https://github.com/toondaey/nestjs-oauth2-server/compare/0.0.3...0.0.4) - 25/11/2020 4 | 5 | ### Changed 6 | 7 | - update dev dependencies: 8 | - typescript to v4 9 | - typescript-eslint monorepo to v4 10 | - release-it to v14 11 | - ts-jest to v26 12 | - jest to v26 13 | - eslint to v7 14 | - renovate to v23.86.1 15 | - @types/jest to v26 16 | - nest monorepo to v7.5.5 17 | - commitlint monorepo to v11 18 | - rxjs to v6.6.3 19 | - eslint-config-prettier to v6.15.0 20 | - prettier to v2.2.0 21 | - lint-staged to v10.5.2 22 | - eslint-plugin-import to v2.22.1 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Before you submit your Pull Request (PR) consider the following guidelines: 2 | 3 | 1. Search [GitHub](https://github.com/toondaey/nestjs-module-boilerplate/pulls) for an open or closed PR 4 | that relates to your submission. You don't want to duplicate effort. 5 | 1. Fork the toondaey/nestjs-module-boilerplate. 6 | 1. Make your changes in a new git branch: 7 | 8 | ```shell 9 | git checkout -b my-fix-branch master 10 | ``` 11 | 12 | 1. Create your patch, **including appropriate test cases**. 13 | 1. Follow our [Coding Rules](#rules). 14 | 1. Run the tests scripts specified in `package.json` and ensure that all tests pass. 15 | 1. Commit your changes using a descriptive commit message that follows our 16 | [commit message conventions](#commit). Adherence to these conventions 17 | is necessary because release notes are automatically generated from these messages. 18 | 19 | ```shell 20 | git commit -a 21 | ``` 22 | 23 | Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. 24 | 25 | 1. Push your branch to GitHub: 26 | 27 | ```shell 28 | git push origin my-fix-branch 29 | ``` 30 | 31 | 1. In GitHub, send a pull request to `toondaey/nestjs-module-boilerplate:master`. 32 | 33 | - If we suggest changes then: 34 | 35 | - Make the required updates. 36 | - Re-run the Nest test suites to ensure tests are still passing. 37 | - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): 38 | 39 | ```shell 40 | git rebase master -i 41 | git push -f 42 | ``` 43 | 44 | That's it! Thank you for your contribution! 45 | 46 | ## Coding Rules 47 | 48 | To ensure consistency throughout the source code, keep these rules in mind as you are working: 49 | 50 | 53 | 54 | - All features or bug fixes **must be tested** by one or more specs (unit-tests). 55 | - We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at 56 | **100 characters**. An automated formatter is available (`npm run format`). 57 | 58 | ## Commit Message Guidelines 59 | 60 | We have very precise rules over how our git commit messages can be formatted. This leads to **more 61 | readable messages** that are easy to follow when looking through the **project history**. But also, 62 | we use the git commit messages to **generate the Nest change log**. 63 | 64 | ### Commit Message Format 65 | 66 | Each commit message consists of a **header**, a **body** and a **footer**. The header has a special 67 | format that includes a **type**, a **scope** and a **subject**: 68 | 69 | ``` 70 | (): 71 | 72 | 73 | 74 |