start working on handle resolver

This commit is contained in:
Lara 2025-04-08 16:45:17 +03:00
parent 5f7539003e
commit e2839dfbdd
Signed by: laratheprotogen
GPG key ID: 5C0296EB3165F98B
7 changed files with 18 additions and 7 deletions

View file

@ -5,6 +5,6 @@ export const reroute: Reroute = async ({ url }) => {
const split = url.hostname.split('.');
if (url.hostname !== PUBLIC_URL && split.length >= 2) {
return `/handles/${split[0]}/`;
return `/${split[0]}${url.pathname}`;
}
};

View file

@ -7,10 +7,10 @@ export const user = sqliteTable('user', {
handle: text('handle').notNull(),
created_at: text('created_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
.default(sql`current_timestamp`),
updated_at: text('updated_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`)
.default(sql`current_timestamp`)
});
//export type User = typeof user.$inferSelect;

View file

@ -0,0 +1,15 @@
import { error } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ params: { handle } }) => {
const user = await db.query.user.findFirst({
where: (user, { eq }) => eq(user.handle, handle)
});
if (!user) {
error(404, 'User not found');
}
return new Response(String(user.did));
};

View file

@ -1,4 +0,0 @@
<script lang="ts">
</script>
<p>This worked</p>