forked from cuixueshe/dida
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3ae78f
commit 073a184
Showing
19 changed files
with
3,101 additions
and
836 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
node_modules | ||
**/*.cy.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
.turbo | ||
coverage |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Backend | ||
|
||
## Running the app | ||
|
||
```bash | ||
# development | ||
$ pnpm run start | ||
|
||
# watch mode | ||
$ pnpm run start:dev | ||
|
||
# production mode | ||
$ pnpm run start:prod | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ pnpm run test | ||
|
||
# e2e tests | ||
$ pnpm run test:e2e | ||
|
||
# test coverage | ||
$ pnpm run test:cov | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "backend", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "nest build", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:prod": "node dist/main", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cov": "vitest run --coverage", | ||
"test:e2e": "vitest run --config test/vitest-e2e.config.ts" | ||
}, | ||
"dependencies": { | ||
"@nestjs/common": "^9.3.5", | ||
"@nestjs/core": "^9.3.5", | ||
"@nestjs/platform-express": "^9.3.5", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.8.0" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/cli": "^9.2.0", | ||
"@nestjs/schematics": "^9.0.4", | ||
"@nestjs/testing": "^9.3.5", | ||
"@swc/core": "^1.3.32", | ||
"@types/express": "^4.17.17", | ||
"@types/node": "18.13.0", | ||
"@types/superagent": "^4.1.15", | ||
"@types/supertest": "^2.0.12", | ||
"@vitest/coverage-c8": "^0.28.4", | ||
"source-map-support": "^0.5.21", | ||
"supertest": "^6.3.3", | ||
"typescript": "^4.9.5", | ||
"unplugin-swc": "^1.3.2", | ||
"vite": "^4.0.4", | ||
"vitest": "^0.27.0", | ||
"webpack": "^5.75.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@antfu", | ||
"rules": { | ||
"@typescript-eslint/consistent-type-imports": "off", | ||
"@typescript-eslint/ban-ts-comment": "off" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { TestingModule } from '@nestjs/testing' | ||
import { Test } 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) | ||
}) | ||
|
||
it('should return "Hello World!"', () => { | ||
expect(appController.getHello()).toBe('Hello World!') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common' | ||
import { AppController } from './app.controller' | ||
import { AppService } from './app.service' | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common' | ||
|
||
@Injectable() | ||
export class AppService { | ||
getHello(): string { | ||
return 'Hello World!' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { TestingModule } from '@nestjs/testing' | ||
import { Test } from '@nestjs/testing' | ||
import type { INestApplication } from '@nestjs/common' | ||
import request from 'supertest' | ||
import { AppModule } from '@/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!') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'vitest/config' | ||
import { mergeConfig } from 'vite' | ||
import defaultConfig from '../vitest.config' | ||
|
||
export default mergeConfig(defaultConfig, defineConfig({ | ||
test: { | ||
include: ['**/*.e2e-spec.ts'], | ||
}, | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "vitest.*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "esnext", | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": false, | ||
"noImplicitAny": false, | ||
"strictBindCallApply": false, | ||
"forceConsistentCasingInFileNames": false, | ||
"noFallthroughCasesInSwitch": false, | ||
"types": [ | ||
"vitest/globals" | ||
], | ||
"paths": { | ||
"@/*": [ | ||
"src/*" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig } from 'vitest/config' | ||
import swc from 'unplugin-swc' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
swc.vite(), | ||
], | ||
test: { | ||
globals: true, | ||
}, | ||
resolve: { | ||
alias: { | ||
'@/': '/src/', | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.