Files
cnpmcore/app/port/controller/admin/PaddingVersionController.ts
MK (fengmk2) e5162f20aa fix: improve TypeScript type definitions across codebase (#844)
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>
2025-10-23 00:58:59 +08:00

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,
};
}
}