Skip to content
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
13 changes: 10 additions & 3 deletions src/auth/jwt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { validateJwtSecret } from "./jwt-secret.validator";

export interface JwtPayload {
walletAddress: string;
type?: "access" | "refresh";
role?: string;
admin?: boolean;
iss?: string;
Expand Down Expand Up @@ -52,7 +53,7 @@ export class JwtService {
* Token expires in 1 hour.
*/
sign(walletAddress: string): string {
const payload: JwtPayload = { walletAddress, jti: crypto.randomUUID() };
const payload: JwtPayload = { walletAddress, type: "access", jti: crypto.randomUUID() };
const options: jwt.SignOptions = {
algorithm: 'HS256',
expiresIn: '1h',
Expand All @@ -71,7 +72,7 @@ export class JwtService {
* Token expires in 1 hour.
*/
signWithRole(walletAddress: string, role: string, admin = false): string {
const payload: JwtPayload = { walletAddress, role, admin, jti: crypto.randomUUID() };
const payload: JwtPayload = { walletAddress, type: "access", role, admin, jti: crypto.randomUUID() };
const options: jwt.SignOptions = {
algorithm: 'HS256',
expiresIn: '1h',
Expand All @@ -97,9 +98,15 @@ export class JwtService {
algorithms: ['HS256'],
issuer: this.issuer,
audience: this.audience,
}) as JwtPayload & { jti?: string };
}) as JwtPayload & { jti?: string; type?: string };

if (decoded.type === "refresh") {
throw new UnauthorizedException("Cannot use refresh token as access token");
}

return {
walletAddress: decoded.walletAddress,
type: decoded.type,
role: decoded.role,
admin: decoded.admin,
};
Expand Down
3 changes: 3 additions & 0 deletions src/health/health.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ export class HealthController {
} else {
// #421 — Report waiting job counts for known Bull queues so ops can
// detect build-up before processing latency becomes user-visible.
// #695 — verify active Redis connectivity via PING before querying queue keys
await this.withTimeout(this.redis.ping(), 'Redis PING');

const queueNames = (this.config.get<string>('HEALTH_QUEUE_NAMES') ?? 'claims,oracle')
.split(',')
.map(n => n.trim())
Expand Down
10 changes: 10 additions & 0 deletions src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export class PrismaService extends PrismaClient implements OnModuleInit, OnModul
}

async onModuleInit() {
// #696 — Handle SIGTERM / SIGINT signals gracefully
process.once('SIGTERM', async () => {
this.logger.log('SIGTERM signal received: disconnecting Prisma client...');
await this.onModuleDestroy();
});
process.once('SIGINT', async () => {
this.logger.log('SIGINT signal received: disconnecting Prisma client...');
await this.onModuleDestroy();
});

const maxRetries = 5;
let delayMs = 1000;
for (let attempt = 1; attempt <= maxRetries; attempt++) {
Expand Down
Loading