flatten app to repo root and update docker deployment for single-stack runtime
This commit is contained in:
16
app/api/portfolio/insights/generate/route.ts
Normal file
16
app/api/portfolio/insights/generate/route.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { asErrorMessage, jsonError } from '@/lib/server/http';
|
||||
import { enqueueTask } from '@/lib/server/tasks';
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
const task = await enqueueTask({
|
||||
taskType: 'portfolio_insights',
|
||||
payload: {},
|
||||
priority: 70
|
||||
});
|
||||
|
||||
return Response.json({ task });
|
||||
} catch (error) {
|
||||
return jsonError(asErrorMessage(error, 'Failed to queue insights task'));
|
||||
}
|
||||
}
|
||||
10
app/api/portfolio/insights/latest/route.ts
Normal file
10
app/api/portfolio/insights/latest/route.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { getStoreSnapshot } from '@/lib/server/store';
|
||||
|
||||
export async function GET() {
|
||||
const snapshot = await getStoreSnapshot();
|
||||
const insight = snapshot.insights
|
||||
.slice()
|
||||
.sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at))[0] ?? null;
|
||||
|
||||
return Response.json({ insight });
|
||||
}
|
||||
Reference in New Issue
Block a user