Data/Users: Rename layout.server.ts to page.server.ts
This commit is contained in:
20
src/routes/data/users/+page.server.ts
Normal file
20
src/routes/data/users/+page.server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { User } from "$lib/schema";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, locals }) => {
|
||||
const fetch_users = async (): Promise<User[]> => {
|
||||
const users: User[] = await locals.pb
|
||||
.collection("users")
|
||||
.getFullList({ fetch: fetch, sort: "+username" });
|
||||
|
||||
users.map((user: User) => {
|
||||
user.avatar_url = locals.pb.files.getURL(user, user.avatar);
|
||||
});
|
||||
|
||||
return users;
|
||||
};
|
||||
|
||||
return {
|
||||
users: await fetch_users(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user