Skip to content

Commit

Permalink
fix: jwt (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 authored Aug 22, 2024
1 parent 6d83c3e commit 302c404
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/website/src/server/api/auth/me.get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jwt, { verify } from 'jsonwebtoken'
import jwt from 'jsonwebtoken'
import type { WebsiteProfile } from '@chat-game/types'

export default defineEventHandler((event) => {
Expand All @@ -13,7 +13,7 @@ export default defineEventHandler((event) => {
}

try {
const { profile } = verify(token, jwtSecretKey) as { profile: WebsiteProfile }
const { profile } = jwt.verify(token, jwtSecretKey) as { profile: WebsiteProfile }
return profile
} catch (error) {
if (error instanceof jwt.TokenExpiredError) {
Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/server/api/auth/twitch.get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sign } from 'jsonwebtoken'
import jwt from 'jsonwebtoken'
import type { WebsiteProfile } from '@chat-game/types'

export default defineEventHandler((event) => {
Expand All @@ -23,7 +23,7 @@ export default defineEventHandler((event) => {
userName: 'tester',
}

const token = sign({ profile }, jwtSecretKey, { expiresIn: '48h' })
const token = jwt.sign({ profile }, jwtSecretKey, { expiresIn: '48h' })

setCookie(event, publicEnv.cookieKey, token, {
path: '/',
Expand Down
11 changes: 4 additions & 7 deletions apps/website/src/server/plugins/start.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { twitchController } from '../utils/twitch/twitch.controller'
import { twitchAddonController } from '../utils/twitch/twitch.addon.controller'
import { twitchWoodlandController } from '../utils/twitch/twitch.woodland.controller'
import { twitchProvider } from '../utils/twitch/twitch.provider'

export default defineNitroPlugin(() => {
void twitchController.serve()
void twitchController.serveStreamOnline()
void twitchAddonController.serve()
void twitchWoodlandController.serve()
// void twitchController.serve()
// void twitchController.serveStreamOnline()
// void twitchAddonController.serve()
// void twitchWoodlandController.serve()

setTimeout(checkIfStreamingNow, 5000)
})
Expand Down

0 comments on commit 302c404

Please sign in to comment.