Fix API lint errors blocking CI
eslint has been failing on 11 no-explicit-any errors, which kept the whole pipeline red — including the new publish job that waits on lint. The casts all worked around missing types rather than unknown shapes: - jwt: @fastify/jwt decorates the instance at runtime, so the namespace is not in FastifyInstance's type. Described the parts we call and cast through unknown once, in one place, instead of `as any` at five sites. - permissions: FastifyInstance.db is declared by the db plugin; the cast was stale and hid the real type. - paginate: the querystring schema already validates page/perPage, so the call sites now name that shape via PaginationQuery. Also dropped an unused import and an unused binding whose call is kept for its validation side effect. No behaviour change: eslint and tsc are both clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { users, games, nodes, auditLogs, plugins, pluginReleases } from '@source
|
||||
import { AppError } from '../../lib/errors.js';
|
||||
import { requireSuperAdmin } from '../../lib/permissions.js';
|
||||
import { paginate, paginatedResponse, PaginationQuerySchema } from '../../lib/pagination.js';
|
||||
import type { PaginationQuery } from '../../lib/pagination.js';
|
||||
import { uploadPluginArtifact } from '../../lib/cdn.js';
|
||||
import * as yazl from 'yazl';
|
||||
import {
|
||||
@@ -202,7 +203,7 @@ export default async function adminRoutes(app: FastifyInstance) {
|
||||
|
||||
// GET /api/admin/users
|
||||
app.get('/users', { schema: { querystring: PaginationQuerySchema } }, async (request) => {
|
||||
const { page, perPage, offset, limit } = paginate(request.query as any);
|
||||
const { page, perPage, offset, limit } = paginate(request.query as PaginationQuery);
|
||||
|
||||
const [totalResult] = await app.db.select({ count: count() }).from(users);
|
||||
|
||||
@@ -912,7 +913,7 @@ export default async function adminRoutes(app: FastifyInstance) {
|
||||
|
||||
// GET /api/admin/audit-logs
|
||||
app.get('/audit-logs', { schema: { querystring: PaginationQuerySchema } }, async (request) => {
|
||||
const { page, perPage, offset, limit } = paginate(request.query as any);
|
||||
const { page, perPage, offset, limit } = paginate(request.query as PaginationQuery);
|
||||
|
||||
const [totalResult] = await app.db.select({ count: count() }).from(auditLogs);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { eq } from 'drizzle-orm';
|
||||
import { users } from '@source/database';
|
||||
import { hashPassword, verifyPassword } from '../../lib/password.js';
|
||||
import { signAccessToken, signRefreshToken, verifyRefreshToken } from '../../lib/jwt.js';
|
||||
import type { AccessTokenPayload, RefreshTokenPayload } from '../../lib/jwt.js';
|
||||
import type { RefreshTokenPayload } from '../../lib/jwt.js';
|
||||
import { AppError } from '../../lib/errors.js';
|
||||
import { RegisterSchema, LoginSchema } from './schemas.js';
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { organizations, organizationMembers, users } from '@source/database';
|
||||
import { AppError } from '../../lib/errors.js';
|
||||
import { requirePermission, getOrgMembership } from '../../lib/permissions.js';
|
||||
import { paginate, paginatedResponse, PaginationQuerySchema } from '../../lib/pagination.js';
|
||||
import type { PaginationQuery } from '../../lib/pagination.js';
|
||||
import { createAuditLog } from '../../lib/audit.js';
|
||||
import {
|
||||
CreateOrgSchema,
|
||||
@@ -20,7 +21,7 @@ export default async function organizationRoutes(app: FastifyInstance) {
|
||||
|
||||
// GET /api/organizations — list user's organizations
|
||||
app.get('/', { schema: { querystring: PaginationQuerySchema } }, async (request) => {
|
||||
const { page, perPage, offset, limit } = paginate(request.query as any);
|
||||
const { page, perPage, offset, limit } = paginate(request.query as PaginationQuery);
|
||||
const userId = request.user.sub;
|
||||
|
||||
if (request.user.isSuperAdmin) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { GameAutomationRule, PowerAction, ServerAutomationEvent } from '@so
|
||||
import { AppError } from '../../lib/errors.js';
|
||||
import { requirePermission } from '../../lib/permissions.js';
|
||||
import { paginate, paginatedResponse, PaginationQuerySchema } from '../../lib/pagination.js';
|
||||
import type { PaginationQuery } from '../../lib/pagination.js';
|
||||
import { createAuditLog } from '../../lib/audit.js';
|
||||
import {
|
||||
deleteFivemQbCoreDatabase,
|
||||
@@ -637,7 +638,7 @@ export default async function serverRoutes(app: FastifyInstance) {
|
||||
const { orgId } = request.params as { orgId: string };
|
||||
await requirePermission(request, orgId, 'server.read');
|
||||
|
||||
const { page, perPage, offset, limit } = paginate(request.query as any);
|
||||
const { page, perPage, offset, limit } = paginate(request.query as PaginationQuery);
|
||||
|
||||
const [totalResult] = await app.db
|
||||
.select({ count: count() })
|
||||
|
||||
@@ -874,7 +874,9 @@ export default async function pluginRoutes(app: FastifyInstance) {
|
||||
app.get('/', { schema: ParamSchema }, async (request) => {
|
||||
const { orgId, serverId } = request.params as { orgId: string; serverId: string };
|
||||
await requirePermission(request, orgId, 'plugin.read');
|
||||
const context = await getServerPluginContext(app, orgId, serverId);
|
||||
// Called for its validation of the server and the caller's access to it;
|
||||
// this endpoint does not need the returned context.
|
||||
await getServerPluginContext(app, orgId, serverId);
|
||||
|
||||
const installed = await app.db
|
||||
.select({
|
||||
|
||||
Reference in New Issue
Block a user