Skip to content

Commit

Permalink
add basic data
Browse files Browse the repository at this point in the history
  • Loading branch information
qingtu authored and qingtu committed Aug 11, 2021
1 parent 87f1036 commit 4836dda
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CatsController } from './cats/cats.controller';
// import { CatsController } from './cats/cats.controller';
import { CatsService } from './cats/cats.service';
import { CatsModule } from './cats/cats.module';

Expand All @@ -15,7 +15,8 @@ import { CatsModule } from './cats/cats.module';
}),
CatsModule,
],
controllers: [AppController, CatsController],
// controllers: [AppController, CatsController],
controllers: [AppController],
providers: [AppService, CatsService],
})
export class AppModule {}
61 changes: 59 additions & 2 deletions src/cats/cats.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
import { Controller } from '@nestjs/common';
import { Controller, Get } from '@nestjs/common';
import { CatsService } from './cats.service';
import Data from '../interfaces/data';

@Controller('cats')
export class CatsController {}
export class CatsController {
constructor(private readonly catsService: CatsService) {}

@Get()
findAll(): string {
return this.catsService.findAll();
}

@Get('/data')
findDataSource(): Data[] {
return [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
tags: ['nice', 'developer'],
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
tags: ['loser'],
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
{
key: '4',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
tags: ['nice', 'developer'],
},
{
key: '5',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
tags: ['loser'],
},
{
key: '6',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
];
}
}
6 changes: 5 additions & 1 deletion src/cats/cats.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class CatsService {}
export class CatsService {
findAll(): string {
return 'some cats';
}
}
26 changes: 0 additions & 26 deletions src/gqls/AuthorResolver.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/interfaces/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface Data {
key: string;
name: string;
age: number;
address: string;
tags: string[];
}

export default Data;
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ async function bootstrap() {
AppModule,
new FastifyAdapter({ logger: true }),
);
await app.listen(3000);
await app.listen(4000);
}
bootstrap();

0 comments on commit 4836dda

Please sign in to comment.