This commit enhances type safety and fixes type-related issues throughout the project including: - Updated type definitions in entities, repositories, and models - Improved type annotations in services and controllers - Fixed type issues in adapters and utilities - Enhanced test file type definitions - Added typings/index.d.ts for global type declarations 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import {
|
|
type EggContext,
|
|
Context,
|
|
HTTPController,
|
|
HTTPMethod,
|
|
HTTPMethodEnum,
|
|
HTTPQuery,
|
|
Inject,
|
|
} from '@eggjs/tegg';
|
|
|
|
import { AbstractController } from '../AbstractController.ts';
|
|
import type { FixNoPaddingVersionService } from '../../../core/service/FixNoPaddingVersionService.ts';
|
|
|
|
@HTTPController()
|
|
export class PaddingVersionController extends AbstractController {
|
|
@Inject()
|
|
private readonly fixNoPaddingVersionService: FixNoPaddingVersionService;
|
|
|
|
@HTTPMethod({
|
|
method: HTTPMethodEnum.PUT,
|
|
path: '/-/admin/npm/fixPaddingVersion',
|
|
})
|
|
async fixNoPaddingVersion(
|
|
@Context() ctx: EggContext,
|
|
@HTTPQuery() id: string
|
|
) {
|
|
const isAdmin = await this.userRoleManager.isAdmin(ctx);
|
|
if (!isAdmin) {
|
|
return {
|
|
ok: false,
|
|
error: 'only admin can do this',
|
|
};
|
|
}
|
|
let idNum: number | undefined;
|
|
if (id) {
|
|
idNum = Number.parseInt(id);
|
|
if (Number.isNaN(idNum)) {
|
|
return {
|
|
ok: false,
|
|
error: `id is not a number ${id}`,
|
|
};
|
|
}
|
|
}
|
|
await this.fixNoPaddingVersionService.fixPaddingVersion(idNum);
|
|
return {
|
|
ok: true,
|
|
};
|
|
}
|
|
}
|