mirror of
https://github.com/supleed2/udlink-docs.git
synced 2024-11-10 04:15:49 +00:00
20 lines
564 B
JavaScript
20 lines
564 B
JavaScript
|
export const onRequest = async ({ env }) => {
|
||
|
const value = await fetch(env.TURSO_URL, {
|
||
|
method: "POST",
|
||
|
headers: {
|
||
|
Authorization: `Bearer ${env.TURSO_AUTH_TOKEN}`,
|
||
|
"Content-Type": "application/json",
|
||
|
},
|
||
|
body: JSON.stringify({
|
||
|
requests: [
|
||
|
{ type: "execute", stmt: { sql: "select count from request_count where id = 1" } },
|
||
|
{ type: "close" },
|
||
|
],
|
||
|
}),
|
||
|
})
|
||
|
.then((res) => res.json())
|
||
|
.then((res) => res.results[0].response.result.rows[0][0].value)
|
||
|
.catch((err) => console.log(err));
|
||
|
return new Response(value, { status: 200 });
|
||
|
}
|