feat: auth middleware, brain data layer, Valkey queue (P1-002/003/004) (#71)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #71.
This commit is contained in:
20
apps/gateway/src/auth/auth.controller.ts
Normal file
20
apps/gateway/src/auth/auth.controller.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
import { All, Controller, Inject, Req, Res } from '@nestjs/common';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { toNodeHandler } from 'better-auth/node';
|
||||
import type { Auth } from '@mosaic/auth';
|
||||
import { AUTH } from './auth.module.js';
|
||||
|
||||
@Controller('api/auth')
|
||||
export class AuthController {
|
||||
private readonly handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
||||
|
||||
constructor(@Inject(AUTH) auth: Auth) {
|
||||
this.handler = toNodeHandler(auth);
|
||||
}
|
||||
|
||||
@All('*path')
|
||||
async handleAuth(@Req() req: FastifyRequest, @Res() res: FastifyReply): Promise<void> {
|
||||
await this.handler(req.raw, res.raw);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user