fix: resolve server TS errors — jwt type augmentation, sign options, services import

bump version to 0.3.1
This commit is contained in:
NixReaper
2026-04-05 12:13:06 -05:00
parent 2fce30eddc
commit e8a69f83d7
3 changed files with 9 additions and 9 deletions
+3 -4
View File
@@ -28,7 +28,7 @@ function signTokens(
const refreshToken = fastify.jwt.sign(
{ ...payload, type: 'refresh' },
{ secret: config.jwt.refreshSecret, expiresIn: config.jwt.refreshExpiresIn }
{ expiresIn: config.jwt.refreshExpiresIn }
)
return { accessToken, refreshToken }
@@ -157,8 +157,7 @@ export default async function authRoutes(fastify: FastifyInstance) {
let payload: JwtPayload & { type?: string }
try {
payload = fastify.jwt.verify<JwtPayload & { type?: string }>(
body.data.refreshToken,
{ secret: config.jwt.refreshSecret }
body.data.refreshToken
)
} catch {
return reply.code(401).send({ success: false, error: 'Invalid or expired refresh token' })
@@ -183,7 +182,7 @@ export default async function authRoutes(fastify: FastifyInstance) {
const accessToken = fastify.jwt.sign(newPayload, { expiresIn: config.jwt.expiresIn })
const newRefresh = fastify.jwt.sign(
{ ...newPayload, type: 'refresh' },
{ secret: config.jwt.refreshSecret, expiresIn: config.jwt.refreshExpiresIn }
{ expiresIn: config.jwt.refreshExpiresIn }
)
const expiresAt = new Date()
+1 -1
View File
@@ -1,7 +1,7 @@
import type { FastifyInstance } from 'fastify'
import { z } from 'zod'
import { requireAdmin } from '../../middleware/auth.js'
import { exec, MANAGED_SERVICES as _ } from '../../core/exec.js'
import { exec } from '../../core/exec.js'
import { getServiceStatus, MANAGED_SERVICES } from '../../core/system.js'
const ServiceActionSchema = z.object({
+5 -4
View File
@@ -10,11 +10,12 @@ export interface JwtPayload {
exp?: number
}
// ─── Fastify type augmentation ────────────────────────────────────────────────
// ─── @fastify/jwt type augmentation ───────────────────────────────────────────
declare module 'fastify' {
interface FastifyRequest {
user?: JwtPayload
declare module '@fastify/jwt' {
interface FastifyJWT {
payload: JwtPayload
user: JwtPayload
}
}