Initial web

This commit is contained in:
Caesar2011
2026-05-17 19:55:53 +02:00
parent 6e3499812e
commit 20ed6ee9fb
58 changed files with 8541 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { NextRequest, NextResponse } from 'next/server';
import pool from '@/lib/db';
import { withAuth } from '@/lib/apiHelpers';
export const GET = withAuth(async () => {
const result = await pool.query('SELECT * FROM charts ORDER BY pos_y ASC, pos_x ASC');
return NextResponse.json(result.rows);
});
export const POST = withAuth(async (req: NextRequest) => {
const body = await req.json();
const {
title,
pos_x = 0, pos_y = 0, width = 2, height = 4,
signal_type = 'both', chart_type = 'signals', viz_type = 'line',
filter_combinators = null, filter_items = null,
filter_items_exclude = null, filter_items_regex = false,
y_min = null, y_max = null, y_scale = 'linear',
series_limit = 20, order_by = 'time',
} = body;
if (!title) return NextResponse.json({ error: 'title required' }, { status: 400 });
const result = await pool.query(
`INSERT INTO charts
(title,pos_x,pos_y,width,height,signal_type,chart_type,viz_type,
filter_combinators,filter_items,filter_items_exclude,filter_items_regex,
y_min,y_max,y_scale,series_limit,order_by)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17)
RETURNING *`,
[title,pos_x,pos_y,width,height,signal_type,chart_type,viz_type,
filter_combinators,filter_items,filter_items_exclude,filter_items_regex,
y_min,y_max,y_scale,series_limit,order_by],
);
return NextResponse.json(result.rows[0], { status: 201 });
});