implement better-auth auth with postgres and route protection
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import { asErrorMessage, jsonError } from '@/lib/server/http';
|
||||
import { requireAuthenticatedSession } from '@/lib/server/auth-session';
|
||||
import { enqueueTask } from '@/lib/server/tasks';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const { session, response } = await requireAuthenticatedSession();
|
||||
if (response) {
|
||||
return response;
|
||||
}
|
||||
|
||||
try {
|
||||
const payload = await request.json() as {
|
||||
ticker?: string;
|
||||
@@ -13,6 +19,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
const task = await enqueueTask({
|
||||
userId: session.user.id,
|
||||
taskType: 'sync_filings',
|
||||
payload: {
|
||||
ticker: payload.ticker.trim().toUpperCase(),
|
||||
|
||||
Reference in New Issue
Block a user