cd78f72f33
Complete rename of all technical identifiers across the codebase: Package names (11 packages): - @planarchy/* → @capakraken/* in all package.json, tsconfig, imports Import statements: 277 files, 548 occurrences replaced Database & Docker: - PostgreSQL user/db: planarchy → capakraken - Docker volumes: planarchy_pgdata → capakraken_pgdata - Connection strings updated in docker-compose, .env, CI CI/CD: - GitHub Actions workflow: all filter commands updated - Test database credentials updated Infrastructure: - Redis channel: planarchy:sse → capakraken:sse - Logger service name: planarchy-api → capakraken-api - Anonymization seed updated - Start/stop/restart scripts updated Test data: - Seed emails: @planarchy.dev → @capakraken.dev - E2E test credentials: all 11 spec files updated - Email defaults: @planarchy.app → @capakraken.app - localStorage keys: planarchy_* → capakraken_* Documentation: 30+ .md files updated Verification: - pnpm install: workspace resolution works - TypeScript: only pre-existing TS2589 (no new errors) - Engine: 310/310 tests pass - Staffing: 37/37 tests pass Co-Authored-By: claude-flow <ruv@ruv.net>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { prisma } from "@capakraken/db";
|
|
import { checkChargeabilityAlerts } from "@capakraken/api";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
export const runtime = "nodejs";
|
|
|
|
/**
|
|
* GET /api/cron/chargeability-alerts
|
|
*
|
|
* Finds resources whose current-month chargeability is >15 percentage points
|
|
* below their target and creates in-app notifications for managers.
|
|
*
|
|
* Duplicate-safe: only one alert per resource per month.
|
|
*
|
|
* Optionally protect with CRON_SECRET environment variable.
|
|
* When set, requests must include `Authorization: Bearer <secret>`.
|
|
*/
|
|
export async function GET(request: Request) {
|
|
const cronSecret = process.env["CRON_SECRET"];
|
|
if (cronSecret) {
|
|
const auth = request.headers.get("authorization");
|
|
if (auth !== `Bearer ${cronSecret}`) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
}
|
|
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const alertsSent = await checkChargeabilityAlerts(prisma as any);
|
|
|
|
return NextResponse.json({
|
|
ok: true,
|
|
alertsSent,
|
|
checkedAt: new Date().toISOString(),
|
|
});
|
|
} catch (error) {
|
|
console.error("[cron/chargeability-alerts] Error:", error);
|
|
return NextResponse.json(
|
|
{ ok: false, error: "Internal error" },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|