Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cced658

Browse files
feat(test)
1 parent 44e9a06 commit cced658

File tree

11 files changed

+167
-0
lines changed

11 files changed

+167
-0
lines changed

‎.npmignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.travis.yml
2+
test

‎.travis.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
os:
2+
- linux
3+
language: node_js
4+
node_js:
5+
- '9'
6+
install:
7+
- npm install npm@latest -g
8+
- npm ci
9+
script:
10+
- npm run test
11+
branches:
12+
only:
13+
- develop

‎test/gulpfile.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const gulp = require('gulp'),
2+
compodoc = require('@compodoc/gulp-compodoc');
3+
4+
gulp.task('default', () => {
5+
return gulp.src('nest-app/src/**/*.ts')
6+
.pipe(compodoc({
7+
output: 'nest-app//documentation',
8+
tsconfig: 'nest-app/tsconfig.json'
9+
}))
10+
});

‎test/nest-app/src/app.controller.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Get, Controller } 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+
root(): string {
10+
return this.appService.root();
11+
}
12+
13+
@Auth(Roles.User)
14+
@Post()
15+
async create(@Body() body: CreateTodoDto, @AuthUser() authUser: User) {}
16+
17+
@UsePipes(new ValidationPipe())
18+
@ApiResponse({ description: 'Return all articles.' })
19+
@Post('multiple')
20+
async createMultipleTodo(@Body() body: CreateMultipleTodoDto, @AuthUser() authUser: User) {}
21+
}

‎test/nest-app/src/app.module.ts‎

Lines changed: 10 additions & 0 deletions
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 {}

‎test/nest-app/src/app.service.ts‎

Lines changed: 8 additions & 0 deletions
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+
root(): string {
6+
return 'Hello World!';
7+
}
8+
}

‎test/nest-app/src/auth.controller.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller, Headers, Post, Res, HttpStatus, Delete } from '@nestjs/common';
2+
3+
@Controller('auth')
4+
export class AuthController {
5+
6+
constructor() {}
7+
8+
@Post()
9+
async login(@Headers() headers, @Res() res) {
10+
11+
}
12+
13+
@Delete()
14+
async logout(@Res() res) {
15+
16+
}
17+
}

‎test/nest-app/src/main.hmr.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NestFactory } from '@nestjs/core';
2+
import { AppModule } from './app.module';
3+
4+
declare const module: any;
5+
6+
async function bootstrap() {
7+
const app = await NestFactory.create(AppModule);
8+
await app.listen(3000);
9+
10+
if (module.hot) {
11+
module.hot.accept();
12+
module.hot.dispose(() => app.close());
13+
}
14+
}
15+
bootstrap();

‎test/nest-app/src/main.ts‎

Lines changed: 8 additions & 0 deletions
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/nest-app/src/user.entity.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {Entity, PrimaryGeneratedColumn, Column, BeforeInsert, JoinTable, ManyToMany, OneToMany} from "typeorm";
2+
import { IsEmail, Validate } from 'class-validator';
3+
import * as crypto from 'crypto';
4+
import { ArticleEntity } from '../article/article.entity';
5+
6+
@Entity('user')
7+
export class UserEntity {
8+
9+
@PrimaryGeneratedColumn()
10+
id: number;
11+
12+
@Column()
13+
username: string;
14+
15+
@Column()
16+
@IsEmail()
17+
email: string;
18+
19+
@Column({default: ''})
20+
bio: string;
21+
22+
@Column({default: ''})
23+
image: string;
24+
25+
@Column()
26+
password: string;
27+
28+
@BeforeInsert()
29+
hashPassword() {
30+
this.password = crypto.createHmac('sha256', this.password).digest('hex');
31+
}
32+
33+
@ManyToMany(type => ArticleEntity)
34+
@JoinTable()
35+
favorites: ArticleEntity[];
36+
37+
@OneToMany(type => ArticleEntity, article => article.author)
38+
articles: ArticleEntity[];
39+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /