├── .eslintrc.js ├── .github └── workflows │ └── release-package.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── LICENSE ├── README.md ├── index.d.ts ├── package-lock.json ├── package.json ├── scripts └── increase-version.js ├── src ├── index.ts ├── snowflake-id.module.ts └── snowflake-id.service.ts ├── test └── jest-e2e.json ├── tsconfig.build.json └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir: __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ["eslint.config.js"], 19 | rules: { 20 | 21 | }, 22 | } 23 | 24 | module.exports = { 25 | parser: '@typescript-eslint/parser', 26 | parserOptions: { 27 | project: 'tsconfig.json', 28 | tsconfigRootDir : __dirname, 29 | sourceType: 'module', 30 | }, 31 | plugins: ['@typescript-eslint/eslint-plugin'], 32 | extends: [ 33 | 'plugin:@typescript-eslint/recommended', 34 | 'plugin:prettier/recommended', 35 | 'plugin:import/recommended', 36 | 'plugin:import/typescript', 37 | ], 38 | root: true, 39 | env: { 40 | node: true, 41 | jest: true, 42 | }, 43 | ignorePatterns: ['.eslintrc.js'], 44 | rules: { 45 | "@typescript-eslint/consistent-type-imports": "warn", 46 | '@typescript-eslint/interface-name-prefix': 'off', 47 | '@typescript-eslint/no-non-null-assertion': 'off', 48 | '@typescript-eslint/no-explicit-any': 'off', 49 | "@typescript-eslint/no-empty-object-type": "off", 50 | 'import/consistent-type-specifier-style': ['error', 'prefer-inline'], 51 | 'import/no-duplicates': ["error", {"prefer-inline": true}], 52 | 'import/no-named-as-default': 'off', 53 | '@typescript-eslint/explicit-function-return-type': 'off', 54 | '@typescript-eslint/explicit-module-boundary-types': 'off', 55 | '@typescript-eslint/explicit-member-accessibility': 'error', 56 | 'prettier/prettier': [ 57 | 'error', 58 | {}, 59 | { 60 | usePrettierrc: true, 61 | }, 62 | ], 63 | }, 64 | settings: { 65 | 'import/resolver': { 66 | typescript: true, 67 | node: true 68 | } 69 | } 70 | }; -------------------------------------------------------------------------------- /.github/workflows/release-package.yml: -------------------------------------------------------------------------------- 1 | name: Nest Snowflake Id 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | publish-npm: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | packages: write 12 | contents: read 13 | env: 14 | NEW_PACKAGE_VERSION: ${{ github.event.release.tag_name }} 15 | NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}} 16 | steps: 17 | - uses: actions/checkout@v3 18 | - uses: actions/setup-node@v3 19 | with: 20 | node-version: 16 21 | registry-url: https://registry.npmjs.org 22 | scope: '@street-devs' 23 | - run: npm ci 24 | - run: npm run build 25 | - run: npm run increase-version 26 | - run: npm publish 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /lib 4 | /node_modules 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | pnpm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | lerna-debug.log* 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | 38 | .env 39 | .env.* 40 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | ### JetBrains template 2 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 3 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 4 | 5 | # User-specific stuff 6 | .idea/ 7 | 8 | # Gradle and Maven with auto-import 9 | # When using Gradle or Maven with auto-import, you should exclude module files, 10 | # since they will be recreated, and may cause churn. Uncomment if using 11 | # auto-import. 12 | # *.iml 13 | # *.ipr 14 | 15 | # CMake 16 | cmake-build-*/ 17 | 18 | # File-based project format 19 | *.iws 20 | 21 | # IntelliJ 22 | out/ 23 | 24 | # mpeltonen/sbt-idea plugin 25 | .idea_modules/ 26 | 27 | # JIRA plugin 28 | atlassian-ide-plugin.xml 29 | 30 | # Crashlytics plugin (for Android Studio and IntelliJ) 31 | com_crashlytics_export_strings.xml 32 | crashlytics.properties 33 | crashlytics-build.properties 34 | fabric.properties 35 | 36 | ### Node template 37 | # Logs 38 | logs 39 | *.log 40 | npm-debug.log* 41 | yarn-debug.log* 42 | yarn-error.log* 43 | lerna-debug.log* 44 | 45 | # Diagnostic reports (https://nodejs.org/api/report.html) 46 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 47 | 48 | # Runtime data 49 | pids 50 | *.pid 51 | *.seed 52 | *.pid.lock 53 | 54 | # Directory for instrumented libs generated by jscoverage/JSCover 55 | lib-cov 56 | 57 | # Coverage directory used by tools like istanbul 58 | coverage 59 | *.lcov 60 | 61 | # nyc test coverage 62 | .nyc_output 63 | 64 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 65 | .grunt 66 | 67 | # Bower dependency directory (https://bower.io/) 68 | bower_components 69 | 70 | # node-waf configuration 71 | .lock-wscript 72 | 73 | # Compiled binary addons (https://nodejs.org/api/addons.html) 74 | build/Release 75 | 76 | # Dependency directories 77 | node_modules/ 78 | jspm_packages/ 79 | 80 | # Snowpack dependency directory (https://snowpack.dev/) 81 | web_modules/ 82 | 83 | # TypeScript cache 84 | *.tsbuildinfo 85 | 86 | # Optional npm cache directory 87 | .npm 88 | 89 | # Optional eslint cache 90 | .eslintcache 91 | 92 | # Microbundle cache 93 | .rpt2_cache/ 94 | .rts2_cache_cjs/ 95 | .rts2_cache_es/ 96 | .rts2_cache_umd/ 97 | 98 | # Optional REPL history 99 | .node_repl_history 100 | 101 | # Output of 'npm pack' 102 | *.tgz 103 | 104 | # Yarn Integrity file 105 | .yarn-integrity 106 | 107 | # dotenv environment variables file 108 | .env 109 | .env.* 110 | 111 | # parcel-bundler cache (https://parceljs.org/) 112 | .cache 113 | .parcel-cache 114 | 115 | # Next.js build output 116 | .next 117 | out 118 | 119 | # Nuxt.js build / generate output 120 | .nuxt 121 | dist 122 | 123 | # Gatsby files 124 | .cache/ 125 | # Comment in the public line in if your project uses Gatsby and not Next.js 126 | # https://nextjs.org/blog/next-9-1#public-directory-support 127 | # public 128 | 129 | # vuepress build output 130 | .vuepress/dist 131 | 132 | # Serverless directories 133 | .serverless/ 134 | 135 | # FuseBox cache 136 | .fusebox/ 137 | 138 | # DynamoDB Local files 139 | .dynamodb/ 140 | 141 | # TernJS port file 142 | .tern-port 143 | 144 | # Stores VSCode versions used for testing VSCode extensions 145 | .vscode-test 146 | 147 | # yarn v2 148 | .yarn/cache 149 | .yarn/unplugged 150 | .yarn/build-state.yml 151 | .yarn/install-state.gz 152 | .pnp.* 153 | 154 | src/ 155 | test/ 156 | scripts/ 157 | .github/ 158 | package-lock.json 159 | tsconfig.json 160 | tsconfig.build.json 161 | *.js.map -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5", 4 | "printWidth": 80, 5 | "semi": false, 6 | "tabWidth": 2 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Justin Phan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **`@street-devs/nest-snowflake-id` - User Guide** 2 | 3 | ## Overview 4 | 5 | The **`@street-devs/nest-snowflake-id`** package provides a highly customizable Snowflake ID generator for NestJS applications. This generator produces unique 64-bit IDs based on the Snowflake algorithm, which consists of a timestamp, a node (instance) ID, and a sequence number. It also includes decoding capabilities to extract the components of generated IDs. 6 | 7 | ### Key Features: 8 | - **Customizable epoch**: You can specify a custom start epoch for the ID generation. 9 | - **Worker and Data Center IDs**: Each instance of the generator can have its own node ID, ensuring that generated IDs are unique across across multiple machines and data centers. 10 | - **Concurrency-safe**: Handles sequence numbers within the same millisecond to avoid collisions. 11 | 12 | --- 13 | 14 | ## Installation 15 | 16 | To install the package in your NestJS project, run: 17 | 18 | ```bash 19 | npm install --save @street-devs/nest-snowflake-id 20 | ``` 21 | 22 | --- 23 | 24 | ## Usage 25 | 26 | ### 1. Importing and Configuring the Module 27 | 28 | To use **`@street-devs/nest-snowflake-id`** in your NestJS application, you need to import the module and configure it. 29 | 30 | #### Example: Basic Usage 31 | 32 | ```typescript 33 | import { Module } from '@nestjs/common'; 34 | import { SnowflakeIdModule } from '@street-devs/nest-snowflake-id'; 35 | 36 | @Module({ 37 | imports: [SnowflakeIdModule.forRoot()], 38 | }) 39 | export class AppModule {} 40 | ``` 41 | 42 | #### Example: Custom Configuration 43 | 44 | You can provide custom options: 45 | 46 | ```typescript 47 | import { Module } from '@nestjs/common'; 48 | import { SnowflakeIdModule } from '@street-devs/nest-snowflake-id'; 49 | 50 | @Module({ 51 | imports: [SnowflakeIdModule.forRoot({ 52 | customEpoch: 1609459200000, // Custom epoch (Jan 1, 2021) 53 | dataCenterId: 1, // Data Center ID 54 | workerId: 1, // Worker ID 55 | })], 56 | }) 57 | export class AppModule {} 58 | ``` 59 | 60 | - `customEpoch` is an optional UNIX timestamp that marks the start of your Snowflake IDs. If not provided, the current time is used. 61 | - `dataCenterId` allows you to set a unique data center ID, which should be between 0 and 31 (based on 5-bit configuration). 62 | - `workerId`: allows you to set a unique worker ID, which should be between 0 and 31 (based on 5-bit configuration). 63 | 64 | ### 2. Generating IDs 65 | 66 | You can generate Snowflake IDs by injecting the **`SnowflakeIdService`** into your service or controller. 67 | 68 | #### Example: ID Generation 69 | 70 | ```typescript 71 | import { Injectable } from '@nestjs/common'; 72 | import { SnowflakeIdService } from '@street-devs/nest-snowflake-id'; 73 | 74 | @Injectable() 75 | export class MyService { 76 | constructor(private readonly snowflakeIdService: SnowflakeIdService) {} 77 | 78 | generateId() { 79 | const id = this.snowflakeIdService.generate(); 80 | console.log(`Generated Snowflake ID: ${id}`); 81 | return id; 82 | } 83 | } 84 | ``` 85 | 86 | The `generate()` method will return a unique **64-bit Snowflake ID** as a `bigint`. 87 | 88 | ### 3. Decoding IDs 89 | 90 | You can also decode a Snowflake ID to extract its timestamp, instance ID, and sequence number. 91 | 92 | #### Example: ID Decoding 93 | 94 | ```typescript 95 | import { Injectable } from '@nestjs/common'; 96 | import { SnowflakeIdService } from '@street-devs/nest-snowflake-id'; 97 | 98 | @Injectable() 99 | export class MyService { 100 | constructor(private readonly snowflakeIdService: SnowflakeIdService) {} 101 | 102 | decodeId(id: bigint) { 103 | const decoded = this.snowflakeIdService.decode(id); 104 | console.log(`Decoded Snowflake ID:`, decoded); 105 | return decoded; 106 | } 107 | } 108 | ``` 109 | 110 | The `decode()` method will return an object containing: 111 | - `dateTime`: The exact date and time when the ID was generated. 112 | - `timestamp`: Raw timestamp value. 113 | - `dataCenterId`: The ID of the data center. 114 | - `workerId`: The ID of the worker node. 115 | - `sequence`: The sequence number ensuring uniqueness within the same millisecond. 116 | - `epoch`: The custom epoch used. 117 | 118 | 119 | ### 4. Global Module Usage 120 | 121 | If you want to make the **`SnowflakeIdService`** globally available throughout your application, set the `global` option to `true`: 122 | 123 | ```typescript 124 | @Module({ 125 | imports: [SnowflakeIdModule.forRoot({ global: true })], 126 | }) 127 | export class AppModule {} 128 | ``` 129 | 130 | --- 131 | 132 | ## API Reference 133 | 134 | ### SnowflakeIdService Methods 135 | 136 | 1. **`generate()`**: Generates a unique 64-bit Snowflake ID. 137 | - Returns: `bigint` 138 | 139 | 2. **`decode(id: bigint)`**: Decodes the given Snowflake ID. 140 | - Parameters: 141 | - `id`: The Snowflake ID to decode. 142 | - Returns: `{ dateTime: Date, timestamp: bigint, dataCenterId: bigint, workerId: bigint, sequence: bigint, epoch: number }` 143 | 144 | --- 145 | 146 | 147 | ## Technical Details 148 | 149 | ### ID Structure (64 bits): 150 | 151 | - **Epoch (42 bits)**: Used to store the timestamp (up to 139 years). 152 | - **Worker ID (5 bits)**: Identifies the node generating the ID (supports up to 32 workers). 153 | - **Data Center ID (5 bits)**: Identifies the data center (supports up to 32 data centers). 154 | - **Sequence (12 bits)**: Ensures uniqueness within the same millisecond (can generate up to 4096 IDs per millisecond). 155 | 156 | ### Edge Cases: 157 | - When multiple IDs are generated within the same millisecond, the sequence number will increment. If the sequence number reaches the limit (1023), the generator waits for the next millisecond. 158 | 159 | --- 160 | 161 | ## Example Use Case 162 | 163 | ```typescript 164 | const snowflake = new SnowflakeId({ 165 | customEpoch: 1609459200000, 166 | dataCenterId: 1, 167 | workerId: 1 168 | }); 169 | const newId = snowflake.generate(); 170 | console.log(newId); // Example output: 93977444276639021 171 | const decoded = snowflake.decode(newId); 172 | console.log(decoded); 173 | // { 174 | // "dateTime": "2024-09-16T07:52:48.732Z", 175 | // "timestamp": 1726473168732, 176 | // "dataCenterId": 1, 177 | // "workerId": 1, 178 | // "sequence": 1325, 179 | // "epoch": 1704067200000 180 | // } 181 | ``` 182 | 183 | --- 184 | 185 | ## License 186 | 187 | This package is open-sourced under the MIT License. 188 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './lib' 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@street-devs/nest-snowflake-id", 3 | "version": "2.0.0", 4 | "description": "Provides a highly customizable Snowflake ID generator for NestJS applications. This generator produces unique 64-bit IDs based on the Snowflake algorithm, which consists of a timestamp, a node (instance) ID, and a sequence number. It also includes decoding capabilities to extract the components of generated IDs.", 5 | "author": "duysolo ", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/street-devs/nest-snowflake-id.git" 9 | }, 10 | "keywords": [ 11 | "street-devs", 12 | "snowflake id", 13 | "nestjs snowflake id" 14 | ], 15 | "main": "lib/index.js", 16 | "typings": "lib/index.d.ts", 17 | "private": false, 18 | "license": "MIT", 19 | "scripts": { 20 | "prebuild": "rimraf dist", 21 | "dev": "npm run prebuild && tsc --build tsconfig.json", 22 | "build": "npm run prebuild && tsc --build tsconfig.build.json", 23 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 24 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 25 | "increase-version": "node scripts/increase-version.js" 26 | }, 27 | "dependencies": { 28 | "@street-devs/snowflake-id": "^1.0.10" 29 | }, 30 | "devDependencies": { 31 | "@nestjs/core": "^10.4.1", 32 | "@nestjs/common": "^10.4.1", 33 | "@nestjs/cli": "^10.4.5", 34 | "@nestjs/schematics": "^10.1.4", 35 | "@nestjs/testing": "^10.4.1", 36 | "@types/jest": "^29.5.13", 37 | "@types/supertest": "^6.0.2", 38 | "@typescript-eslint/eslint-plugin": "^8.5.0", 39 | "@typescript-eslint/parser": "^8.5.0", 40 | "eslint-config-prettier": "^9.1.0", 41 | "eslint-import-resolver-typescript": "^3.6.3", 42 | "eslint-plugin-import": "^2.30.0", 43 | "eslint-plugin-prettier": "^5.2.1", 44 | "prettier": "^3.3.3", 45 | "eslint": "^8.48.0", 46 | "jest": "^29.7.0", 47 | "supertest": "^7.0.0", 48 | "ts-jest": "^29.2.5", 49 | "ts-node": "^10.9.2", 50 | "typescript": "^5.6.2", 51 | "reflect-metadata": "^0.2.2", 52 | "rimraf": "^5.0.1" 53 | }, 54 | "peerDependencies": { 55 | "@nestjs/core": "*", 56 | "@nestjs/common": "*", 57 | "reflect-metadata": "*" 58 | }, 59 | "peerDependenciesMeta": {}, 60 | "bugs": { 61 | "url": "https://github.com/street-devs/nest-snowflake-id/issues" 62 | }, 63 | "homepage": "https://github.com/street-devs/nest-snowflake-id#readme", 64 | "directories": { 65 | "test": "test" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /scripts/increase-version.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | 5 | const raw = fs.readFileSync('./package.json', { encoding: 'utf8' }) 6 | 7 | const packageContent = JSON.parse(raw) 8 | 9 | packageContent.version = 10 | process.env.NEW_PACKAGE_VERSION || packageContent.version 11 | 12 | console.log(`New ${packageContent.name} version: ${packageContent.version}`) 13 | 14 | fs.writeFileSync('./package.json', JSON.stringify(packageContent, undefined, 2)) 15 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './snowflake-id.service' 2 | export * from './snowflake-id.module' 3 | export * from '@street-devs/snowflake-id' 4 | -------------------------------------------------------------------------------- /src/snowflake-id.module.ts: -------------------------------------------------------------------------------- 1 | import { type DynamicModule } from '@nestjs/common' 2 | import { type SnowflakeIdOptions } from '@street-devs/snowflake-id' 3 | import { SnowflakeIdService } from './snowflake-id.service' 4 | 5 | export class SnowflakeIdModule { 6 | public static forRoot( 7 | options?: SnowflakeIdOptions & { global?: boolean } 8 | ): DynamicModule { 9 | return { 10 | module: SnowflakeIdModule, 11 | providers: [ 12 | { 13 | provide: SnowflakeIdService, 14 | useValue: new SnowflakeIdService(options), 15 | }, 16 | ], 17 | exports: [SnowflakeIdService], 18 | global: options?.global || false, 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/snowflake-id.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common' 2 | import { SnowflakeId, type SnowflakeIdOptions } from '@street-devs/snowflake-id' 3 | 4 | @Injectable() 5 | export class SnowflakeIdService { 6 | private readonly _snowflakeId: SnowflakeId 7 | 8 | public constructor(options?: SnowflakeIdOptions) { 9 | this._snowflakeId = new SnowflakeId(options) 10 | } 11 | 12 | public generate() { 13 | return this._snowflakeId.generate() 14 | } 15 | 16 | public decode(id: bigint) { 17 | return this._snowflakeId.decode(id) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": "../src/__tests__", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false, 5 | "sourceRoot": "" 6 | }, 7 | "exclude": [ 8 | "node_modules", 9 | "test", 10 | "dist", 11 | "src/tests/*.ts", 12 | "src/**/__tests__/**/*.ts", 13 | "src/**/*.spec.ts", 14 | "src/**/*.e2e-spec.ts", 15 | "src/**/*.ft-spec.ts" 16 | ] 17 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "module": "commonjs", 5 | "target": "es2020", 6 | "declaration": true, 7 | "removeComments": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "allowSyntheticDefaultImports": true, 11 | "sourceMap": true, 12 | "incremental": true, 13 | "skipLibCheck": true, 14 | "strictNullChecks": true, 15 | "noImplicitAny": false, 16 | "strictBindCallApply": false, 17 | "forceConsistentCasingInFileNames": false, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSources": false, 20 | "allowJs": false, 21 | "outDir": "./lib", 22 | "baseUrl": "./", 23 | "sourceRoot": "./", 24 | "rootDirs": ["src/"], 25 | "lib": ["ES2020"], 26 | "esModuleInterop": true, 27 | "noUnusedLocals": true 28 | }, 29 | "include": ["src/**/*.ts"], 30 | "exclude": ["node_modules", "test", "lib"] 31 | } 32 | --------------------------------------------------------------------------------