{"id":21181,"library":"dp-koa-framework-core","title":"DP-Koa Framework Core","description":"dp-koa-framework-core is a v2 upgrade of the DP-Koa framework core at version 0.1.8, a lightweight, decorator-driven Node.js web framework built on Koa. It enables class-based controllers with decorators for routing (@Get, @Post, @Put, @Del, @All), parameter injection (@Body, @Query, @Params, @State, @Session, @Headers), DTO validation using class-validator, response control (@ResponseCode, @ResponseHeader), HTTP redirects, and an extensible annotation processor system for cross-cutting concerns like logging, authentication, and rate limiting. It supports both legacy and new annotation execution modes switchable via environment variable (USE_NEW_ANNOTATION_SYSTEM=1). Ships TypeScript types. Release cadence is irregular; actively maintained.","status":"active","version":"0.1.8","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install dp-koa-framework-core","lang":"bash","label":"npm"},{"cmd":"yarn add dp-koa-framework-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add dp-koa-framework-core","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Koa web framework","package":"koa","optional":false},{"reason":"Used internally by bindRouter for route generation","package":"koa-router","optional":true},{"reason":"Required for DTO validation in parameter decorators","package":"class-validator","optional":true},{"reason":"Used with class-validator for @Transform decorator","package":"class-transformer","optional":true}],"imports":[{"note":"Get is exported from the main entry; no subpath import.","wrong":"import { Get } from 'dp-koa-framework-core/decorators'","symbol":"Get","correct":"import { Get } from 'dp-koa-framework-core'"},{"note":"ESM-only; CommonJS require is unsupported.","wrong":"const { bindRouter } = require('dp-koa-framework-core')","symbol":"bindRouter","correct":"import { bindRouter } from 'dp-koa-framework-core'"},{"note":"bootstrap is a named export from the main module.","wrong":"import { bootstrap } from 'dp-koa-framework-core/bootstrap'","symbol":"bootstrap","correct":"import { bootstrap } from 'dp-koa-framework-core'"},{"note":"Used to programmatically initialize new annotation system.","wrong":"","symbol":"MigrationHelper","correct":"import { MigrationHelper } from 'dp-koa-framework-core'"},{"note":"An instance of koa-router, configured by bindRouter.","wrong":"","symbol":"router","correct":"import { router } from 'dp-koa-framework-core'"}],"quickstart":{"code":"import Koa from 'koa';\nimport bodyParser from 'koa-bodyparser';\nimport { bindRouter, router, Get, Query, bootstrap, logger } from 'dp-koa-framework-core';\n\nclass HelloController {\n  @Get('/hello')\n  async hello(@Query() query: any) {\n    return { code: 0, data: { message: 'hello', query } };\n  }\n}\n\nasync function main() {\n  const app = new Koa();\n  app.use(bodyParser());\n  bindRouter('', HelloController);\n  app.use(router.routes()).use(router.allowedMethods());\n  const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;\n  app.listen(port, () => logger.info(`listening on :${port}`));\n}\n\nmain();","lang":"typescript","description":"Shows minimal setup: import core decorators and utilities, define a controller with @Get and @Query, bind routes, and start Koa app."},"warnings":[{"fix":"Set process.env.USE_NEW_ANNOTATION_SYSTEM = '1' or call MigrationHelper.initializeNewSystem() if you intend to use processors (Logging, Permission, etc.).","message":"v2 uses new annotation system by default? Check environment variable USE_NEW_ANNOTATION_SYSTEM. Old system is default (0). Set to 1 to enable processor-based annotation execution. Some decorators may behave differently.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Enable new system and test all decorators for compatibility. See MigrationHelper.","message":"The old annotation system (default) may be removed in future major versions. Users should migrate to new processor-based system.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"npm install class-validator class-transformer","message":"DTO validation requires both class-validator and class-transformer as dependencies. They are not shipped with the package; must be installed separately.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always use import { Get } from 'dp-koa-framework-core'.","message":"Do NOT mix named and default imports for decorators. All common decorators (Get, Post, etc.) are named exports only.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use: return redirect(url, { status: 302 }); not return { data: redirect(...) }.","message":"The redirect() function returns a special object, not a plain JSON. Ensure your controller returns redirect(...) directly; do not wrap in another object.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install dp-koa-framework-core","cause":"Package not installed or import path is incorrect.","error":"Cannot find module 'dp-koa-framework-core'"},{"fix":"Change require('dp-koa-framework-core').bindRouter to import { bindRouter } from 'dp-koa-framework-core'.","cause":"Using CommonJS require instead of ESM import.","error":"TypeError: bindRouter is not a function"},{"fix":"Add @Transform((v) => Number(v)) and ensure class-validator and class-transformer are installed.","cause":"DTO property is string but @Transform was omitted or class-validator not installed.","error":"Validation failed for DTO: page must be an integer"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}