Skip to content

Commit

Permalink
move server only libraries into $lib/server
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay OConnor committed Feb 17, 2024
1 parent 324fd4b commit 938f1d8
Show file tree
Hide file tree
Showing 38 changed files with 51 additions and 53 deletions.
7 changes: 3 additions & 4 deletions starter/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare global {
namespace Lucia {
type Auth = import('$lib/lucia/mysql').Auth;
type Auth = import('$lib/server/lucia/mysql').Auth;
type DatabaseUserAttributes = {
email: string;
email_verified: boolean
email_verified: boolean;
github_username?: string;
};
type DatabaseSessionAttributes = object;
Expand All @@ -21,5 +21,4 @@ declare global {
}
}

export { };

export {};
2 changes: 1 addition & 1 deletion starter/src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { auth } from '$lib/lucia/mysql';
import { auth } from '$lib/server/lucia/mysql';

export const handle = async ({ event, resolve }) => {
event.locals.auth = auth.handleRequest(event);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/mysql/client';
import { emailVerification, passwordResetToken } from '$lib/drizzle/mysql/schema';
import { drizzleClient } from '$lib/server/drizzle/mysql/client';
import { emailVerification, passwordResetToken } from '$lib/server/drizzle/mysql/schema';
import { eq } from 'drizzle-orm';
import { generateRandomString, isWithinExpiration } from 'lucia/utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/mysql/client';
import { user, userProfile } from '$lib/drizzle/mysql/schema';
import { drizzleClient } from '$lib/server/drizzle/mysql/client';
import { user, userProfile } from '$lib/server/drizzle/mysql/schema';
import { eq } from 'drizzle-orm';

const getUserByEmail = async (email: string | undefined) => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/postgres/client';
import { emailVerification, passwordResetToken } from '$lib/drizzle/postgres/schema';
import { drizzleClient } from '$lib/server/drizzle/postgres/client';
import { emailVerification, passwordResetToken } from '$lib/server/drizzle/postgres/schema';
import { eq } from 'drizzle-orm';
import { generateRandomString, isWithinExpiration } from 'lucia/utils';

Expand Down Expand Up @@ -114,9 +114,8 @@ const validatePasswordResetToken = async (token: string) => {
};

export {
generateEmailVerificationToken,
generatePasswordResetToken,
validateEmailVerificationToken,
validatePasswordResetToken
generateEmailVerificationToken,
generatePasswordResetToken,
validateEmailVerificationToken,
validatePasswordResetToken
};

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/postgres/client';
import { user, userProfile } from '$lib/drizzle/postgres/schema';
import { drizzleClient } from '$lib/server/drizzle/postgres/client';
import { user, userProfile } from '$lib/server/drizzle/postgres/schema';
import { eq } from 'drizzle-orm';

const getUserByEmail = async (email: string | undefined) => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/turso/client';
import { emailVerification, passwordResetToken } from '$lib/drizzle/turso/schema';
import { drizzleClient } from '$lib/server/drizzle/turso/client';
import { emailVerification, passwordResetToken } from '$lib/server/drizzle/turso/schema';
import { eq } from 'drizzle-orm';
import { generateRandomString, isWithinExpiration } from 'lucia/utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { drizzleClient } from '$lib/drizzle/turso/client';
import { user, userProfile } from '$lib/drizzle/turso/schema';
import { drizzleClient } from '$lib/server/drizzle/turso/client';
import { user, userProfile } from '$lib/server/drizzle/turso/schema';
import { eq } from 'drizzle-orm';

const getUserByEmail = async (email: string | undefined) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dev } from '$app/environment';
import { sendTestEmail } from '$lib/emails/mailhog';
import { sendResendEmail } from '$lib/emails/resend';
import { sendTestEmail } from '$lib/server/emails/mailhog';
import { sendResendEmail } from '$lib/server/emails/resend';

const sendEmail = async (options: { from: string; to: string; subject: string; html: string }) => {
if (!dev) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dev } from '$app/environment';
import { connectionPool } from '$lib/drizzle/mysql/client';
import { connectionPool } from '$lib/server/drizzle/mysql/client';
import {
adapterOptions,
generateUserAttributes,
githubAuthOptions,
googleAuthOptions
} from '$lib/lucia/utils';
} from '$lib/server/lucia/utils';
import { mysql2 } from '@lucia-auth/adapter-mysql';
import { github, google } from '@lucia-auth/oauth/providers';
import { lucia } from 'lucia';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dev } from '$app/environment';
import { connection } from '$lib/drizzle/postgres/client';
import { connection } from '$lib/server/drizzle/postgres/client';
import {
adapterOptions,
generateUserAttributes,
githubAuthOptions,
googleAuthOptions
} from '$lib/lucia/utils';
} from '$lib/server/lucia/utils';
import { postgres } from '@lucia-auth/adapter-postgresql';
import { github, google } from '@lucia-auth/oauth/providers';
import { lucia } from 'lucia';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dev } from '$app/environment';
import { dbClient } from '$lib/drizzle/turso/client';
import { dbClient } from '$lib/server/drizzle/turso/client';
import {
adapterOptions,
generateUserAttributes,
githubAuthOptions,
googleAuthOptions
} from '$lib/lucia/utils';
} from '$lib/server/lucia/utils';
import { libsql } from '@lucia-auth/adapter-sqlite';
import { github, google } from '@lucia-auth/oauth/providers';
import { lucia } from 'lucia';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TRANSACTIONAL_EMAILS_ADDRESS, TRANSACTIONAL_EMAILS_SENDER } from '$env/static/private';
import { generateEmailVerificationToken } from '$lib/drizzle/mysql/models/tokens';
import { getUserByEmail, getUserProfileData } from '$lib/drizzle/mysql/models/users';
import { sendEmail } from '$lib/emails/send';
import { generateEmailVerificationToken } from '$lib/server/drizzle/mysql/models/tokens';
import { getUserByEmail, getUserProfileData } from '$lib/server/drizzle/mysql/models/users';
import { sendEmail } from '$lib/server/emails/send';
import { getFeedbackObjects } from '$lib/utils';
import { fail, redirect } from '@sveltejs/kit';

Expand Down Expand Up @@ -59,7 +59,7 @@ export const actions = {
feedbacks: verificationEmail
});
}
} catch(e) {
} catch (e) {
const feedbacks = getFeedbackObjects([
{
type: 'error',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validateEmailVerificationToken } from '$lib/drizzle/mysql/models/tokens';
import { auth } from '$lib/lucia/mysql';
import { validateEmailVerificationToken } from '$lib/server/drizzle/mysql/models/tokens';
import { auth } from '$lib/server/lucia/mysql';

export const GET = async ({ params, locals }) => {
const { token } = params;
Expand Down
2 changes: 1 addition & 1 deletion starter/src/routes/(app)/app/profile/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUserProfileData } from '$lib/drizzle/mysql/models/users';
import { getUserProfileData } from '$lib/server/drizzle/mysql/models/users';
import { redirect } from '@sveltejs/kit';

export const load = async ({ locals }) => {
Expand Down
2 changes: 1 addition & 1 deletion starter/src/routes/(auth)/auth/login/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { auth } from '$lib/lucia/mysql';
import { auth } from '$lib/server/lucia/mysql';
import { getFeedbackObjects } from '$lib/utils';
import { fail, redirect } from '@sveltejs/kit';
import { LuciaError } from 'lucia';
Expand Down
8 changes: 4 additions & 4 deletions starter/src/routes/(auth)/auth/signup/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TRANSACTIONAL_EMAILS_ADDRESS, TRANSACTIONAL_EMAILS_SENDER } from '$env/static/private';
import { generateEmailVerificationToken } from '$lib/drizzle/mysql/models/tokens';
import { updateUserProfileData } from '$lib/drizzle/mysql/models/users';
import { sendEmail } from '$lib/emails/send';
import { auth } from '$lib/lucia/mysql';
import { generateEmailVerificationToken } from '$lib/server/drizzle/mysql/models/tokens';
import { updateUserProfileData } from '$lib/server/drizzle/mysql/models/users';
import { sendEmail } from '$lib/server/emails/send';
import { auth } from '$lib/server/lucia/mysql';
import { getFeedbackObjects } from '$lib/utils';
import { fail, redirect } from '@sveltejs/kit';
import { nanoid } from 'nanoid';
Expand Down
6 changes: 3 additions & 3 deletions starter/src/routes/(auth)/password-reset/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TRANSACTIONAL_EMAILS_ADDRESS, TRANSACTIONAL_EMAILS_SENDER } from '$env/static/private';
import { generatePasswordResetToken } from '$lib/drizzle/mysql/models/tokens';
import { getUserByEmail, getUserProfileData } from '$lib/drizzle/mysql/models/users';
import { sendEmail } from '$lib/emails/send';
import { generatePasswordResetToken } from '$lib/server/drizzle/mysql/models/tokens';
import { getUserByEmail, getUserProfileData } from '$lib/server/drizzle/mysql/models/users';
import { sendEmail } from '$lib/server/emails/send';
import { getFeedbackObjects } from '$lib/utils';
import { fail } from '@sveltejs/kit';
import { z } from 'zod';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validatePasswordResetToken } from '$lib/drizzle/mysql/models/tokens';
import { auth } from '$lib/lucia/mysql';
import { validatePasswordResetToken } from '$lib/server/drizzle/mysql/models/tokens';
import { auth } from '$lib/server/lucia/mysql';
import { getFeedbackObjects } from '$lib/utils';
import { fail, redirect } from '@sveltejs/kit';
import { z } from 'zod';
Expand Down
2 changes: 1 addition & 1 deletion starter/src/routes/api/oauth/github/+server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dev } from '$app/environment';
import { githubAuth } from '$lib/lucia/mysql';
import { githubAuth } from '$lib/server/lucia/mysql';
import { redirect } from '@sveltejs/kit';

export const GET = async ({ cookies }) => {
Expand Down
4 changes: 2 additions & 2 deletions starter/src/routes/api/oauth/github/callback/+server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getUserByEmail } from '$lib/drizzle/mysql/models/users';
import { auth, githubAuth } from '$lib/lucia/mysql';
import { getUserByEmail } from '$lib/server/drizzle/mysql/models/users';
import { auth, githubAuth } from '$lib/server/lucia/mysql';
import { getGitHubPrimaryEmailAddress } from '$lib/utils';
import { OAuthRequestError } from '@lucia-auth/oauth';
import { error } from '@sveltejs/kit';
Expand Down
2 changes: 1 addition & 1 deletion starter/src/routes/api/oauth/google/+server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dev } from '$app/environment';
import { googleAuth } from '$lib/lucia/mysql';
import { googleAuth } from '$lib/server/lucia/mysql';
import { redirect } from '@sveltejs/kit';

export const GET = async ({ cookies }) => {
Expand Down
4 changes: 2 additions & 2 deletions starter/src/routes/api/oauth/google/callback/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
getUserByEmail,
getUserProfileData,
updateUserProfileData
} from '$lib/drizzle/mysql/models/users';
import { auth, googleAuth } from '$lib/lucia/mysql';
} from '$lib/server/drizzle/mysql/models/users';
import { auth, googleAuth } from '$lib/server/lucia/mysql';
import { OAuthRequestError } from '@lucia-auth/oauth';
import { error } from '@sveltejs/kit';
import { nanoid } from 'nanoid';
Expand Down

0 comments on commit 938f1d8

Please sign in to comment.