Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jwt #213

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading