Skip to content

Commit b9c5ac3

Browse files
authored
fixed missing query files (#992)
1 parent 46d15fa commit b9c5ac3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import postgres from 'postgres';
2+
3+
const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });
4+
5+
async function listInvoices() {
6+
const data = await sql`
7+
SELECT invoices.amount, customers.name
8+
FROM invoices
9+
JOIN customers ON invoices.customer_id = customers.id
10+
WHERE invoices.amount = 666;
11+
`;
12+
13+
return data;
14+
}
15+
16+
export async function GET() {
17+
// return Response.json({
18+
// message:
19+
// 'Uncomment this file and remove this line. You can delete this file when you are finished.',
20+
// });
21+
try {
22+
return Response.json(await listInvoices());
23+
} catch (error) {
24+
return Response.json({ error }, { status: 500 });
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// import postgres from 'postgres';
2+
3+
// const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });
4+
5+
// async function listInvoices() {
6+
// const data = await sql`
7+
// SELECT invoices.amount, customers.name
8+
// FROM invoices
9+
// JOIN customers ON invoices.customer_id = customers.id
10+
// WHERE invoices.amount = 666;
11+
// `;
12+
13+
// return data;
14+
// }
15+
16+
export async function GET() {
17+
return Response.json({
18+
message:
19+
'Uncomment this file and remove this line. You can delete this file when you are finished.',
20+
});
21+
// try {
22+
// return Response.json(await listInvoices());
23+
// } catch (error) {
24+
// return Response.json({ error }, { status: 500 });
25+
// }
26+
}

0 commit comments

Comments
 (0)