File size: 797 Bytes
c0dd699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
import { OpenAPIRoute } from 'chanfana';
import { Context } from 'hono';


import { Bindings } from '../types';

export class UserInfo extends OpenAPIRoute {
    schema = {
        summary: '获取用户信息',
        description: '',
        response: {
            200: {
                description: 'userId',
                content: {
                },
            },
        },
    };

    async handle(c: Context<{ Bindings: Bindings }>) {
        // const data = await this.getValidatedData<typeof this.schema>();
        const jwtPayload = c.get('jwtPayload');
        if (!jwtPayload) {
            return c.json({ error: 'jwtPayload not found' }, 401);
        }
        
        let result = {
            userId: jwtPayload.userId
        }

        return c.json(result);
    }
}