set up hono types

This commit is contained in:
Chad Freeman 2024-08-17 14:18:14 -04:00
parent aeba55b315
commit b8a234d52e
8 changed files with 19 additions and 15 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -16,7 +16,6 @@
"@olli/kvdex": "npm:@jsr/olli__kvdex",
"@oxi/option": "npm:@jsr/oxi__option",
"@oxi/result": "npm:@jsr/oxi__result",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@ts-rex/argon2": "npm:@jsr/ts-rex__argon2",
@ -31,6 +30,7 @@
"prettier-plugin-svelte": "^3.2.5",
"svelte": "^5.0.0-next.1",
"svelte-check": "^3.6.0",
"sveltekit-adapter-deno": "^0.12.1",
"sveltekit-superforms": "^2.17.0",
"tailwindcss": "^3.4.10",
"typescript": "^5.0.0",

View file

@ -1,6 +1,10 @@
import { Hono } from "hono"
const api = new Hono()
type Bindings = {
locals: App.Locals
}
const api = new Hono<{ Bindings: Bindings }>()
export type api = typeof api
export const hono = new Hono().route('/api', api)
export const hono = new Hono<{ Bindings: Bindings }>().route('/api', api)

View file

@ -1,5 +1,7 @@
import { Google, Discord, GitHub } from "arctic"
//TODO: oauth
export const google = new Google();
export const discord = new Discord();
export const github = new GitHub();

View file

@ -1,5 +1,5 @@
import { hono } from '$lib/hono.js';
export async function fallback({ request }) {
return hono.fetch(request)
export async function fallback({ request, locals }) {
return hono.fetch(request, { locals })
}

View file

@ -9,7 +9,6 @@
form.update((f) => {
f.username = username
f.password = password
console.log(f)
return f
})
})
@ -19,9 +18,9 @@
<div class="card bg-base-200 w-96 shadow-xl p-4">
<h1 class="text-xl mb-2 font-bold">sign up/in</h1>
<div class="join">
<a href="{$page.url.pathname}/oauth/google" class="btn grow btn-outline join-item">
<a href="{$page.url.pathname}/oauth/google" class="btn-disabled btn grow btn-outline join-item">
<svg
class="size-4"
class="size-4 brightness-50"
viewBox="-3 0 262 262"
xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid"
@ -46,17 +45,17 @@
></g
></svg>
</a>
<a href="{$page.url.pathname}/oauth/discord" class="btn grow btn-outline join-item">
<svg class="size-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 127.14 96.36"
<a href="{$page.url.pathname}/oauth/discord" class="btn-disabled btn grow btn-outline join-item">
<svg class="size-4 brightness-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 127.14 96.36"
><path
fill="#5865f2"
d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z"
></path
></svg>
</a>
<a href="{$page.url.pathname}/oauth/github" class="btn grow btn-outline join-item group">
<a href="{$page.url.pathname}/oauth/github" class="btn-disabled btn grow btn-outline join-item group">
<svg
class="size-5 text-[#24292f] dark:text-[#fff] group-hover:text-[#fff] dark:group-hover:text-[#24292f] transition-colors"
class="size-5 brightness-50 text-[#24292f] dark:text-[#fff] group-hover:text-[#fff] dark:group-hover:text-[#24292f] transition-colors"
viewBox="0 0 98 96"
xmlns="http://www.w3.org/2000/svg"
><path
@ -135,4 +134,4 @@
.showerror {
@apply block opacity-100;
}
</style>
</style>

View file

@ -2,7 +2,6 @@ import { cookieController, deleteSession } from '$lib/auth';
import { redirect } from '@sveltejs/kit';
export async function GET({ locals, cookies }) {
console.log(locals)
if(locals.session) {
await deleteSession(locals.session.id)
const sessionCookie = cookieController.createBlankCookie();

View file

@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-auto';
import adapter from 'sveltekit-adapter-deno';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { Float16Array } from "@petamoriken/float16"