pretty
This commit is contained in:
parent
f0f32d71fc
commit
ce0d940953
35 changed files with 62 additions and 66 deletions
|
|
@ -13,4 +13,4 @@ const config = {
|
||||||
options: {}
|
options: {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ const preview = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default preview;
|
export default preview;
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,4 @@ h2 {
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
@apply font-display text-2xl;
|
@apply font-display text-2xl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
src/app.d.ts
vendored
3
src/app.d.ts
vendored
|
|
@ -2,10 +2,9 @@
|
||||||
// for information about these interfaces
|
// for information about these interfaces
|
||||||
declare global {
|
declare global {
|
||||||
namespace App {
|
namespace App {
|
||||||
|
|
||||||
// interface Error {}
|
// interface Error {}
|
||||||
interface Locals {
|
interface Locals {
|
||||||
user: import("lucia").User | null;
|
user: import('lucia').User | null;
|
||||||
session: import('lucia').Session | null;
|
session: import('lucia').Session | null;
|
||||||
}
|
}
|
||||||
// interface PageData {}
|
// interface PageData {}
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Story name="Default" args={{ label: 'Button', size: 'normal', primary: true }} />
|
<Story name="Default" args={{ label: 'Button', size: 'normal', primary: true }} />
|
||||||
|
|
|
||||||
|
|
@ -48,4 +48,4 @@
|
||||||
.button--secondary {
|
.button--secondary {
|
||||||
@apply bg-blue-600 text-white;
|
@apply bg-blue-600 text-white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,4 @@
|
||||||
|
|
||||||
<Story name="Text" args={{ label: 'Text', name: 'text', type: 'text' }} />
|
<Story name="Text" args={{ label: 'Text', name: 'text', type: 'text' }} />
|
||||||
<Story name="Password" args={{ label: 'Password', name: 'pass', type: 'password' }} />
|
<Story name="Password" args={{ label: 'Password', name: 'pass', type: 'password' }} />
|
||||||
<Story name="Email" args={{ label: 'Email', name: 'email', type: 'email' }} />
|
<Story name="Email" args={{ label: 'Email', name: 'email', type: 'email' }} />
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,4 @@
|
||||||
all: unset;
|
all: unset;
|
||||||
@apply text-lg;
|
@apply text-lg;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Story name="Default" args={{}} />
|
<Story name="Default" args={{}} />
|
||||||
|
|
|
||||||
|
|
@ -48,4 +48,4 @@
|
||||||
transform: rotate(-360deg);
|
transform: rotate(-360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Story name="Default" args={{ title: 'Storybook' }} />
|
<Story name="Default" args={{ title: 'Storybook' }} />
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,4 @@
|
||||||
.navbar h2 {
|
.navbar h2 {
|
||||||
@apply text-xl;
|
@apply text-xl;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export * from './Navbar.svelte';
|
export * from './Navbar.svelte';
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
// place files you want to import through the `$lib` alias in this folder.
|
// place files you want to import through the `$lib` alias in this folder.
|
||||||
export * from './components';
|
export * from './components';
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@ export const LoadConfig = (): Configuration => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Config = LoadConfig();
|
export const Config = LoadConfig();
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,4 @@ export const yogaLogger: YogaLogger = {
|
||||||
// @ts-expect-error types dont match
|
// @ts-expect-error types dont match
|
||||||
logger.error(...args);
|
logger.error(...args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
import { Lucia } from "lucia";
|
import { Lucia } from 'lucia';
|
||||||
import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
|
import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
|
||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
const client = new PrismaClient();
|
const client = new PrismaClient();
|
||||||
const adapter = new PrismaAdapter(client.session, client.user)
|
const adapter = new PrismaAdapter(client.session, client.user);
|
||||||
// expect error (see next section)
|
// expect error (see next section)
|
||||||
export const auth = new Lucia(adapter, {
|
export const auth = new Lucia(adapter, {
|
||||||
sessionCookie: {
|
sessionCookie: {
|
||||||
attributes: {
|
attributes: {
|
||||||
secure: process.env.NODE_ENV === "production"
|
secure: process.env.NODE_ENV === 'production'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getUserAttributes: (attributes)=>{
|
getUserAttributes: (attributes) => {
|
||||||
return {
|
return {
|
||||||
email: attributes.email
|
email: attributes.email
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
declare module "lucia" {
|
declare module 'lucia' {
|
||||||
interface Register {
|
interface Register {
|
||||||
Lucia: typeof Lucia;
|
Lucia: typeof Lucia;
|
||||||
DatabaseUserAttributes: DatabaseUserAttributes
|
DatabaseUserAttributes: DatabaseUserAttributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DatabaseUserAttributes {
|
interface DatabaseUserAttributes {
|
||||||
email: string
|
email: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Auth = typeof auth;
|
export type Auth = typeof auth;
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,4 @@ export const builder = new SchemaBuilder<PothosType>({
|
||||||
// warn when not using a query parameter correctly
|
// warn when not using a query parameter correctly
|
||||||
onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn'
|
onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export * from './schema';
|
export * from './schema';
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ export const DateScalar = builder.scalarType('Date', {
|
||||||
}
|
}
|
||||||
return new Date(date);
|
return new Date(date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ export type Scalars = {
|
||||||
Input: Date;
|
Input: Date;
|
||||||
Output: Date;
|
Output: Date;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ import './Scalars';
|
||||||
import './posts';
|
import './posts';
|
||||||
import './users';
|
import './users';
|
||||||
|
|
||||||
export const Schema = builder.toSchema();
|
export const Schema = builder.toSchema();
|
||||||
|
|
|
||||||
|
|
@ -107,4 +107,4 @@ builder.mutationFields((t) => ({
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -80,4 +80,4 @@ builder.mutationFields((t) => ({
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
export const prisma = new PrismaClient();
|
export const prisma = new PrismaClient();
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ import type { YogaInitialContext } from 'graphql-yoga';
|
||||||
export const Context = (initialContext: YogaInitialContext) => ({
|
export const Context = (initialContext: YogaInitialContext) => ({
|
||||||
...initialContext,
|
...initialContext,
|
||||||
config: Config
|
config: Config
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
export * from './context';
|
export * from './context';
|
||||||
export * from './server';
|
export * from './server';
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ export const Yoga = createYoga<RequestEvent>({
|
||||||
// Let Yoga use sveltekit's Response object
|
// Let Yoga use sveltekit's Response object
|
||||||
fetchAPI: { Response },
|
fetchAPI: { Response },
|
||||||
logging: yogaLogger
|
logging: yogaLogger
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@
|
||||||
.layout {
|
.layout {
|
||||||
@apply h-screen w-screen animate-fade bg-slate-100;
|
@apply h-screen w-screen animate-fade bg-slate-100;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ export async function load(event) {
|
||||||
return {
|
return {
|
||||||
authenticated: !!user
|
authenticated: !!user
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@
|
||||||
.site-loader {
|
.site-loader {
|
||||||
@apply flex h-screen w-screen flex-col items-center justify-center gap-6;
|
@apply flex h-screen w-screen flex-col items-center justify-center gap-6;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import { Yoga } from '$lib/server/yoga';
|
import { Yoga } from '$lib/server/yoga';
|
||||||
|
|
||||||
export { Yoga as GET, Yoga as POST };
|
export { Yoga as GET, Yoga as POST };
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar title="Svelte" />
|
<Navbar title="Svelte" />
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { logger } from '$lib/server/logger';
|
import { logger } from '$lib/server/logger';
|
||||||
import { prisma } from '$lib/server/prisma';
|
import { prisma } from '$lib/server/prisma';
|
||||||
import { error, redirect, type Actions } from '@sveltejs/kit';
|
import { error, redirect, type Actions } from '@sveltejs/kit';
|
||||||
import { Argon2id } from "oslo/password"
|
import { Argon2id } from 'oslo/password';
|
||||||
import { auth } from '$lib/server/lucia.js';
|
import { auth } from '$lib/server/lucia.js';
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
|
|
@ -19,12 +19,12 @@ export const actions = {
|
||||||
logger.error('User not found! ${user}');
|
logger.error('User not found! ${user}');
|
||||||
return error(401);
|
return error(401);
|
||||||
}
|
}
|
||||||
const pw = form.get('password') as string;
|
const password = form.get('password') as string;
|
||||||
if(!pw) {
|
if (!password) {
|
||||||
return error(401, 'Password is required')
|
return error(401, 'Password is required');
|
||||||
}
|
}
|
||||||
const validPassword = await new Argon2id().verify(user.password,pw);
|
const validPassword = await new Argon2id().verify(user.password, password);
|
||||||
if(!validPassword) {
|
if (!validPassword) {
|
||||||
return error(400, 'Password is incorrect!');
|
return error(400, 'Password is incorrect!');
|
||||||
}
|
}
|
||||||
const session = await auth.createSession(user.id, []);
|
const session = await auth.createSession(user.id, []);
|
||||||
|
|
@ -36,14 +36,12 @@ export const actions = {
|
||||||
redirect(302, '/');
|
redirect(302, '/');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
register: async (event) => {
|
register: async (event) => {
|
||||||
const form = await event.request.formData();
|
const form = await event.request.formData();
|
||||||
if (!form.has('email') || !form.has('name') || !form.has('password')) {
|
if (!form.has('email') || !form.has('name') || !form.has('password')) {
|
||||||
return error(400);
|
return error(400);
|
||||||
}
|
}
|
||||||
const hashedPassword = await new Argon2id().hash(form.get('password') as string)
|
const hashedPassword = await new Argon2id().hash(form.get('password') as string);
|
||||||
const user = await prisma.user.create({
|
const user = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
email: form.get('email') as string,
|
email: form.get('email') as string,
|
||||||
|
|
@ -61,6 +59,5 @@ export const actions = {
|
||||||
maxAge: 120
|
maxAge: 120
|
||||||
});
|
});
|
||||||
redirect(302, '/');
|
redirect(302, '/');
|
||||||
|
|
||||||
}
|
}
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,4 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [typography]
|
plugins: [typography]
|
||||||
} satisfies Config;
|
} satisfies Config;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue