Skip to content

Commit 91936c3

Browse files
committedApr 10, 2024
init(codebase): stagging initial codebase
0 parents  commit 91936c3

21 files changed

+13590
-0
lines changed
 

‎.commitlintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"]
3+
}

‎.czrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "./node_modules/cz-conventional-changelog"
3+
}

‎.eslintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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/eslint-plugin'],
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: ['.eslintrc.js', '**/dist/**', '**/node_modules/**'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

‎.gitignore

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
/build
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+
# dotenv environment variable files
39+
.env*
40+
!.env.example
41+
42+
# temp directory
43+
.temp
44+
.tmp
45+
46+
# Runtime data
47+
pids
48+
*.pid
49+
*.seed
50+
*.pid.lock
51+
52+
# Diagnostic reports (https://nodejs.org/api/report.html)
53+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

‎.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.11.0

‎.prettierignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.github
3+
.gitignore
4+
node_modules/
5+
dist/
6+
*.md
7+
*-lock.json
8+
.nvmrc
9+
*-cli.json

‎.prettierrc.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"semi": true,
7+
"overrides": [
8+
{
9+
"files": "*.json",
10+
"options": {
11+
"printWidth": 200
12+
}
13+
}
14+
]
15+
}

‎.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"files.eol": "\n",
5+
"cSpell.words": ["commitlint", "mahabubx", "nestjs", "precommit"]
6+
}

‎README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Nest.js project starter kit (Knex.js & Postgres)
2+
3+
**Tech Usages:**
4+
```yml
5+
Runtime: Node.js v20 (LTS)
6+
Framework: Nest.js (v10)
7+
Databases: PostgreSQL (knex.js), and Redis (native-driver)
8+
Mailer: NodeMailer (tempMail)
9+
```
10+
> Docker-compose ready!
11+
12+
## TODO:
13+
14+
- [ ] Compose Nest.js application initials!
15+
- [ ] Setup `commit-lint` for standard commit history
16+
- [ ] Setup `ESLint` & `Prettier`
17+
- [ ] Setup `husky` & `lint-staged` for lint-proof commits
18+
- [ ] Setup and config `env` variables & docker-composed instances
19+
- [ ] Setup `Knex.js` with `PostgreSQL`
20+
- [ ] Setup Validation-pipes for incoming request body
21+
- [ ] Implement User Module with CRUD
22+
- [ ] Implement Todo Module with CRUD
23+
- [ ] Setup `RBAC/PBAC` with `nest-access-control`
24+
- [ ] Config **Todo with required permissions**
25+
- [ ] Setup `Swagger` API Documentation
26+
- [ ] Setup `Throttler` for rate-limiting

‎nest-cli.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src",
5+
"compilerOptions": {
6+
"deleteOutDir": true
7+
}
8+
}

‎package-lock.json

+13,228
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"name": "nest.js-api-starter-kit",
3+
"version": "1.0.0",
4+
"description": "Nest.js API project starter kit by @mahabubx7",
5+
"author": "Mahabub <mahabubx7@gmail.com>",
6+
"private": true,
7+
"license": "UNLICENSED",
8+
"scripts": {
9+
"build": "nest build",
10+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11+
"start": "nest start",
12+
"start:dev": "nest start --watch",
13+
"start:debug": "nest start --debug --watch",
14+
"start:prod": "node dist/main",
15+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
16+
"test": "jest",
17+
"test:watch": "jest --watch",
18+
"test:cov": "jest --coverage",
19+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
20+
"test:e2e": "jest --config ./test/jest-e2e.json",
21+
"precommit": "npx lint-staged",
22+
"commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS"
23+
},
24+
"dependencies": {
25+
"@nestjs/common": "^10.0.0",
26+
"@nestjs/core": "^10.0.0",
27+
"@nestjs/platform-express": "^10.0.0",
28+
"reflect-metadata": "^0.2.0",
29+
"rxjs": "^7.8.1"
30+
},
31+
"devDependencies": {
32+
"@commitlint/cli": "^19.2.1",
33+
"@commitlint/config-conventional": "^19.1.0",
34+
"@nestjs/cli": "^10.0.0",
35+
"@nestjs/schematics": "^10.0.0",
36+
"@nestjs/testing": "^10.0.0",
37+
"@types/express": "^4.17.17",
38+
"@types/jest": "^29.5.2",
39+
"@types/node": "^20.3.1",
40+
"@types/supertest": "^6.0.0",
41+
"@typescript-eslint/eslint-plugin": "^6.0.0",
42+
"@typescript-eslint/parser": "^6.0.0",
43+
"commitizen": "^4.3.0",
44+
"cz-conventional-changelog": "^3.3.0",
45+
"eslint": "^8.57.0",
46+
"eslint-config-prettier": "^9.1.0",
47+
"eslint-plugin-import": "^2.29.1",
48+
"eslint-plugin-prettier": "^5.0.0",
49+
"husky": "^9.0.11",
50+
"jest": "^29.5.0",
51+
"lint-staged": "^15.2.2",
52+
"prettier": "^3.2.5",
53+
"source-map-support": "^0.5.21",
54+
"supertest": "^6.3.3",
55+
"ts-jest": "^29.1.0",
56+
"ts-loader": "^9.4.3",
57+
"ts-node": "^10.9.1",
58+
"tsconfig-paths": "^4.2.0",
59+
"typescript": "^5.1.3"
60+
},
61+
"engines": {
62+
"node": ">=20.11.0",
63+
"npm": ">=10.2.4"
64+
},
65+
"packageManager": ">=npm@10.2.4",
66+
"jest": {
67+
"moduleFileExtensions": [
68+
"js",
69+
"json",
70+
"ts"
71+
],
72+
"rootDir": "src",
73+
"testRegex": ".*\\.spec\\.ts$",
74+
"transform": {
75+
"^.+\\.(t|j)s$": "ts-jest"
76+
},
77+
"collectCoverageFrom": [
78+
"**/*.(t|j)s"
79+
],
80+
"coverageDirectory": "../coverage",
81+
"testEnvironment": "node"
82+
},
83+
"husky": {
84+
"hooks": {
85+
"pre-commit": "lint-staged",
86+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
87+
}
88+
},
89+
"lint-staged": {
90+
"*.ts": [
91+
"eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
92+
"git add"
93+
]
94+
}
95+
}

‎src/app.controller.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { AppController } from './app.controller';
3+
import { AppService } from './app.service';
4+
5+
describe('AppController', () => {
6+
let appController: AppController;
7+
8+
beforeEach(async () => {
9+
const app: TestingModule = await Test.createTestingModule({
10+
controllers: [AppController],
11+
providers: [AppService],
12+
}).compile();
13+
14+
appController = app.get<AppController>(AppController);
15+
});
16+
17+
describe('root', () => {
18+
it('should return "Hello World!"', () => {
19+
expect(appController.getHello()).toBe('Hello World!');
20+
});
21+
});
22+
});

‎src/app.controller.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
import { AppService } from './app.service';
3+
4+
@Controller()
5+
export class AppController {
6+
constructor(private readonly appService: AppService) {}
7+
8+
@Get()
9+
getHello(): string {
10+
return this.appService.getHello();
11+
}
12+
}

‎src/app.module.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Module } from '@nestjs/common';
2+
import { AppController } from './app.controller';
3+
import { AppService } from './app.service';
4+
5+
@Module({
6+
imports: [],
7+
controllers: [AppController],
8+
providers: [AppService],
9+
})
10+
export class AppModule {}

‎src/app.service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class AppService {
5+
getHello(): string {
6+
return 'Hello World!';
7+
}
8+
}

‎src/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { NestFactory } from '@nestjs/core';
2+
import { AppModule } from './app.module';
3+
4+
async function bootstrap() {
5+
const app = await NestFactory.create(AppModule);
6+
await app.listen(3000);
7+
}
8+
bootstrap();

‎test/app.e2e-spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { INestApplication } from '@nestjs/common';
3+
import * as request from 'supertest';
4+
import { AppModule } from './../src/app.module';
5+
6+
describe('AppController (e2e)', () => {
7+
let app: INestApplication;
8+
9+
beforeEach(async () => {
10+
const moduleFixture: TestingModule = await Test.createTestingModule({
11+
imports: [AppModule],
12+
}).compile();
13+
14+
app = moduleFixture.createNestApplication();
15+
await app.init();
16+
});
17+
18+
it('/ (GET)', () => {
19+
return request(app.getHttpServer())
20+
.get('/')
21+
.expect(200)
22+
.expect('Hello World!');
23+
});
24+
});

‎test/jest-e2e.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"moduleFileExtensions": ["js", "json", "ts"],
3+
"rootDir": ".",
4+
"testEnvironment": "node",
5+
"testRegex": ".e2e-spec.ts$",
6+
"transform": {
7+
"^.+\\.(t|j)s$": "ts-jest"
8+
}
9+
}

‎tsconfig.build.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4+
}

‎tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"declaration": true,
5+
"removeComments": true,
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"allowSyntheticDefaultImports": true,
9+
"target": "ES2021",
10+
"sourceMap": true,
11+
"outDir": "./dist",
12+
"baseUrl": "./",
13+
"incremental": true,
14+
"skipLibCheck": true,
15+
"strictNullChecks": false,
16+
"noImplicitAny": false,
17+
"strictBindCallApply": false,
18+
"forceConsistentCasingInFileNames": false,
19+
"noFallthroughCasesInSwitch": false
20+
}
21+
}

0 commit comments

Comments
 (0)
Please sign in to comment.