-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setup s3, fiexed i18n and started auth
- Loading branch information
1 parent
7a0a8f3
commit e8f618b
Showing
24 changed files
with
275 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
import { env } from '@/env'; | ||
|
||
const connectionString = `postgresql://${env.DATABASE_USER}:${env.DATABASE_PASSWORD}@${env.DATABASE_HOST}:${env.DATABASE_PORT}/${env.DATABASE_NAME}`; | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
export default defineConfig({ | ||
schema: './src/server/db/schema/*.ts', | ||
dialect: 'postgresql', | ||
dbCredentials: { | ||
url: connectionString, | ||
url: `postgresql://${env.DATABASE_USER}:${env.DATABASE_PASSWORD}@${env.DATABASE_HOST}:${env.DATABASE_PORT}/${env.DATABASE_NAME}`, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
'use client'; | ||
|
||
import { routing } from '@/lib/locale'; | ||
import { redirect, usePathname } from 'next/navigation'; | ||
|
||
import { defaultLocale } from '@/lib/locale/config'; | ||
|
||
export default function NotFound() { | ||
const pathname = usePathname(); | ||
redirect(`/${defaultLocale}${pathname}`); | ||
redirect(`/${routing.defaultLocale}/${pathname}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import { routing } from '@/lib/locale'; | ||
import { getRequestConfig } from 'next-intl/server'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
export default getRequestConfig(async ({ locale }) => ({ | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
messages: (await import(`../../../messages/${locale}.json`)) | ||
.default as Messages, | ||
})); | ||
export default getRequestConfig(async ({ locale }) => { | ||
// @ts-ignore | ||
if (!routing.locales.includes(locale)) notFound(); | ||
return { | ||
messages: (await import(`../../../messages/${locale}.json`)) | ||
.default as Messages, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { GB, NO } from 'country-flag-icons/react/1x1'; | ||
import { defineRouting } from 'next-intl/routing'; | ||
|
||
export const localeIcons = { en: GB, no: NO }; | ||
|
||
export const routing = defineRouting({ | ||
locales: ['en', 'no'], | ||
defaultLocale: 'no', | ||
localePrefix: 'as-needed', | ||
pathnames: { | ||
'/': '/', | ||
'/events': { | ||
en: '/events', | ||
no: '/arrangementer', | ||
}, | ||
'/news': { | ||
en: '/news', | ||
no: '/nyheter', | ||
}, | ||
'/news/new': { | ||
en: '/news/new', | ||
no: '/nyheter/ny', | ||
}, | ||
'/news/[article]': { | ||
en: '/news/[article]', | ||
no: '/nyheter/[article]', | ||
}, | ||
'/about': { | ||
en: '/about', | ||
no: '/om-oss', | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { routing } from '@/lib/locale'; | ||
import { createLocalizedPathnamesNavigation } from 'next-intl/navigation'; | ||
|
||
import { localePrefix, locales, pathnames } from '@/lib/locale/config'; | ||
|
||
export const { Link, redirect, usePathname, useRouter, getPathname } = | ||
createLocalizedPathnamesNavigation({ locales, localePrefix, pathnames }); | ||
createLocalizedPathnamesNavigation(routing); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { env } from '@/env'; | ||
import { db } from '@/server/db'; | ||
import { sessions, users } from '@/server/db/schema'; | ||
import { DrizzlePostgreSQLAdapter } from '@lucia-auth/adapter-drizzle'; | ||
import { Lucia } from 'lucia'; | ||
|
||
const adapter = new DrizzlePostgreSQLAdapter(db, sessions, users); | ||
|
||
export const auth = new Lucia(adapter, { | ||
sessionCookie: { | ||
// this sets cookies with super long expiration | ||
// since Next.js doesn't allow Lucia to extend cookie expiration when rendering pages | ||
expires: false, | ||
attributes: { | ||
// set to `true` when using HTTPS | ||
secure: env.NODE_ENV === 'production', | ||
}, | ||
}, | ||
getUserAttributes: (attributes) => { | ||
return { | ||
// attributes has the type of DatabaseUserAttributes | ||
username: attributes.username, | ||
}; | ||
}, | ||
}); | ||
|
||
export * from './user'; | ||
|
||
// IMPORTANT! | ||
declare module 'lucia' { | ||
// Has to be an interface | ||
interface Register { | ||
Lucia: typeof auth; | ||
UserId: number; | ||
DatabaseUserAttributes: DatabaseUserAttributes; | ||
} | ||
} | ||
|
||
type DatabaseUserAttributes = { | ||
username: string; | ||
}; |
Oops, something went wrong.