{"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,"search_vec":"'0.1.8':24 '1':105 'activ':113 'annot':74,94,103 'authent':84 'base':40 'bodi':53 'built':33 'cadenc':110 'class':39,63 'class-bas':38 'class-valid':62 'concern':81 'control':41,66 'core':5,10,21 'cross':79 'cross-cut':78 'cut':80 'decor':28,43 'decorator-driven':27 'del':49 'dp':2,7,18 'dp-koa':1,17 'dp-koa-framework-cor':6 'driven':29 'dto':59 'enabl':37 'environ':99 'execut':95 'extens':73 'framework':4,9,20,32 'get':46 'header':58 'http':69 'inject':52 'irregular':112 'javascript':115 'koa':3,8,19,35 'legaci':91 'lightweight':26 'like':82 'limit':87 'log':83 'maintain':114 'mode':96 'new':93,102 'node.js':30 'param':55 'paramet':51 'post':47 'processor':75 'put':48 'queri':54 'rate':86 'redirect':70 'releas':109 'respons':65 'responsecod':67 'responsehead':68 'rout':45 'session':57 'ship':106 'state':56 'support':89 'switchabl':97 'system':76,104 'type':108 'typescript':107,116 'upgrad':14 'use':61,101 'v2':13 'valid':60,64 'variabl':100 'version':23 'via':98 'web':31","created_at":"2026-04-27T16:58:30.340202+00:00","updated_at":"2026-04-27T16:58:30.340202+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/dp-koa-framework-core","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}