Created
January 14, 2020 17:51
-
-
Save santoshyadavdev/510776e173a9ddfc781cffe7a34a09bc to your computer and use it in GitHub Desktop.
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
import { Controller, Get, Param } from '@nestjs/common'; | |
import { InMemoryDBService } from '@nestjs-addons/in-memory-db'; | |
import { EmployeeEntity } from './entities/employee'; | |
@Controller('employee') | |
export class EmployeeController { | |
constructor(private employeeService: InMemoryDBService<EmployeeEntity>) { | |
} | |
@Get('seed') | |
GetEmployee() { | |
const recordFactory = (idx: number): Partial<EmployeeEntity> => ({ | |
id: idx, email: `test${idx}@test.com`, age: 10, department: 'Marketing', name: `Test${idx}` | |
}); | |
this.employeeService.seed(recordFactory, 10); | |
return this.employeeService.getAll(); | |
} | |
@Get(':id') | |
GetEmployeeByID(@Param('id') id: number) { | |
return this.employeeService.get(+id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment