Skip to content

Commit

Permalink
change to env
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Mar 31, 2024
1 parent 5b18b4e commit 509f576
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/api/auth/signin.post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jsonwebtoken from 'jsonwebtoken'
import { JWT_KEY } from '~/server/utils/utils'

export default defineEventHandler(async (event) => {
const { JWT_KEY } = useRuntimeConfig(event)
const token = jsonwebtoken.sign({
name: 'Yunus',
userId: 1,
Expand Down
2 changes: 1 addition & 1 deletion server/middleware/auth-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jsonwebtoken from 'jsonwebtoken'
import { JWT_KEY } from '../utils/utils';

type AuthData = {
userId: number,
Expand All @@ -14,7 +15,6 @@ declare module 'h3' {
export default defineEventHandler((event) => {
const appAuth = getCookie(event, 'app-auth')
if (appAuth) {
const { JWT_KEY } = useRuntimeConfig(event)
const verifiedData = jsonwebtoken.verify(appAuth, JWT_KEY)
// if (!verifiedData) {
// deleteCookie(event, 'app-auth')
Expand Down
2 changes: 2 additions & 0 deletions server/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const normalizeName = (value: string): string => {
return value.replaceAll(' ', '-')
}

export const JWT_KEY = process.env.JWT_KEY!

0 comments on commit 509f576

Please sign in to comment.