forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.controller.ts
More file actions
28 lines (21 loc) · 781 Bytes
/
Copy pathusers.controller.ts
File metadata and controls
28 lines (21 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { UsersService } from "./users.service";
import { RequestMethod, Controller, RequestMapping } from "./../../../src/";
@Controller({ path: 'users' })
export class UsersController {
constructor(private usersService: UsersService) {}
@RequestMapping()
async getAllUsers(req, res) {
const users = await this.usersService.getAllUsers();
res.status(200).json(users);
}
@RequestMapping({ path: '/:id' })
async getUser(req, res) {
const user = await this.usersService.getUser(req.params.id);
res.status(200).json(user);
}
@RequestMapping({ method: RequestMethod.POST })
async addUser(req, res) {
const msg = await this.usersService.getUser(req.body.user);
res.status(201).json(msg);
}
}