SPB Git forge

spb/immbot-ai

Public
1commits 1branches 0releases
1.5 MBsize
maindefault branch
20 days agolast push
TypeScript 98.3% CSS 0.9% Shell 0.7%
693 B · 21 lines typescript
Raw Blame History
1import { NextResponse } from "next/server";2import { apiError } from "@/lib/api.ts";3import { requireUser } from "@/lib/auth/session.ts";4import { all } from "@/lib/db/index.ts";56export async function GET() {7  try {8    const user = await requireUser();9    const rows = all(10      `SELECT a.id, a.title, a.body, a.course_code, a.pinned, a.created_at11       FROM announcements a12       WHERE a.active = 1 AND (a.course_code IS NULL OR a.course_code IN (SELECT course_code FROM enrollments WHERE user_id = ?))13       ORDER BY a.pinned DESC, a.created_at DESC LIMIT 20`,14      user.id15    );16    return NextResponse.json({ announcements: rows });17  } catch (e) {18    return apiError(e);19  }20}21