refactor: migrate packages/server from MJS to TypeScript #4

Merged
xiaonuo merged 3 commits from fix/2-migrate-server-to-typescript into main 2026-05-28 14:54:01 +00:00
Owner

What

Migrate packages/server from .mjs to TypeScript.

Changes

  • src/index.mjs → src/index.ts
  • src/protocol.mjs → src/protocol.ts
  • New: src/types.ts, src/logger.ts
  • Added tsconfig.json
  • Added migration tests

Ref

Fixes #2

## What Migrate packages/server from .mjs to TypeScript. ## Changes - src/index.mjs → src/index.ts - src/protocol.mjs → src/protocol.ts - New: src/types.ts, src/logger.ts - Added tsconfig.json - Added migration tests ## Ref Fixes #2
xiaonuo added 3 commits 2026-05-28 14:53:53 +00:00
- Created tsconfig.json with strict mode enabled
- Added comprehensive type definitions in types.ts
- Migrated protocol.mjs to protocol.ts with const assertions
- Migrated index.mjs to index.ts with full type annotations
- Updated package.json with TypeScript build script and type exports
- Added @types/express and @types/ws devDependencies
- Created comprehensive test suite with 28 tests covering:
  - Type safety and strict null checks
  - Protocol constants with literal types
  - Build configuration validation
  - Module exports and imports
  - Data structure validation
  - Type safety enforcement
- All tests passing, build succeeds with no errors
- Zero implicit any types, full type safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Applied biome auto-fix to resolve all 5 formatting/linting errors
- Fixed import sorting in index.ts, protocol.ts, and migration.test.ts
- Fixed typeof expression parentheses in protocol.ts
- Created logger.ts utility with createLogger function
- Replaced console.log with logger.info for production code
- All biome checks passing, TypeScript compilation successful
- All 28 tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
chore: remove old .mjs files after TypeScript migration
CI / check (pull_request) Successful in 4m39s
3a75cc9136
小橘 <xiaoju@shazhou.work>
xiaonuo force-pushed fix/2-migrate-server-to-typescript from b67e09578c to 3a75cc9136 2026-05-28 14:53:53 +00:00 Compare
xiaonuo merged commit 0b76491d7d into main 2026-05-28 14:54:01 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/worker-dashboard#4