feat!: start implementing repo listing & auth middleware
This commit is contained in:
@@ -10,9 +10,7 @@
|
||||
const query = createQuery(() => ({
|
||||
queryKey: ['github-repositories'],
|
||||
queryFn: async () => {
|
||||
const response = await fetch('https://api.github.com/user/repos?affiliation=owner', {
|
||||
headers: {}
|
||||
});
|
||||
const response = await fetch(`/api/${$session.data?.user.id}/repos`);
|
||||
return await response.json();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { jwt } from 'better-auth/plugins';
|
||||
import { createAuthClient } from 'better-auth/svelte';
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: 'http://localhost:5173'
|
||||
baseURL: 'http://localhost:5173',
|
||||
plugins: [jwt()]
|
||||
});
|
||||
|
||||
@@ -2,12 +2,14 @@ import { betterAuth } from 'better-auth';
|
||||
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
|
||||
import { db } from './db/drizzle';
|
||||
import * as authSchema from './db/auth-schema';
|
||||
import { jwt } from 'better-auth/plugins';
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
provider: 'pg',
|
||||
schema: { ...authSchema }
|
||||
}),
|
||||
plugins: [jwt()],
|
||||
socialProviders: {
|
||||
github: {
|
||||
clientId: process.env.GH_CLIENT_ID!,
|
||||
|
||||
@@ -73,6 +73,14 @@ export const verification = pgTable(
|
||||
(table) => [index("verification_identifier_idx").on(table.identifier)],
|
||||
);
|
||||
|
||||
export const jwks = pgTable("jwks", {
|
||||
id: text("id").primaryKey(),
|
||||
publicKey: text("public_key").notNull(),
|
||||
privateKey: text("private_key").notNull(),
|
||||
createdAt: timestamp("created_at").notNull(),
|
||||
expiresAt: timestamp("expires_at"),
|
||||
});
|
||||
|
||||
export const userRelations = relations(user, ({ many }) => ({
|
||||
sessions: many(session),
|
||||
accounts: many(account),
|
||||
|
||||
Reference in New Issue
Block a user