mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 14:43:24 +00:00
19 lines
492 B
TypeScript
19 lines
492 B
TypeScript
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',
|
|
});
|
|
}
|
|
}
|