master
Kar 2024-09-20 20:21:19 +05:30
commit bca6c309f0
20 changed files with 5331 additions and 0 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
# compiled output
/dist
/node_modules
src/config/secrets/keys
!src/config/secrets/README.md

44
.env.sample Normal file
View File

@ -0,0 +1,44 @@
# ---- Application ---- #
APPLICATION_PORT=3010
APPLICATION_HOST=http://localhost
# ---- Mongodb ---- #
MONGO_URL=mongodb://localhost:27017/db
# ---- Redis ---- #
REDIS_PORT=6379
REDIS_HOST=127.0.0.1
REDIS_FAMILY=4
REDIS_PASSWORD=''
REDIS_DB=0
REDIS_ENABLE_OFFLINE_QUEUE=false
# ---- Payment Service ---- #
EXTERNAL_PAYMENT_SERVICE_HOST=http://localhost:3756
# ---- Auth ---- #
AUTH_SERVER_TOKEN=whatAToken
# ---- AWS ---- #
S3_ENDPOINT=s3.ap-south-1.amazonaws.com
S3_KEY=AKIAQ35B6OYRWULNZLXD
S3_SECRET=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
S3_BUCKET=buzz-test-1
# ---- Jwt ---- #
JWT_KEY_PRIVATE=LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBNWdYQ3pJblZsVjB4VHVIVkdyaUxMb21EZHNZUHJ3KzB1S1dMNWdUeGFBbVBtc1pDCjlaOGliSHY3TzUzWGk1dVZMYUpNd01BOG14TURVckp4YTIxK1NtVzNDTUJxZ3pMZ21qenNVTitESEMyUlZ2T1IKc1dkT3FySVl6dTBYT01sOEU1K0hJL1lEUzBoaWZndGFESTIrMDJQSFVJVkVsRHFuRHl0Z3crNzBpS1R3WlpJUQowTTRYTjU5UUl3R0V6VnRuTVlnNUowSmlJQkhHcGN3bTViRUEybzgwbU5uM0dlL2ZneVY3UEdzTzFmdVNobVNPCjlMc0dNeFBFcnE0QnAzNHRaaGdJckZINmlLQjYvcGU4Z2l0UUd0NXFERU1uU1hJTml1SkV2eD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zBpS1R3WlpJUTBNNFhONTlRSXdHRXpWdG5NWWc1SjBKaUlCSEdwY3dtNWJFQQoybzgwbU5uM0dlL2ZneVY3UEdzTzFmdVNobVNPOUxzR014UEVycTRCcDM0dFpoZ0lyRkg2aUtCNi9wZThnaXRRCkd0NXFERU1uU1hJTml1SkV2eDRxNWtoSkc1LytHV2VnOGI2QzY0Sk5JbmRtNFVGeC9qQXI1V3VyNHFYTGVyOWIKYVFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
JWT_KEY_PASSPHRASE=''
JWT_EXPIRES_IN=7d
# JWT_EXPIRES_IN_MS=
JWT_ISSUER=domainname
CODEMAGIC_API_KEY=codemagic
FIREBASE_TOKEN=ft
FIREBASE_PROJECT_ID=fpid
GOOGLE_APPLICATION_CREDENTIALS=./src/config/secrets/firebase_service_account.json
EXTERNAL_COMMUNICATION_SERVICE_HOST=http://localhost:3007
FIREBASE_KEY=abcdf1234

25
.eslintrc.js Normal file
View File

@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};

56
.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build
# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# OS
.DS_Store
# Tests
/coverage
/.nyc_output
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# temp directory
.temp
.tmp
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

85
README.md Normal file
View File

@ -0,0 +1,85 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Project setup
```bash
$ yarn install
```
## Compile and run the project
```bash
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
```
## Run tests
```bash
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
```
## Resources
Check out a few resources that may come in handy when working with NestJS:
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).

8
nest-cli.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}

76
package.json Normal file
View File

@ -0,0 +1,76 @@
{
"name": "boilarplate-nestjs",
"version": "0.0.1",
"description": "NestJs Boilarplate",
"author": "Kar Kar",
"license": "MUKTI the liberation",
"scripts": {
"generate": "echo \"Enter Type (eg, module, keys)\" && read type && npm run generate:$type",
"generate:module": "nest generate -c ./.generator/rest/ res && npm run build",
"generate:keys": "mkdir -p src/config/secrets/keys && ssh-keygen -b 2048 -t rsa -m pem -C jwtKey -f ./src/config/secrets/keys/rsa -N \"$npm_config_passphrase\" && openssl rsa -in ./src/config/secrets/keys/rsa -passin pass:\"$npm_config_passphrase\" -pubout -out ./src/config/secrets/keys/rsa.pub.pem",
"show:publicKey": "base64 ./src/config/secrets/keys/rsa.pub.pem",
"show:privateKey": "base64 ./src/config/secrets/keys/rsa",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"docker:prod": "docker-compose -f docker-compose.yml -f docker-compose.prod.yml up",
"docker:dev": "docker-compose -f docker-compose.yml -f docker-compose.dev.yml up",
"docker:test": "docker-compose -f docker-compose.yml -f docker-compose.test.yml up"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

View File

@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});

12
src/app.controller.ts Normal file
View File

@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

11
src/app.module.ts Normal file
View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ModuleLoader } from './loaders/module.loader';
@Module({
imports: [...StaticModules, ...ModuleLoader()],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

8
src/app.service.ts Normal file
View File

@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@ -0,0 +1,16 @@
import { ConfigFactory, ConfigObject } from '@nestjs/config';
import { sync } from 'fast-glob';
import { resolve } from 'path';
export const ConfigLoader = () => {
const configs: Array<ConfigFactory<ConfigObject>> = [];
const modulePaths = sync(resolve(__dirname + '/../config/*.config.*').replace(/\\/g, '/'), {
ignore: ['**/*.d.ts', '**/*.js.map'],
});
for (const moduleFile of modulePaths) {
const s = require(moduleFile).default;
configs.push(s);
}
return configs;
};

View File

@ -0,0 +1,19 @@
import { DynamicModule } from '@nestjs/common';
import { sync } from 'fast-glob';
import { resolve } from 'path';
export const ModuleLoader = () => {
const modules: Array<DynamicModule> = [];
const modulePaths = sync(resolve(__dirname + '/../modules/**/*.module.*').replace(/\\/g, '/'), {
ignore: ['**/*.d.ts', '**/*.js.map'],
});
for (const moduleFile of modulePaths) {
const s = require(moduleFile);
const providersRequire: any[] = Object.values(s);
for (const provider of providersRequire) {
modules.push(provider);
}
}
return modules;
};

8
src/main.ts Normal file
View File

@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();

24
test/app.e2e-spec.ts Normal file
View File

@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});

9
test/jest-e2e.json Normal file
View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

4
tsconfig.build.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

21
tsconfig.json Normal file
View File

@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
}

4873
yarn.lock Normal file

File diff suppressed because it is too large Load Diff