2024-05-08 00:19:13 +00:00
|
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
|
import db from '../../../../../db';
|
2024-06-17 20:06:45 +00:00
|
|
|
import { userNotAuthenticated } from '$lib/server/auth-utils';
|
2024-03-15 19:05:47 +00:00
|
|
|
|
|
|
|
|
export const load: PageServerLoad = async (event) => {
|
2024-06-12 02:12:12 +00:00
|
|
|
const { locals } = event;
|
|
|
|
|
const { user, session } = locals;
|
2024-06-17 20:06:45 +00:00
|
|
|
if (userNotAuthenticated(user, session)) {
|
2024-06-12 02:12:12 +00:00
|
|
|
return fail(401);
|
2024-03-15 19:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-08 00:19:13 +00:00
|
|
|
const users = await db.query.users.findMany({
|
|
|
|
|
limit: 10,
|
|
|
|
|
offset: 0,
|
|
|
|
|
});
|
2024-03-15 19:05:47 +00:00
|
|
|
|
|
|
|
|
return {
|
2024-05-08 00:19:13 +00:00
|
|
|
users,
|
2024-03-15 19:05:47 +00:00
|
|
|
};
|
2024-05-08 00:19:13 +00:00
|
|
|
};
|