mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-24 07:06:18 +08:00
feat: use simpler nitro instead of nestjs to implement mock service
This commit is contained in:
15
apps/backend-mock/api/auth/codes.ts
Normal file
15
apps/backend-mock/api/auth/codes.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export default eventHandler((event) => {
|
||||
const token = getHeader(event, 'Authorization');
|
||||
|
||||
if (!token) {
|
||||
setResponseStatus(event, 401);
|
||||
return useResponseError('UnauthorizedException', 'Unauthorized Exception');
|
||||
}
|
||||
|
||||
const username = Buffer.from(token, 'base64').toString('utf8');
|
||||
|
||||
const codes =
|
||||
MOCK_CODES.find((item) => item.username === username)?.codes ?? [];
|
||||
|
||||
return useResponseSuccess(codes);
|
||||
});
|
Reference in New Issue
Block a user