start working on handle resolver
This commit is contained in:
parent
5f7539003e
commit
e2839dfbdd
7 changed files with 18 additions and 7 deletions
|
@ -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}`;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
0
src/routes/.well-known/atproto-did/+server.ts
Normal file
0
src/routes/.well-known/atproto-did/+server.ts
Normal file
15
src/routes/[handle]/.well-known/atproto-did/+server.ts
Normal file
15
src/routes/[handle]/.well-known/atproto-did/+server.ts
Normal 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));
|
||||
};
|
|
@ -1,4 +0,0 @@
|
|||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<p>This worked</p>
|
Loading…
Add table
Add a link
Reference in a new issue