actually start implementing the backend slowly
This commit is contained in:
parent
37ae49b66e
commit
342fd30d62
19 changed files with 977 additions and 136 deletions
|
|
@ -0,0 +1,26 @@
|
|||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const { groupOrServerId, channelId } = params;
|
||||
|
||||
const isGroup = !channelId;
|
||||
|
||||
// fake messages
|
||||
const messages = Array.from({ length: 5 }, (_, i) => ({
|
||||
id: crypto.randomUUID(),
|
||||
authorId: `user_${Math.floor(Math.random() * 10)}`,
|
||||
content: isGroup
|
||||
? `Group message #${i + 1}`
|
||||
: `Server message #${i + 1}`,
|
||||
timestamp: Date.now() - Math.floor(Math.random() * 100000),
|
||||
}));
|
||||
|
||||
return json({
|
||||
type: isGroup ? 'group' : 'server',
|
||||
groupId: isGroup ? groupOrServerId : null,
|
||||
serverId: isGroup ? null : groupOrServerId,
|
||||
channelId: channelId ?? null,
|
||||
messages,
|
||||
});
|
||||
};
|
||||
17
src/routes/api/status/[userId]/+server.ts
Normal file
17
src/routes/api/status/[userId]/+server.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { Status } from '$lib';
|
||||
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const { userId } = params;
|
||||
|
||||
const status = Object.values(Status)[Math.floor(Math.random() * Object.values(Status).length)];
|
||||
|
||||
return json({
|
||||
userId,
|
||||
status,
|
||||
lastActive: Date.now() - Math.floor(Math.random() * 600000),
|
||||
customStatus: Math.random() > 0.5 ? 'vibing 🟢' : null,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue