Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
912e1c46d9 |
8
src/app.d.ts
vendored
8
src/app.d.ts
vendored
|
@ -1,13 +1,15 @@
|
|||
// See https://kit.svelte.dev/docs/types#app
|
||||
// for information about these interfaces
|
||||
import { Database } from 'pg';
|
||||
import { Pool } from "pg";
|
||||
import type { SimpleGit } from "simple-git";
|
||||
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
interface Locals {
|
||||
db: any;
|
||||
}
|
||||
db: Pool;
|
||||
git: SimpleGit;
|
||||
}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
|
|
18
src/routes/api/search/+server.ts
Normal file
18
src/routes/api/search/+server.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { json } from '@sveltejs/kit';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ url, locals }) => {
|
||||
const category = String(url.searchParams.get('category'));
|
||||
|
||||
if (!category) {
|
||||
error(400, 'Bad request');
|
||||
}
|
||||
|
||||
const db = await locals.db;
|
||||
const article = await db.query(
|
||||
'SELECT * FROM article WHERE category = $1',
|
||||
[category]
|
||||
);
|
||||
return new Response();
|
||||
};
|
Loading…
Reference in New Issue
Block a user