Skip to content

Commit

Permalink
feat: 集成 cookie & session 中间件
Browse files Browse the repository at this point in the history
  • Loading branch information
nonhana committed Nov 21, 2024
1 parent ef16d06 commit b6d43f2
Show file tree
Hide file tree
Showing 14 changed files with 419 additions and 419 deletions.
4 changes: 2 additions & 2 deletions lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import process from 'node:process'
import { PrismaClient } from '@prisma/client'
import env from '~/server/env/dotenv'

function prismaClientSingleton() {
return new PrismaClient()
Expand All @@ -14,5 +14,5 @@ const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()

export default prisma

if (process.env.NODE_ENV !== 'production')
if (env.NODE_ENV !== 'production')
globalThis.prismaGlobal = prisma
27 changes: 2 additions & 25 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,8 @@ export default defineNuxtConfig({
preload: true,
download: true,
},
auth: {
isEnabled: true,
disableServerSideAuth: false,
originEnvKey: 'HANA_AUTH_ORIGIN',
baseURL: 'http://localhost:2408/api/auth',
provider: {
type: 'local',
endpoints: {
signIn: { path: '/login', method: 'post' },
signOut: { path: '/logout', method: 'post' },
signUp: { path: '/register', method: 'post' },
getSession: { path: '/session', method: 'get' },
},
refresh: {
isEnabled: true,
endpoint: { path: '/refresh', method: 'post' },
refreshOnlyToken: true,
token: {
signInResponseRefreshTokenPointer: '/refresh-token',
refreshRequestTokenPointer: '/refresh-token',
maxAgeInSeconds: 60 * 60 * 24 * 7,
},
},
},
runtimeConfig: {
sessionKey: '',
},
modules: [
'@nuxtjs/tailwindcss',
Expand All @@ -114,7 +92,6 @@ export default defineNuxtConfig({
'@nuxtjs/seo',
'@vueuse/nuxt',
'@pinia/nuxt',
'@sidebase/nuxt-auth',
],
plugins: ['~/plugins/directives.ts'],
devtools: { enabled: true },
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,29 @@
"@nuxtjs/tailwindcss": "^6.12.1",
"@pinia/nuxt": "^0.6.1",
"@prisma/client": "^5.22.0",
"@sidebase/nuxt-auth": "^0.9.4",
"@quixo3/prisma-session-store": "^3.1.13",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"@types/bcrypt": "^5.0.2",
"@types/express-session": "^1.18.0",
"@types/node": "^22.7.4",
"@types/vivus": "^0.4.7",
"@vueuse/core": "^11.1.0",
"@vueuse/nuxt": "^11.1.0",
"bcrypt": "^5.1.1",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"eslint": "^9.12.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"express-session": "^1.18.1",
"gsap": "^3.12.5",
"nuxt-lodash": "^2.5.3",
"pinia": "^2.2.5",
"prisma": "5.22.0",
"sass": "^1.79.4",
"sharp": "^0.33.5",
"typescript": "~5.5.4",
"vivus": "^0.4.6"
"vivus": "^0.4.6",
"zod": "^3.23.8"
}
}
Loading

0 comments on commit b6d43f2

Please sign in to comment.