MCPcopy Create free account
hub / github.com/coderwhy/coderhub / UserController

Class UserController

src/controller/user.controller.js:8–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class UserController {
9 async create(ctx, next) {
10 // 获取用户请求传递的参数
11 const user = ctx.request.body;
12
13 // 查询数据
14 const result = await userService.create(user);
15
16 // 返回数据
17 ctx.body = result;
18 }
19
20 async avatarInfo(ctx, next) {
21 // 1.用户的头像是哪一个文件呢?
22 const { userId } = ctx.params;
23 const avatarInfo = await fileService.getAvatarByUserId(userId);
24
25 // 2.提供图像信息
26 ctx.response.set('content-type', avatarInfo.mimetype);
27 ctx.body = fs.createReadStream(`${AVATAR_PATH}/${avatarInfo.filename}`);
28 }
29}
30
31module.exports = new UserController();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected