├── .all-contributorsrc ├── .eslintignore ├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── semantic.yml └── workflows │ ├── master.yml │ └── pull-requests.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── API.md ├── API_V1.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── index.d.ts ├── index.js ├── index.ts ├── jest.config.js ├── lib ├── common │ ├── in-memory-db.constants.ts │ ├── in-memory-db.decorators.spec.ts │ ├── in-memory-db.decorators.ts │ ├── in-memory-db.utils.spec.ts │ ├── in-memory-db.utils.ts │ └── index.ts ├── controllers │ ├── in-memory-db-async.controller.spec.ts │ ├── in-memory-db-async.controller.ts │ ├── in-memory-db.controller.spec.ts │ ├── in-memory-db.controller.ts │ └── index.ts ├── factories │ ├── in-memory-db-service.factory.ts │ └── index.ts ├── in-memory-db.module.spec.ts ├── in-memory-db.module.ts ├── index.ts ├── interfaces │ ├── in-memory-db-config.ts │ ├── in-memory-db-entity.ts │ └── index.ts ├── providers │ ├── in-memory-db-for-feature.providers.spec.ts │ ├── in-memory-db-for-feature.providers.ts │ ├── in-memory-db-for-root.providers.spec.ts │ ├── in-memory-db-for-root.providers.ts │ └── index.ts ├── services │ ├── in-memory-db.service.spec.ts │ ├── in-memory-db.service.ts │ └── index.ts └── v1 │ ├── common │ ├── in-memory-db.constants.ts │ ├── in-memory-db.decorators.spec.ts │ ├── in-memory-db.decorators.ts │ ├── in-memory-db.utils.spec.ts │ ├── in-memory-db.utils.ts │ └── index.ts │ ├── controllers │ ├── in-memory-db-async.controller.spec.ts │ ├── in-memory-db-async.controller.ts │ ├── in-memory-db.controller.spec.ts │ ├── in-memory-db.controller.ts │ └── index.ts │ ├── factories │ ├── in-memory-db-service.factory.ts │ └── index.ts │ ├── in-memory-db.module.spec.ts │ ├── in-memory-db.module.ts │ ├── index.ts │ ├── interfaces │ ├── in-memory-db-config.ts │ ├── in-memory-db-entity.ts │ └── index.ts │ ├── providers │ ├── in-memory-db-for-feature.providers.spec.ts │ ├── in-memory-db-for-feature.providers.ts │ ├── in-memory-db-for-root.providers.spec.ts │ ├── in-memory-db-for-root.providers.ts │ └── index.ts │ └── services │ ├── in-memory-db.service.spec.ts │ ├── in-memory-db.service.ts │ └── index.ts ├── package-lock.json ├── package.json ├── renovate.json ├── schematics ├── collection.json ├── mocks.ts ├── nest-add │ ├── __snapshots__ │ │ └── index.spec.ts.snap │ ├── index.spec.ts │ ├── index.ts │ ├── schema.json │ └── schema.ts └── utils │ ├── ast-utils.ts │ ├── change.ts │ └── module.finder.ts ├── tests ├── current │ ├── e2e │ │ ├── app-customer-product.e2e-spec.ts │ │ ├── app-customer.e2e-spec.ts │ │ ├── app-product.e2e-spec.ts │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ └── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── customer-product │ │ └── customer-product.module.ts │ │ ├── customer │ │ ├── customer.controller.spec.ts │ │ ├── customer.controller.ts │ │ ├── customer.module.ts │ │ └── customer.ts │ │ ├── index.ts │ │ ├── main.ts │ │ ├── product │ │ ├── product.controller.spec.ts │ │ ├── product.controller.ts │ │ ├── product.module.ts │ │ └── product.ts │ │ └── user.ts ├── jest-e2e.json └── v1 │ ├── e2e │ ├── app-customer-product.e2e-spec.ts │ ├── app-customer.e2e-spec.ts │ ├── app-product.e2e-spec.ts │ ├── app.e2e-spec.ts │ └── jest-e2e.json │ └── src │ ├── app.controller.spec.ts │ ├── app.controller.ts │ ├── app.module.ts │ ├── customer-product │ └── customer-product.module.ts │ ├── customer │ ├── customer.controller.spec.ts │ ├── customer.controller.ts │ ├── customer.module.ts │ └── customer.ts │ ├── index.ts │ ├── main.ts │ ├── product │ ├── product.controller.spec.ts │ ├── product.controller.ts │ ├── product.module.ts │ └── product.ts │ └── user.ts ├── tsconfig.json └── tsconfig.schematics.json /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "wesleygrimes", 10 | "name": "Wes Grimes", 11 | "avatar_url": "https://avatars0.githubusercontent.com/u/324308?v=4", 12 | "profile": "https://wesleygrimes.com", 13 | "contributions": [ 14 | "infra", 15 | "test", 16 | "code" 17 | ] 18 | }, 19 | { 20 | "login": "cmwhited", 21 | "name": "Chris Whited", 22 | "avatar_url": "https://avatars0.githubusercontent.com/u/18075124?v=4", 23 | "profile": "https://github.com/cmwhited", 24 | "contributions": [ 25 | "infra", 26 | "test", 27 | "code" 28 | ] 29 | }, 30 | { 31 | "login": "wescopeland", 32 | "name": "Wes Copeland", 33 | "avatar_url": "https://avatars0.githubusercontent.com/u/3984985?v=4", 34 | "profile": "https://github.com/wescopeland", 35 | "contributions": [ 36 | "code", 37 | "test" 38 | ] 39 | }, 40 | { 41 | "login": "jordanpowell88", 42 | "name": "Jordan", 43 | "avatar_url": "https://avatars0.githubusercontent.com/u/3605268?v=4", 44 | "profile": "http://hirejordanpowell.com", 45 | "contributions": [ 46 | "code", 47 | "test" 48 | ] 49 | }, 50 | { 51 | "login": "santoshyadav198613", 52 | "name": "Santosh Yadav", 53 | "avatar_url": "https://avatars3.githubusercontent.com/u/11923975?v=4", 54 | "profile": "https://www.santoshyadav.dev", 55 | "contributions": [ 56 | "code", 57 | "test" 58 | ] 59 | }, 60 | { 61 | "login": "itayod", 62 | "name": "Itay Oded", 63 | "avatar_url": "https://avatars2.githubusercontent.com/u/6719615?v=4", 64 | "profile": "https://github.com/itayod", 65 | "contributions": [ 66 | "code", 67 | "test" 68 | ] 69 | } 70 | ], 71 | "contributorsPerLine": 7, 72 | "projectName": "in-memory-db", 73 | "projectOwner": "nestjs-addons", 74 | "repoType": "github", 75 | "repoHost": "https://github.com" 76 | } 77 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | tests/** 2 | **/*.spec.ts -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | parser: '@typescript-eslint/parser', 4 | parserOptions: { 5 | project: 'tsconfig.json', 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/eslint-recommended', 11 | 'plugin:@typescript-eslint/recommended', 12 | 'prettier', 13 | 'prettier/@typescript-eslint', 14 | ], 15 | root: true, 16 | env: { 17 | node: true, 18 | jest: true, 19 | }, 20 | rules: { 21 | '@typescript-eslint/interface-name-prefix': 'off', 22 | '@typescript-eslint/explicit-function-return-type': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | '@typescript-eslint/no-use-before-define': 'off', 25 | '@typescript-eslint/no-non-null-assertion': 'off', 26 | }, 27 | }; -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | titleOnly: true 2 | -------------------------------------------------------------------------------- /.github/workflows/master.yml: -------------------------------------------------------------------------------- 1 | name: Master 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v1 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: 12 16 | - run: npm ci 17 | - run: npm run test 18 | 19 | e2e: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v1 23 | - uses: actions/setup-node@v1 24 | with: 25 | node-version: 12 26 | - run: npm ci 27 | - run: npm run e2e 28 | 29 | publish: 30 | needs: [test, e2e] 31 | runs-on: ubuntu-latest 32 | steps: 33 | - uses: actions/checkout@v1 34 | - uses: actions/setup-node@v1 35 | with: 36 | node-version: 12 37 | - run: npm ci 38 | - run: npm run build 39 | - run: npx semantic-release 40 | env: 41 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 42 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 43 | -------------------------------------------------------------------------------- /.github/workflows/pull-requests.yml: -------------------------------------------------------------------------------- 1 | name: Pull Requests 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | lint: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v1 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: 12 16 | - run: npm ci 17 | - run: npm run lint 18 | 19 | test: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v1 23 | - uses: actions/setup-node@v1 24 | with: 25 | node-version: 12 26 | - run: npm ci 27 | - run: npm run test 28 | 29 | e2e: 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v1 33 | - uses: actions/setup-node@v1 34 | with: 35 | node-version: 12 36 | - run: npm ci 37 | - run: npm run e2e 38 | 39 | verify-format: 40 | runs-on: ubuntu-latest 41 | steps: 42 | - uses: actions/checkout@v1 43 | - uses: actions/setup-node@v1 44 | with: 45 | node-version: 12 46 | - run: npm ci 47 | - run: npm run format:verify 48 | 49 | build: 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v1 53 | - uses: actions/setup-node@v1 54 | with: 55 | node-version: 12 56 | - run: npm ci 57 | - run: npm run build 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | .DS_Store 12 | 13 | # tests 14 | /test 15 | /coverage 16 | /.nyc_output 17 | 18 | # dist 19 | /dist 20 | 21 | # schematics 22 | /schematics/**/*.js 23 | /schematics/**/*.d.ts 24 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # source 2 | lib 3 | index.ts 4 | package-lock.json 5 | tslint.json 6 | tsconfig.json 7 | .prettierrc -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "arrowParens": "always", 4 | "singleQuote": true 5 | } -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # API Documentation 2 | 3 | ## `InMemoryDBService` 4 | 5 | This is the service that provides the in-memory database. All methods interact with a `records` array and implement `generics` to provide type-safety and intellisense based on the `T extends InMemoryEntity` passed in. 6 | 7 | ### Public Methods 8 | 9 | **`public create(record: Partial, getNextId?: () => string): T`** 10 | 11 | This method takes in a `Partial` as we do not always know the `id` for a record when we are creating. If we leave off the `id` property the service will automatically generate an `id` for us. Upon successful creation, the method returns the record with the newly generated `id`. An optional parameter of `getNextId` can be used to pass a function that returns a `string` and will be used by the service to get the next id. By default this uses the `uuid` npm package. 12 | 13 | Example Usage: 14 | 15 | ```typescript 16 | const newUser = this.userService.create({ 17 | firstName: 'Some', 18 | lastName: 'Person', 19 | }); 20 | 21 | console.log({ newUser }); 22 | 23 | // logs out 24 | // { 25 | // newUser: { 26 | // id: 1, 27 | // firstName: 'Some', 28 | // lastName: 'Person, 29 | // } 30 | // } 31 | ``` 32 | 33 | **`public createMany(records: Array>, getNextId?: () => string): T[]`** 34 | 35 | This method takes in an array of `Partial` as we do not always know the `id` for records when we are creating. If we leave off the `id` properties the service will automatically generate `id`s for us. Upon successful creation, the method returns the an array of records with the newly generated `id`s. An optional parameter of `getNextId` can be used to pass a function that returns a `string` and will be used by the service to get the next id. By default this uses the `uuid` npm package. 36 | 37 | Example Usage: 38 | 39 | ```typescript 40 | const recordsToCreate = [ 41 | { 42 | firstName: 'Some', 43 | lastName: 'Person', 44 | }, 45 | { 46 | firstName: 'Other', 47 | lastName: 'Person', 48 | }, 49 | ]; 50 | 51 | const newUsers = this.userService.createMany(recordsToCreate); 52 | 53 | console.log({ newUsers }); 54 | 55 | // logs out 56 | // { 57 | // newUsers: [{ 58 | // id: 1, 59 | // firstName: 'Some', 60 | // lastName: 'Person, 61 | // }, 62 | // { 63 | // id: 2, 64 | // firstName: 'Other', 65 | // lastName: 'Person, 66 | // }] 67 | // } 68 | ``` 69 | 70 | **`public update(record: T): void`** 71 | 72 | This method takes in a `T` record object and updates the record in the `records` array based on the `id` in the object. This method does not return a value. 73 | 74 | Example Usage: 75 | 76 | ```typescript 77 | this.userService.update({ 78 | id: 1, 79 | firstName: 'Other', 80 | lastName: 'Person', 81 | }); 82 | ``` 83 | 84 | **`public delete(id: string): void`** 85 | 86 | This method takes in a `id: string` and deletes the record from the `records` array based on the `id` in the object. This method does not return a value. 87 | 88 | Example Usage: 89 | 90 | ```typescript 91 | this.userService.delete('1'); 92 | ``` 93 | 94 | **`public get(id: string): T`** 95 | 96 | This method takes in a `id: string` and returns the record from the `records` array based on the `id` in the object. 97 | 98 | Example Usage: 99 | 100 | ```typescript 101 | const foundUser = this.userService.get('1'); 102 | 103 | console.log({ foundUser }); 104 | 105 | // logs out 106 | // { 107 | // foundUser: { 108 | // id: '1', 109 | // firstName: 'Some', 110 | // lastName: 'Person' 111 | // } 112 | // } 113 | ``` 114 | 115 | **`public getAll(): T[]`** 116 | 117 | This method has no parameters and returns the all from the `records` array. 118 | 119 | Example Usage: 120 | 121 | ```typescript 122 | const allUsers = this.userService.getAll(); 123 | 124 | console.log({ allUsers }); 125 | 126 | // logs out 127 | // { 128 | // allUsers: [ 129 | // { 130 | // id: '1', 131 | // firstName: 'Some', 132 | // lastName: 'Person' 133 | // }, 134 | // { 135 | // id: '2', 136 | // firstName: 'Other', 137 | // lastName: 'Person' 138 | // } 139 | // ]; 140 | // } 141 | ``` 142 | 143 | **`public query(predicate: (record: T) => boolean): T[]`** 144 | 145 | This method has takes in a `record: T` predicate and returns all from the `records` array that meet that predicate's requirements. 146 | 147 | Example Usage: 148 | 149 | ```typescript 150 | const foundUsers = this.userService.query( 151 | (record) => record.lastName === 'Person', 152 | ); 153 | 154 | console.log({ foundUsers }); 155 | 156 | // logs out 157 | // { 158 | // allUsers: [ 159 | // { 160 | // id: '1', 161 | // firstName: 'Some', 162 | // lastName: 'Person' 163 | // }, 164 | // { 165 | // id: '2', 166 | // firstName: 'Other', 167 | // lastName: 'Person' 168 | // } 169 | // ]; 170 | // } 171 | ``` 172 | 173 | ### Public Properties 174 | 175 | - `records: T[]` - This is the in-memory array used in all crud and read operations for the service. Please access with care. 176 | 177 | ## `InMemoryDBEntity` 178 | 179 | This is an interface used by the `InMemoryDBService` for intellisense and type-safety. Do not use this interface directly. Rather, implement your own `interface` that `extends` this. 180 | 181 | ```typescript 182 | export interface InMemoryDBEntity { 183 | id: string; 184 | } 185 | ``` 186 | -------------------------------------------------------------------------------- /API_V1.md: -------------------------------------------------------------------------------- 1 | # API Documentation - V1 2 | 3 | ## `InMemoryDBV1Service` 4 | 5 | This is the service that provides the in-memory database. All methods interact with a `records` array and implement `generics` to provide type-safety and intellisense based on the `T extends InMemoryDBV1Entity` passed in. 6 | 7 | ### Public Methods 8 | 9 | **`public create(record: Partial): T`** 10 | 11 | This method takes in a `Partial` as we do not always know the `id` for a record when we are creating. If we leave off the `id` property the service will automatically generate an `id` for us. Upon successful creation, the method returns the record with the newly generated `id`. 12 | 13 | Example Usage: 14 | 15 | ```typescript 16 | const newUser = this.userService.create({ 17 | firstName: 'Some', 18 | lastName: 'Person', 19 | }); 20 | 21 | console.log({ newUser }); 22 | 23 | // logs out 24 | // { 25 | // newUser: { 26 | // id: 1, 27 | // firstName: 'Some', 28 | // lastName: 'Person, 29 | // } 30 | // } 31 | ``` 32 | 33 | **`public createMany(records: Array>): T[]`** 34 | 35 | This method takes in an array of `Partial` as we do not always know the `id` for records when we are creating. If we leave off the `id` properties the service will automatically generate `id`s for us. Upon successful creation, the method returns the an array of records with the newly generated `id`s. 36 | 37 | Example Usage: 38 | 39 | ```typescript 40 | const recordsToCreate = [ 41 | { 42 | firstName: 'Some', 43 | lastName: 'Person', 44 | }, 45 | { 46 | firstName: 'Other', 47 | lastName: 'Person', 48 | }, 49 | ]; 50 | 51 | const newUsers = this.userService.createMany(recordsToCreate); 52 | 53 | console.log({ newUsers }); 54 | 55 | // logs out 56 | // { 57 | // newUsers: [{ 58 | // id: 1, 59 | // firstName: 'Some', 60 | // lastName: 'Person, 61 | // }, 62 | // { 63 | // id: 2, 64 | // firstName: 'Other', 65 | // lastName: 'Person, 66 | // }] 67 | // } 68 | ``` 69 | 70 | **`public update(record: T): void`** 71 | 72 | This method takes in a `T` record object and updates the record in the `records` array based on the `id` in the object. This method does not return a value. 73 | 74 | Example Usage: 75 | 76 | ```typescript 77 | this.userService.update({ 78 | id: 1, 79 | firstName: 'Other', 80 | lastName: 'Person', 81 | }); 82 | ``` 83 | 84 | **`public delete(id: number): void`** 85 | 86 | This method takes in a `id: number` and deletes the record from the `records` array based on the `id` in the object. This method does not return a value. 87 | 88 | Example Usage: 89 | 90 | ```typescript 91 | this.userService.delete(1); 92 | ``` 93 | 94 | **`public get(id: number): T`** 95 | 96 | This method takes in a `id: number` and returns the record from the `records` array based on the `id` in the object. 97 | 98 | Example Usage: 99 | 100 | ```typescript 101 | const foundUser = this.userService.get(1); 102 | 103 | console.log({ foundUser }); 104 | 105 | // logs out 106 | // { 107 | // foundUser: { 108 | // id:1, 109 | // firstName: 'Some', 110 | // lastName: 'Person' 111 | // } 112 | // } 113 | ``` 114 | 115 | **`public getAll(): T[]`** 116 | 117 | This method has no parameters and returns the all from the `records` array. 118 | 119 | Example Usage: 120 | 121 | ```typescript 122 | const allUsers = this.userService.getAll(); 123 | 124 | console.log({ allUsers }); 125 | 126 | // logs out 127 | // { 128 | // allUsers: [ 129 | // { 130 | // id: 1, 131 | // firstName: 'Some', 132 | // lastName: 'Person' 133 | // }, 134 | // { 135 | // id: 2, 136 | // firstName: 'Other', 137 | // lastName: 'Person' 138 | // } 139 | // ]; 140 | // } 141 | ``` 142 | 143 | **`public query(predicate: (record: T) => boolean): T[]`** 144 | 145 | This method has takes in a `record: T` predicate and returns all from the `records` array that meet that predicate's requirements. 146 | 147 | Example Usage: 148 | 149 | ```typescript 150 | const foundUsers = this.userService.query( 151 | (record) => record.lastName === 'Person', 152 | ); 153 | 154 | console.log({ foundUsers }); 155 | 156 | // logs out 157 | // { 158 | // allUsers: [ 159 | // { 160 | // id: 1, 161 | // firstName: 'Some', 162 | // lastName: 'Person' 163 | // }, 164 | // { 165 | // id: 2, 166 | // firstName: 'Other', 167 | // lastName: 'Person' 168 | // } 169 | // ]; 170 | // } 171 | ``` 172 | 173 | ### Public Properties 174 | 175 | - `records: T[]` - This is the in-memory array used in all crud and read operations for the service. Please access with care. 176 | 177 | ## `InMemoryDBV1Entity` 178 | 179 | This is an interface used by the `InMemoryDBV1Service` for intellisense and type-safety. Do not use this interface directly. Rather, implement your own `interface` that `extends` this. 180 | 181 | ```typescript 182 | export interface InMemoryDBV1Entity { 183 | id: number; 184 | } 185 | ``` 186 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at wesgrimes@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Nest 2 | 3 | We would love for you to contribute to Nest and help make it even better than it is 4 | today! As a contributor, here are the guidelines we would like you to follow: 5 | 6 | - [Code of Conduct](#coc) 7 | - [Question or Problem?](#question) 8 | - [Issues and Bugs](#issue) 9 | - [Feature Requests](#feature) 10 | - [Submission Guidelines](#submit) 11 | - [Coding Rules](#rules) 12 | - [Commit Message Guidelines](#commit) 13 | 14 | 15 | 17 | 18 | ## Got a Question or Problem? 19 | 20 | **Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests.** You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/-addons) where the questions should be tagged with tag `nestjs-addons`. 21 | 22 | Stack Overflow is a much better place to ask questions since: 23 | 24 | 25 | 26 | - questions and answers stay available for public viewing so your question / answer might help someone else 27 | - Stack Overflow's voting system assures that the best answers are prominently visible. 28 | 29 | To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow. 30 | 31 | If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter]. 32 | 33 | ## Found a Bug? 34 | 35 | If you find a bug in the source code, you can help us by 36 | [submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can 37 | [submit a Pull Request](#submit-pr) with a fix. 38 | 39 | ## Missing a Feature? 40 | 41 | You can _request_ a new feature by [submitting an issue](#submit-issue) to our GitHub 42 | Repository. If you would like to _implement_ a new feature, please submit an issue with 43 | a proposal for your work first, to be sure that we can use it. 44 | Please consider what kind of change it is: 45 | 46 | - For a **Major Feature**, first open an issue and outline your proposal so that it can be 47 | discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, 48 | and help you to craft the change so that it is successfully accepted into the project. For your issue name, please prefix your proposal with `[discussion]`, for example "[discussion]: your feature idea". 49 | - **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). 50 | 51 | ## Submission Guidelines 52 | 53 | ### Submitting an Issue 54 | 55 | Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. 56 | 57 | We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a minimal reproduction scenario using a repository or [Gist](https://gist.github.com/). Having a live, reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like: 58 | 59 | - version of NestJS Addons - InMemory DB used 60 | - 3rd-party libraries and their versions 61 | - and most importantly - a use-case that fails 62 | 63 | 67 | 68 | 69 | 70 | Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced. 71 | 72 | You can file new issues by filling out our [new issue form](https://github.com/nestjs-addons/in-memory-db/issues/new). 73 | 74 | ### Submitting a Pull Request (PR) 75 | 76 | Before you submit your Pull Request (PR) consider the following guidelines: 77 | 78 | 1. Search [GitHub](https://github.com/nestjs-addons/in-memory-db/pulls) for an open or closed PR 79 | that relates to your submission. You don't want to duplicate effort. 80 | 82 | 1. Fork the nestjs-addons/in-memory-db repo. 83 | 1. Make your changes in a new git branch: 84 | 85 | ```shell 86 | git checkout -b my-fix-branch master 87 | ``` 88 | 89 | 1. Create your patch, **including appropriate test cases**. 90 | 1. Follow our [Coding Rules](#rules). 91 | 1. Run the full Nest test suite, as described in the [developer documentation][dev-doc], 92 | and ensure that all tests pass. 93 | 1. Commit your changes using a descriptive commit message that follows our 94 | [commit message conventions](#commit). Adherence to these conventions 95 | is necessary because release notes are automatically generated from these messages. 96 | 97 | ```shell 98 | git commit -a 99 | ``` 100 | 101 | Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. 102 | 103 | 1. Push your branch to GitHub: 104 | 105 | ```shell 106 | git push origin my-fix-branch 107 | ``` 108 | 109 | 1. In GitHub, send a pull request to `nestjs-addons/in-memory-db:master`. 110 | 111 | - If we suggest changes then: 112 | 113 | - Make the required updates. 114 | - Re-run the Nest test suites to ensure tests are still passing. 115 | - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): 116 | 117 | ```shell 118 | git rebase master -i 119 | git push -f 120 | ``` 121 | 122 | That's it! Thank you for your contribution! 123 | 124 | #### After your pull request is merged 125 | 126 | After your pull request is merged, you can safely delete your branch and pull the changes 127 | from the main (upstream) repository: 128 | 129 | - Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: 130 | 131 | ```shell 132 | git push origin --delete my-fix-branch 133 | ``` 134 | 135 | - Check out the master branch: 136 | 137 | ```shell 138 | git checkout master -f 139 | ``` 140 | 141 | - Delete the local branch: 142 | 143 | ```shell 144 | git branch -D my-fix-branch 145 | ``` 146 | 147 | - Update your master with the latest upstream version: 148 | 149 | ```shell 150 | git pull --ff upstream master 151 | ``` 152 | 153 | ## Coding Rules 154 | 155 | To ensure consistency throughout the source code, keep these rules in mind as you are working: 156 | 157 | - All features or bug fixes **must be tested** by one or more specs (unit-tests). 158 | 161 | - We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at 162 | **100 characters**. 163 | 164 | ## Commit Message Guidelines 165 | 166 | We have very precise rules over how our git commit messages can be formatted. This leads to **more 167 | readable messages** that are easy to follow when looking through the **project history**. But also, 168 | we use the git commit messages to **generate the NestJS Addons - In Memory DB change log**. 169 | 170 | This project uses Commitizen to help with formatting commit messages. 171 | 172 | Simply run `git commit` in your terminal and the tooling will ask a series of questions to format 173 | the commit message correctly. 174 | 175 | ### Commit Message Format 176 | 177 | Each commit message consists of a **header**, a **body** and a **footer**. The header has a special 178 | format that includes a **type**, a **scope** and a **subject**: 179 | 180 | ``` 181 | (): 182 | 183 | 184 | 185 |