-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserController.ts
More file actions
27 lines (22 loc) · 907 Bytes
/
userController.ts
File metadata and controls
27 lines (22 loc) · 907 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 { TYPES } from "../types"
import IUserRepositoryInterface from "../repositories/interfaces/userInterface"
import { inject, injectable } from "inversify"
import { Request, Response, NextFunction } from "express"
import { ICreatePostDTO } from "../dtos/postDTO"
import UserService from "../services/user"
import { myContainer } from "../inversify.config"
@injectable()
export default class UserController {
public userService: UserService
constructor() {
this.userService = myContainer.resolve<UserService>(UserService);
}
public async index(req: Request, res: Response, next: NextFunction) {
const users = await this.userService.getAll();
res.status(200).send(users);
}
public async show(req: Request, res: Response, next: NextFunction) {
const user = await this.userService.find(+req.params.id);
res.status(200).send(user);
}
}