Skip to content

[Chore] Fix Package.json Errors, Add Dev Tooling, and Configure API Proxy for Development #29

Description

@KarenZita01

Description

The current package.json has dependency issues: @typesh/node is misspelled (should be @types/node), and there are no scripts for common development tasks beyond dev/build/start/lint. Additionally, no tools for code generation, API client generation, or contract type generation are configured.

Developer experience gaps:

  • @typesh/node typo in package.json (will cause install warning/error)
  • No npm run format for Prettier
  • No npm run typecheck for TypeScript
  • No npm run analyze for bundle analysis
  • No OpenAPI/client code generation from backend spec
  • No contract type generation from Solidity/Rust ABIs
  • No npm run clean for clearing build artifacts
  • No npm run storybook script
  • No development proxy configuration for backend API
  • No prebuild validation hooks

Technical Context & Impact

  • Affected Components/Files: package.json
  • Impact: Developer friction; broken dependencies; missing essential tooling

Step-by-Step Implementation Guide

  1. Fix package.json errors: Correct @typesh/node to @types/node in devDependencies
  2. Add npm scripts:
    "format": "prettier --write 'src/**/*.{ts,tsx,css}'",
    "format:check": "prettier --check 'src/**/*.{ts,tsx,css}'",
    "typecheck": "tsc --noEmit",
    "clean": "rm -rf .next node_modules",
    "analyze": "ANALYZE=true next build",
    "validate": "npm run typecheck && npm run lint && npm test",
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build",
    "gen:api": "openapi-typescript ../backend/openapi.json -o src/lib/types/api.ts",
    "gen:contracts": "soroban contract bindings typescript --output-dir src/lib/contracts/",
    "dev:proxy": "concurrently \"next dev\" \"tsx proxy.ts\"",
    "postinstall": "husky"
  3. Add dev dependencies: Install concurrently, openapi-typescript, prettier, husky
  4. Configure proxy: next.config.ts with rewrites for backend API in development:
    async rewrites() {
      return [
        { source: '/api/:path*', destination: 'http://localhost:3001/api/:path*' }
      ];
    }
  5. Add contract type generation: Create scripts/generate-contract-types.ts that reads Soroban contract spec and generates TypeScript types
  6. Create .nvmrc: Pin Node.js version (20.x) for consistent development
  7. Set up VS Code launch.json: Debug configurations for Next.js, tests, and API routes
  8. Add package.json validation: Disallow any types in code review checklist

Verification & Testing Steps

  1. Run npm install -> verify no warnings or errors
  2. Run npm run typecheck -> passes with zero errors
  3. Run npm run validate -> lint + typecheck + test all pass
  4. Run npx tsc --noEmit -> passes
  5. Verify API proxy: start backend on 3001 -> start frontend on 3000 -> /api/xxx proxies to 3001
  6. Run npm run clean -> verifies .next and node_modules removed

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions