Skip to content

Commit

Permalink
init: create NestJS project base
Browse files Browse the repository at this point in the history
  • Loading branch information
HardManDev committed Dec 30, 2024
1 parent f30d6f0 commit 0c57d0f
Show file tree
Hide file tree
Showing 13 changed files with 5,849 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
root: true,
env: {
node: true,
jest: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: [
'@typescript-eslint/eslint-plugin',
],
extends: [
'eslint:recommended',
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript"
],
ignorePatterns: ['.eslintrc.js'],
rules: {
// General formatting rules
"eol-last": ["error", "always"],
"indent": ["error", 4],
"quotes": ["error", "single"],
"semi": ["error", "never"],

// Code style and structure rules
"arrow-parens": ["error", "always"],
"arrow-spacing": ["error", { "before": true, "after": true }],
"comma-dangle": ["error", "never"],
"curly": ["error", "all"],
"func-style": ["error", "expression"],
"no-shadow": "warn",
"no-useless-concat": "error",
"object-curly-spacing": ["error", "always"],
"space-before-blocks": ["error", "always"],

// Import and export rules
"import/order": [
"warn",
{
"groups": [
["builtin", "external"],
"internal"
],
"newlines-between": "always"
}
],
"import/no-unresolved": "off",

// TypeScript-specific rules
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "explicit" }],
"@typescript-eslint/explicit-module-boundary-types": "error",

// Variable and async handling rules
"no-unused-vars": ["warn", { "vars": "all", "args": "none" }],
"prefer-const": "error",
"require-await": "error",

// Debugging and logging rules
"no-console": "error",
"no-debugger": "error",

// NestJS
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/workspace-interaction-hub.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
67 changes: 67 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "workspace-interaction-hub",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "MIT",
"scripts": {
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:prod": "node dist/main",
"start:debug": "nest start --debug --watch",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest --passWithNoTests",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
},
"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": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^22.10.2",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.0.0",
"eslint-plugin-import": "^2.31.0",
"jest": "^29.5.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"
}
}
6 changes: 6 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Module } from '@nestjs/common'

@Module({
imports: []
})
export class AppModule {}
10 changes: 10 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as process from 'node:process'
import { NestFactory } from '@nestjs/core'

import { AppModule } from './app.module'

(async () => {
const app = await NestFactory.create(AppModule)

await app.listen(process.env.PORT ?? 3000)
})()
28 changes: 28 additions & 0 deletions test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Test, TestingModule } from '@nestjs/testing'
import { INestApplication } from '@nestjs/common'
import * as request from 'supertest'

import { AppModule } from '../src/app.module'

describe('[e2e] AppModule', () => {
let app: INestApplication

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule]
}).compile()

app = moduleFixture.createNestApplication()
await app.init()
})

describe('AppController',
() => {
it('GET /',
() => {
return request(app.getHttpServer())
.get('/')
.expect(404)
})
})
})
9 changes: 9 additions & 0 deletions test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading

0 comments on commit 0c57d0f

Please sign in to comment.