Add short links middleware and list endpoint
This commit is contained in:
11
functions/api/short-links/list.ts
Normal file
11
functions/api/short-links/list.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { jsonResponse } from "../../common.js";
|
||||
|
||||
export async function onRequestGet(context: RequestContext) {
|
||||
const { results } = await context.env.D1.prepare(
|
||||
"SELECT created_at, destination, path FROM short_links WHERE user = ?;",
|
||||
)
|
||||
.bind(context.data.current_user.id)
|
||||
.all();
|
||||
|
||||
return jsonResponse(JSON.stringify(results));
|
||||
}
|
Reference in New Issue
Block a user