mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
feat: add api controllers and routes for browser extension
This commit is contained in:
18
app/api/tokens/controllers/api_token_controller.ts
Normal file
18
app/api/tokens/controllers/api_token_controller.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import UnAuthorizedException from '#api/tokens/exceptions/un_authorized_exception';
|
||||
import { getTokenFromHeader } from '#api/tokens/lib/index';
|
||||
import { inject } from '@adonisjs/core';
|
||||
import { HttpContext } from '@adonisjs/core/http';
|
||||
|
||||
@inject()
|
||||
export default class ApiTokenController {
|
||||
async index(ctx: HttpContext) {
|
||||
const token = getTokenFromHeader(ctx);
|
||||
if (!token) {
|
||||
throw new UnAuthorizedException();
|
||||
}
|
||||
|
||||
return ctx.response.json({
|
||||
message: 'Token is valid',
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user