Skip to content

Commit 8fc6ef1

Browse files
init project
0 parents  commit 8fc6ef1

29 files changed

Lines changed: 687 additions & 0 deletions

.eslintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
sourceType: 'module',
6+
},
7+
plugins: ['@typescript-eslint/eslint-plugin'],
8+
extends: [
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier',
12+
'prettier/@typescript-eslint',
13+
],
14+
root: true,
15+
env: {
16+
node: true,
17+
jest: true,
18+
},
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
},
24+
};

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# OS
14+
.DS_Store
15+
16+
# Tests
17+
/coverage
18+
/.nyc_output
19+
20+
# IDEs and editors
21+
/.idea
22+
.project
23+
.classpath
24+
.c9/
25+
*.launch
26+
.settings/
27+
*.sublime-workspace
28+
29+
# IDE - VSCode
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json
35+
36+
# package-lock
37+
package-lock.json

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2020 DevUI.
4+
Copyright (c) 2020 Huawei Technologies Co., Ltd.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## devui tutorial server
2+
3+
### 技术
4+
* Nodejs
5+
* Nestjs
6+
* in-memory-db
7+
8+
### 启动开发
9+
10+
```shell
11+
npm run start:dev #默认端口3000
12+
```
13+
#### 构建
14+
15+
```shell
16+
npm run build
17+
```

nest-cli.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"collection": "@nestjs/schematics",
3+
"sourceRoot": "src"
4+
}

package.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "devui-tutorial-server",
3+
"version": "0.0.0",
4+
"description": "",
5+
"author": "",
6+
"private": true,
7+
"scripts": {
8+
"prebuild": "rimraf dist",
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+
},
22+
"dependencies": {
23+
"@nestjs-addons/in-memory-db": "^1.8.10",
24+
"@nestjs/common": "~6.10.14",
25+
"@nestjs/core": "~6.10.14",
26+
"@nestjs/platform-express": "~6.10.14",
27+
"jsonfile": "^6.0.0",
28+
"jsonwebtoken": "^8.5.1",
29+
"reflect-metadata": "^0.1.13",
30+
"rimraf": "^3.0.0",
31+
"rxjs": "~6.5.4"
32+
},
33+
"devDependencies": {
34+
"@nestjs/cli": "~6.13.2",
35+
"@nestjs/schematics": "~6.8.1",
36+
"@nestjs/testing": "~6.10.14",
37+
"@types/express": "~4.17.2",
38+
"@types/jest": "25.1.2",
39+
"@types/node": "^13.1.6",
40+
"@types/supertest": "^2.0.8",
41+
"@typescript-eslint/eslint-plugin": "^2.12.0",
42+
"@typescript-eslint/parser": "^2.12.0",
43+
"eslint": "^6.7.2",
44+
"eslint-config-prettier": "^6.7.0",
45+
"eslint-plugin-import": "^2.19.1",
46+
"jest": "^24.9.0",
47+
"prettier": "^1.18.2",
48+
"supertest": "^4.0.2",
49+
"ts-jest": "25.2.0",
50+
"ts-loader": "^6.2.1",
51+
"ts-node": "^8.6.0",
52+
"tsconfig-paths": "^3.9.0",
53+
"typescript": "~3.7.4"
54+
},
55+
"jest": {
56+
"moduleFileExtensions": [
57+
"js",
58+
"json",
59+
"ts"
60+
],
61+
"rootDir": "src",
62+
"testRegex": ".spec.ts$",
63+
"transform": {
64+
"^.+\\.(t|j)s$": "ts-jest"
65+
},
66+
"coverageDirectory": "../coverage",
67+
"testEnvironment": "node"
68+
}
69+
}

src/app.controller.spec.ts

Lines changed: 22 additions & 0 deletions
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

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

src/app.module.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Module } from '@nestjs/common';
2+
import { AppController } from './app.controller';
3+
import { AppService } from './app.service';
4+
import { LoginController } from './login/login.controller';
5+
import { APP_INTERCEPTOR } from '@nestjs/core';
6+
import {LoggingInterceptor} from './interceptor/logging.interceptor';
7+
import { IsLoginController } from './is-login/is-login.controller';
8+
import { ArticlesModule } from './articles/articles.module';
9+
import { DashboardController } from './dashboard/dashboard.controller';
10+
import { InMemoryDBModule } from '@nestjs-addons/in-memory-db';
11+
@Module({
12+
imports: [ArticlesModule, InMemoryDBModule.forRoot()],
13+
controllers: [AppController, LoginController, IsLoginController, DashboardController],
14+
providers: [
15+
AppService,
16+
{
17+
provide: APP_INTERCEPTOR,
18+
useClass: LoggingInterceptor,
19+
}
20+
],
21+
})
22+
export class AppModule {}

0 commit comments

Comments
 (0)