mirror of https://github.com/sveltejs/svelte
parent
90ecf90963
commit
bd5f69ded4
@ -0,0 +1,20 @@
|
|||||||
|
import send from '@polka/send';
|
||||||
|
import { query } from '../../utils/db';
|
||||||
|
|
||||||
|
export async function get(req, res) {
|
||||||
|
if (req.user) {
|
||||||
|
const offset = req.params.offset || 0;
|
||||||
|
const rows = await query(`
|
||||||
|
select g.uid, g.name, coalesce(g.updated_at, g.created_at) as updated_at
|
||||||
|
from gists g
|
||||||
|
where g.user_id = $1
|
||||||
|
order by updated_at desc
|
||||||
|
limit 100
|
||||||
|
offset $2
|
||||||
|
`, [req.user.id, offset]);
|
||||||
|
|
||||||
|
send(res, 200, rows);
|
||||||
|
} else {
|
||||||
|
send(res, 401);
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
import send from '@polka/send';
|
|
||||||
import { query } from '../../utils/db';
|
|
||||||
import { isUser } from '../../backend/auth';
|
|
||||||
|
|
||||||
export async function get(req, res) {
|
|
||||||
const user = await isUser(req, res);
|
|
||||||
if (!user) return; // response already sent
|
|
||||||
|
|
||||||
const offset = req.params.offset || 0;
|
|
||||||
const rows = await query(`
|
|
||||||
select g.uid, g.name, coalesce(g.updated_at, g.created_at) as updated_at
|
|
||||||
from gists g
|
|
||||||
where g.user_id = $1
|
|
||||||
order by g.updated_at desc, g.created_at desc
|
|
||||||
limit 100
|
|
||||||
offset $2
|
|
||||||
`, [user.id, offset]);
|
|
||||||
|
|
||||||
send(res, 200, rows);
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import send from '@polka/send';
|
|
||||||
import { query } from '../../utils/db';
|
|
||||||
import { isUser } from '../../backend/auth';
|
|
||||||
|
|
||||||
export async function get(req, res) {
|
|
||||||
const user = await isUser(req, res);
|
|
||||||
if (!user) return; // response already sent
|
|
||||||
|
|
||||||
const offset = req.params.offset || 0;
|
|
||||||
const rows = await query(`
|
|
||||||
select g.uid, g.name, coalesce(g.updated_at, g.created_at) as updated_at
|
|
||||||
from gists g
|
|
||||||
where g.user_id = $1
|
|
||||||
order by g.updated_at desc, g.created_at desc
|
|
||||||
limit 100
|
|
||||||
offset $2
|
|
||||||
`, [user.id, offset]);
|
|
||||||
|
|
||||||
send(res, 200, rows);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<!-- TODO we need to be able to fetch the data in preload -->
|
|
||||||
|
|
||||||
<script context="module">
|
|
||||||
export async function preload() {
|
|
||||||
const r = await this.fetch('repls.json');
|
|
||||||
|
|
||||||
return {
|
|
||||||
list: await r.json()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export let list;
|
|
||||||
</script>
|
|
Loading…
Reference in new issue