[{"data":1,"prerenderedAt":2295},["ShallowReactive",2],{"navigation":3,"\u002Fblog\u002Fmiiajs-0-9":195},[4,25,98,177],{"title":5,"path":6,"stem":7,"children":8,"status":11,"icon":24},"Getting Started","\u002Fdocs\u002Fgetting-started","1.docs\u002F1.getting-started\u002F1.index",[9,12,16,20],{"title":10,"path":6,"stem":7,"status":11},"Introduction",null,{"title":13,"path":14,"stem":15,"status":11},"Installation","\u002Fdocs\u002Fgetting-started\u002Finstallation","1.docs\u002F1.getting-started\u002F2.installation",{"title":17,"path":18,"stem":19,"status":11},"Quick Start","\u002Fdocs\u002Fgetting-started\u002Fquick-start","1.docs\u002F1.getting-started\u002F3.quick-start",{"title":21,"path":22,"stem":23,"status":11},"Coming from NestJS","\u002Fdocs\u002Fgetting-started\u002Fcoming-from-nest","1.docs\u002F1.getting-started\u002F4.coming-from-nest",false,{"title":26,"path":27,"stem":28,"children":29,"status":11,"icon":24},"Core Concepts","\u002Fdocs\u002Fcore-concepts","1.docs\u002F2.core-concepts\u002F01.index",[30,32,36,40,44,48,52,56,60,64,68,72,76,86,90,94],{"title":31,"path":27,"stem":28,"status":11},"Overview",{"title":33,"path":34,"stem":35,"status":11},"Controllers","\u002Fdocs\u002Fcore-concepts\u002Fcontrollers","1.docs\u002F2.core-concepts\u002F02.controllers",{"title":37,"path":38,"stem":39,"status":11},"Routing","\u002Fdocs\u002Fcore-concepts\u002Frouting","1.docs\u002F2.core-concepts\u002F03.routing",{"title":41,"path":42,"stem":43,"status":11},"Providers","\u002Fdocs\u002Fcore-concepts\u002Fproviders","1.docs\u002F2.core-concepts\u002F04.providers",{"title":45,"path":46,"stem":47,"status":11},"Modules","\u002Fdocs\u002Fcore-concepts\u002Fmodules","1.docs\u002F2.core-concepts\u002F05.modules",{"title":49,"path":50,"stem":51,"status":11},"Configuration","\u002Fdocs\u002Fcore-concepts\u002Fconfiguration","1.docs\u002F2.core-concepts\u002F06.configuration",{"title":53,"path":54,"stem":55,"status":11},"Middleware","\u002Fdocs\u002Fcore-concepts\u002Fmiddleware","1.docs\u002F2.core-concepts\u002F07.middleware",{"title":57,"path":58,"stem":59,"status":11},"Guards","\u002Fdocs\u002Fcore-concepts\u002Fguards","1.docs\u002F2.core-concepts\u002F08.guards",{"title":61,"path":62,"stem":63,"status":11},"Exceptions","\u002Fdocs\u002Fcore-concepts\u002Fexceptions","1.docs\u002F2.core-concepts\u002F09.exceptions",{"title":65,"path":66,"stem":67,"status":11},"Response","\u002Fdocs\u002Fcore-concepts\u002Fresponse","1.docs\u002F2.core-concepts\u002F10.response",{"title":69,"path":70,"stem":71,"status":11},"Cookies","\u002Fdocs\u002Fcore-concepts\u002Fcookies","1.docs\u002F2.core-concepts\u002F11.cookies",{"title":73,"path":74,"stem":75,"status":11},"Testing","\u002Fdocs\u002Fcore-concepts\u002Ftesting","1.docs\u002F2.core-concepts\u002F12.testing",{"title":77,"path":78,"stem":79,"children":80,"status":11,"icon":24,"defaultOpen":24},"Decorators","\u002Fdocs\u002Fcore-concepts\u002Fdecorators","1.docs\u002F2.core-concepts\u002F13.decorators\u002F1.index",[81,82],{"title":31,"path":78,"stem":79,"status":11},{"title":83,"path":84,"stem":85,"status":11},"Custom","\u002Fdocs\u002Fcore-concepts\u002Fdecorators\u002Fcustom","1.docs\u002F2.core-concepts\u002F13.decorators\u002F2.custom",{"title":87,"path":88,"stem":89,"status":11},"Discovery Service","\u002Fdocs\u002Fcore-concepts\u002Fdiscovery","1.docs\u002F2.core-concepts\u002F14.discovery",{"title":91,"path":92,"stem":93,"status":11},"Application Lifecycle","\u002Fdocs\u002Fcore-concepts\u002Fapp-lifecycle","1.docs\u002F2.core-concepts\u002F15.app-lifecycle",{"title":95,"path":96,"stem":97,"status":11},"Logger","\u002Fdocs\u002Fcore-concepts\u002Flogger","1.docs\u002F2.core-concepts\u002F16.logger",{"title":99,"path":100,"stem":101,"children":102,"status":11,"icon":24},"Packages","\u002Fdocs\u002Fpackages","1.docs\u002F3.packages\u002F01.index",[103,104,123,127,131,135,139,143,147,151,155,165,169,173],{"title":31,"path":100,"stem":101,"status":11},{"title":105,"path":106,"stem":107,"children":108,"status":11,"icon":24,"defaultOpen":24},"Auth","\u002Fdocs\u002Fpackages\u002Fauth","1.docs\u002F3.packages\u002F02.auth\u002F1.index",[109,110,114,118],{"title":31,"path":106,"stem":107,"status":11},{"title":111,"path":112,"stem":113,"status":11},"JWT Provider","\u002Fdocs\u002Fpackages\u002Fauth\u002Fjwt","1.docs\u002F3.packages\u002F02.auth\u002F2.jwt",{"title":115,"path":116,"stem":117,"status":11},"Local Provider","\u002Fdocs\u002Fpackages\u002Fauth\u002Flocal","1.docs\u002F3.packages\u002F02.auth\u002F3.local",{"title":119,"path":120,"stem":121,"status":122},"OAuth2 Provider","\u002Fdocs\u002Fpackages\u002Fauth\u002Foauth2","1.docs\u002F3.packages\u002F02.auth\u002F4.oauth2","experimental",{"title":124,"path":125,"stem":126,"status":11},"JWT","\u002Fdocs\u002Fpackages\u002Fjwt","1.docs\u002F3.packages\u002F03.jwt",{"title":128,"path":129,"stem":130,"status":11},"Drizzle","\u002Fdocs\u002Fpackages\u002Fdrizzle","1.docs\u002F3.packages\u002F04.drizzle",{"title":132,"path":133,"stem":134,"status":11},"Papr","\u002Fdocs\u002Fpackages\u002Fpapr","1.docs\u002F3.packages\u002F05.papr",{"title":136,"path":137,"stem":138,"status":11},"Mongoose","\u002Fdocs\u002Fpackages\u002Fmongoose","1.docs\u002F3.packages\u002F06.mongoose",{"title":140,"path":141,"stem":142,"status":11},"Swagger","\u002Fdocs\u002Fpackages\u002Fswagger","1.docs\u002F3.packages\u002F07.swagger",{"title":144,"path":145,"stem":146,"status":11},"Node Server","\u002Fdocs\u002Fpackages\u002Fnode-server","1.docs\u002F3.packages\u002F08.node-server",{"title":148,"path":149,"stem":150,"status":11},"uWS Server","\u002Fdocs\u002Fpackages\u002Fuws-server","1.docs\u002F3.packages\u002F09.uws-server",{"title":152,"path":153,"stem":154,"status":11},"CLI","\u002Fdocs\u002Fpackages\u002Fcli","1.docs\u002F3.packages\u002F10.cli",{"title":156,"path":157,"stem":158,"children":159,"status":11,"icon":24,"defaultOpen":24},"Events","\u002Fdocs\u002Fpackages\u002Fmessaging","1.docs\u002F3.packages\u002F11.messaging\u002F1.index",[160,161],{"title":31,"path":157,"stem":158,"status":11},{"title":162,"path":163,"stem":164,"status":122},"Redis","\u002Fdocs\u002Fpackages\u002Fmessaging\u002Fredis","1.docs\u002F3.packages\u002F11.messaging\u002F2.redis",{"title":166,"path":167,"stem":168,"status":11},"Serve Static","\u002Fdocs\u002Fpackages\u002Fserve-static","1.docs\u002F3.packages\u002F12.serve-static",{"title":170,"path":171,"stem":172,"status":11},"Rate Limit","\u002Fdocs\u002Fpackages\u002Frate-limit","1.docs\u002F3.packages\u002F13.rate-limit",{"title":174,"path":175,"stem":176,"status":11},"Multipart","\u002Fdocs\u002Fpackages\u002Fmultipart","1.docs\u002F3.packages\u002F14.multipart",{"title":178,"path":179,"stem":180,"children":181,"status":11,"icon":24},"Roadmap","\u002Fdocs\u002Froadmap","1.docs\u002F4.roadmap\u002F1.index",[182,183,187,191],{"title":31,"path":179,"stem":180,"status":11},{"title":184,"path":185,"stem":186,"status":11},"Short term (0-3 months)","\u002Fdocs\u002Froadmap\u002Fshort-term","1.docs\u002F4.roadmap\u002F2.short-term",{"title":188,"path":189,"stem":190,"status":11},"Mid term (3-9 months)","\u002Fdocs\u002Froadmap\u002Fmid-term","1.docs\u002F4.roadmap\u002F3.mid-term",{"title":192,"path":193,"stem":194,"status":11},"Long term (9-12+ months)","\u002Fdocs\u002Froadmap\u002Flong-term","1.docs\u002F4.roadmap\u002F4.long-term",{"id":196,"title":197,"author":198,"body":199,"date":2277,"description":2278,"discussion":11,"extension":2279,"meta":2280,"navigation":329,"path":2281,"seo":2282,"stem":2283,"tags":2284,"topics":2286,"__hash__":2294},"blog\u002F2.blog\u002Fmiiajs-0-9.md","MiiaJS 0.9: module boundaries, typed tokens and a rebuilt CLI","Ruslan Matiushev",{"type":200,"value":201,"toc":2266},"minimark",[202,218,227,230,257,262,269,280,358,376,384,408,415,535,557,565,569,576,653,656,755,790,797,803,809,813,819,914,924,982,992,995,1027,1033,1036,1042,1046,1057,1074,1159,1172,1178,1182,1185,1207,1225,1408,1415,1421,1424,1430,1434,1444,1450,1557,1560,1566,1572,1576,1619,1646,1692,1717,1741,1747,1751,1755,1928,1931,1943,2188,2207,2228,2239,2245,2262],[203,204,205,206,210,211,213,214,217],"p",{},"MiiaJS is a TypeScript HTTP framework with the modules, providers, controllers and guards NestJS made familiar, built on native TC39 decorators and the Web ",[207,208,209],"code",{},"Request"," \u002F ",[207,212,65],{}," API. It runs on Bun, Deno and Node.js, and as a plain ",[207,215,216],{},"fetch"," handler on serverless and edge platforms.",[203,219,220,221,226],{},"0.9 is the largest release so far. The DI system was redesigned: modules have boundaries that startup checks, tokens carry their types, request-scoped providers live on the request, and lifecycle hooks follow dependencies. Around it, messaging got typed event contracts, config got feature configs, and the CLI was rebuilt. The release has breaking changes; ",[222,223,225],"a",{"href":224},"#upgrading-from-08","Upgrading from 0.8"," lists the ones most apps will hit, with the fix for each.",[203,228,229],{},"To try it:",[231,232,237],"pre",{"className":233,"code":234,"language":235,"meta":236,"style":236},"language-bash shiki shiki-themes miia-light miia-light miia-dark","bun create miia my-app\n","bash","",[207,238,239],{"__ignoreMap":236},[240,241,244,248,251,254],"span",{"class":242,"line":243},"line",1,[240,245,247],{"class":246},"sQCOG","bun ",[240,249,250],{"class":246},"create",[240,252,253],{"class":246}," miia",[240,255,256],{"class":246}," my-app\n",[258,259,261],"h2",{"id":260},"modules-with-boundaries","Modules with boundaries",[203,263,264,265,268],{},"Until 0.9 every provider of an app sat in one container, and any of them could inject any other. ",[207,266,267],{},"imports"," described the structure of the app, but nothing enforced it: a forgotten import only showed up when you tried to test a module on its own.",[203,270,271,272,275,276,279],{},"Now a module sees three things: its own providers, what the modules it imports list in ",[207,273,274],{},"exports",", and the exports of ",[207,277,278],{},"global"," modules. Nothing is global by default, MiiaJS packages included.",[231,281,285],{"className":282,"code":283,"language":284,"meta":236,"style":236},"language-ts shiki shiki-themes miia-light miia-light miia-dark","@Module({\n  providers: [UsersService, PasswordHasher],\n  exports: [UsersService], \u002F\u002F PasswordHasher stays private\n})\nclass UsersModule {}\n\n@Module({\n  providers: [OrdersService], \u002F\u002F OrdersService injects UsersService\n})\nclass OrdersModule {}\n","ts",[207,286,287,296,302,312,318,324,331,338,347,352],{"__ignoreMap":236},[240,288,289,293],{"class":242,"line":243},[240,290,292],{"class":291},"s4dNc","@Module",[240,294,295],{"class":246},"({\n",[240,297,299],{"class":242,"line":298},2,[240,300,301],{"class":246},"  providers: [UsersService, PasswordHasher],\n",[240,303,305,308],{"class":242,"line":304},3,[240,306,307],{"class":246},"  exports: [UsersService], ",[240,309,311],{"class":310},"sM8yr","\u002F\u002F PasswordHasher stays private\n",[240,313,315],{"class":242,"line":314},4,[240,316,317],{"class":246},"})\n",[240,319,321],{"class":242,"line":320},5,[240,322,323],{"class":246},"class UsersModule {}\n",[240,325,327],{"class":242,"line":326},6,[240,328,330],{"emptyLinePlaceholder":329},true,"\n",[240,332,334,336],{"class":242,"line":333},7,[240,335,292],{"class":291},[240,337,295],{"class":246},[240,339,341,344],{"class":242,"line":340},8,[240,342,343],{"class":246},"  providers: [OrdersService], ",[240,345,346],{"class":310},"\u002F\u002F OrdersService injects UsersService\n",[240,348,350],{"class":242,"line":349},9,[240,351,317],{"class":246},[240,353,355],{"class":242,"line":354},10,[240,356,357],{"class":246},"class OrdersModule {}\n",[203,359,360,363,364,367,368,371,372,375],{},[207,361,362],{},"OrdersModule"," forgot to import ",[207,365,366],{},"UsersModule",". ",[207,369,370],{},"init()"," builds every singleton, collects every violation it finds, and throws one report before the first ",[207,373,374],{},"onInit()",", so nothing has connected to a database yet:",[231,377,382],{"className":378,"code":380,"language":381,"meta":236},[379],"language-text","[Miia] 1 module boundary violation:\n\nOrdersService (OrdersModule) injects UsersService (UsersModule):\n  - add UsersModule to OrdersModule `imports`\n\nDocs: \u002Fdocs\u002Fcore-concepts\u002Fmodules#boundaries\n","text",[207,383,380],{"__ignoreMap":236},[203,385,386,387,390,391,394,395,397,398,401,402,367,404,407],{},"The check covers more than ",[207,388,389],{},"inject()",". Factory providers are checked from their module, and so is everything a guard injects: ",[207,392,393],{},"AuthGuard(JwtAuth)"," on a controller in ",[207,396,366],{}," needs ",[207,399,400],{},"JwtAuth"," to be visible from ",[207,403,366],{},[207,405,406],{},"inject(Resolver)"," returns a resolver bound to the module that injects it, so it is no longer a way around the boundaries.",[203,409,410,411,414],{},"Infrastructure that almost every module reaches for is configured once, in the root module, with ",[207,412,413],{},"{ global: true }",":",[231,416,418],{"className":282,"code":417,"language":284,"meta":236,"style":236},"@Module({\n  imports: [\n    ConfigModule.configure({ schema: EnvSchema }, { global: true }),\n    DrizzleModule.configure(\n      (resolve) => ({\n        dialect: 'postgres',\n        connection: { url: resolve(ConfigService).getOrThrow('DATABASE_URL') },\n      }),\n      { global: true },\n    ),\n    UsersModule,\n    OrdersModule,\n  ],\n})\nclass AppModule {}\n",[207,419,420,426,431,442,452,457,468,491,496,501,506,512,518,524,529],{"__ignoreMap":236},[240,421,422,424],{"class":242,"line":243},[240,423,292],{"class":291},[240,425,295],{"class":246},[240,427,428],{"class":242,"line":298},[240,429,430],{"class":246},"  imports: [\n",[240,432,433,436,439],{"class":242,"line":304},[240,434,435],{"class":246},"    ConfigModule.",[240,437,438],{"class":291},"configure",[240,440,441],{"class":246},"({ schema: EnvSchema }, { global: true }),\n",[240,443,444,447,449],{"class":242,"line":314},[240,445,446],{"class":246},"    DrizzleModule.",[240,448,438],{"class":291},[240,450,451],{"class":246},"(\n",[240,453,454],{"class":242,"line":320},[240,455,456],{"class":246},"      (resolve) => ({\n",[240,458,459,462,465],{"class":242,"line":326},[240,460,461],{"class":246},"        dialect: ",[240,463,464],{"class":310},"'postgres'",[240,466,467],{"class":246},",\n",[240,469,470,473,476,479,482,485,488],{"class":242,"line":333},[240,471,472],{"class":246},"        connection: { url: ",[240,474,475],{"class":291},"resolve",[240,477,478],{"class":246},"(ConfigService).",[240,480,481],{"class":291},"getOrThrow",[240,483,484],{"class":246},"(",[240,486,487],{"class":310},"'DATABASE_URL'",[240,489,490],{"class":246},") },\n",[240,492,493],{"class":242,"line":340},[240,494,495],{"class":246},"      }),\n",[240,497,498],{"class":242,"line":349},[240,499,500],{"class":246},"      { global: true },\n",[240,502,503],{"class":242,"line":354},[240,504,505],{"class":246},"    ),\n",[240,507,509],{"class":242,"line":508},11,[240,510,511],{"class":246},"    UsersModule,\n",[240,513,515],{"class":242,"line":514},12,[240,516,517],{"class":246},"    OrdersModule,\n",[240,519,521],{"class":242,"line":520},13,[240,522,523],{"class":246},"  ],\n",[240,525,527],{"class":242,"line":526},14,[240,528,317],{"class":246},[240,530,532],{"class":242,"line":531},15,[240,533,534],{"class":246},"class AppModule {}\n",[203,536,537,538,541,542,544,545,548,549,552,553,556],{},"A few rules came with it. Module files that import each other use ",[207,539,540],{},"forwardRef(() => X)"," on both sides of the cycle. The same module configured twice throws instead of the first configuration silently winning, and the same provider in two modules names both of them in the error. The module graph is processed once, on the first ",[207,543,370],{},", ",[207,546,547],{},"app.get()"," or ",[207,550,551],{},"fetch()",", so the order of ",[207,554,555],{},"app.register()"," calls no longer matters.",[203,558,559,560,564],{},"Docs: ",[222,561,563],{"href":562},"\u002Fdocs\u002Fcore-concepts\u002Fmodules#boundaries","Modules → Boundaries",".",[258,566,568],{"id":567},"typed-tokens","Typed tokens",[203,570,571,572,575],{},"A token is now a class (abstract ones included) or an object from ",[207,573,574],{},"createToken\u003CT>()",". String tokens are gone. In 0.8 a value that was not a class looked like this:",[231,577,579],{"className":282,"code":578,"language":284,"meta":236,"style":236},"@Module({\n  providers: [{ token: 'MAILER', factory: () => new SmtpMailer() }],\n})\nclass MailModule {}\n\n@Injectable()\nclass NotificationService {\n  private mailer = inject\u003CMailer>('MAILER') \u002F\u002F the type is whatever you write here\n}\n",[207,580,581,587,609,613,618,622,630,635,648],{"__ignoreMap":236},[240,582,583,585],{"class":242,"line":243},[240,584,292],{"class":291},[240,586,295],{"class":246},[240,588,589,592,595,597,600,603,606],{"class":242,"line":298},[240,590,591],{"class":246},"  providers: [{ token: ",[240,593,594],{"class":310},"'MAILER'",[240,596,544],{"class":246},[240,598,599],{"class":291},"factory",[240,601,602],{"class":246},": () => new ",[240,604,605],{"class":291},"SmtpMailer",[240,607,608],{"class":246},"() }],\n",[240,610,611],{"class":242,"line":304},[240,612,317],{"class":246},[240,614,615],{"class":242,"line":314},[240,616,617],{"class":246},"class MailModule {}\n",[240,619,620],{"class":242,"line":320},[240,621,330],{"emptyLinePlaceholder":329},[240,623,624,627],{"class":242,"line":326},[240,625,626],{"class":291},"@Injectable",[240,628,629],{"class":246},"()\n",[240,631,632],{"class":242,"line":333},[240,633,634],{"class":246},"class NotificationService {\n",[240,636,637,640,642,645],{"class":242,"line":340},[240,638,639],{"class":246},"  private mailer = inject\u003CMailer>(",[240,641,594],{"class":310},[240,643,644],{"class":246},") ",[240,646,647],{"class":310},"\u002F\u002F the type is whatever you write here\n",[240,649,650],{"class":242,"line":349},[240,651,652],{"class":246},"}\n",[203,654,655],{},"In 0.9:",[231,657,659],{"className":282,"code":658,"language":284,"meta":236,"style":236},"import { createToken, inject, Injectable, Module, provider } from '@miiajs\u002Fcore'\n\nexport const MAILER = createToken\u003CMailer>('Mailer', { hint: 'MailModule' })\n\n@Module({\n  providers: [provider(MAILER, () => new SmtpMailer())],\n  exports: [MAILER],\n})\nclass MailModule {}\n\n@Injectable()\nclass NotificationService {\n  private mailer = inject(MAILER) \u002F\u002F Mailer\n}\n",[207,660,661,669,673,690,694,700,716,721,725,729,733,739,743,751],{"__ignoreMap":236},[240,662,663,666],{"class":242,"line":243},[240,664,665],{"class":246},"import { createToken, inject, Injectable, Module, provider } from ",[240,667,668],{"class":310},"'@miiajs\u002Fcore'\n",[240,670,671],{"class":242,"line":298},[240,672,330],{"emptyLinePlaceholder":329},[240,674,675,678,681,684,687],{"class":242,"line":304},[240,676,677],{"class":246},"export const MAILER = createToken\u003CMailer>(",[240,679,680],{"class":310},"'Mailer'",[240,682,683],{"class":246},", { hint: ",[240,685,686],{"class":310},"'MailModule'",[240,688,689],{"class":246}," })\n",[240,691,692],{"class":242,"line":314},[240,693,330],{"emptyLinePlaceholder":329},[240,695,696,698],{"class":242,"line":320},[240,697,292],{"class":291},[240,699,295],{"class":246},[240,701,702,705,708,711,713],{"class":242,"line":326},[240,703,704],{"class":246},"  providers: [",[240,706,707],{"class":291},"provider",[240,709,710],{"class":246},"(MAILER, () => new ",[240,712,605],{"class":291},[240,714,715],{"class":246},"())],\n",[240,717,718],{"class":242,"line":333},[240,719,720],{"class":246},"  exports: [MAILER],\n",[240,722,723],{"class":242,"line":340},[240,724,317],{"class":246},[240,726,727],{"class":242,"line":349},[240,728,617],{"class":246},[240,730,731],{"class":242,"line":354},[240,732,330],{"emptyLinePlaceholder":329},[240,734,735,737],{"class":242,"line":508},[240,736,626],{"class":291},[240,738,629],{"class":246},[240,740,741],{"class":242,"line":514},[240,742,634],{"class":246},[240,744,745,748],{"class":242,"line":520},[240,746,747],{"class":246},"  private mailer = inject(MAILER) ",[240,749,750],{"class":310},"\u002F\u002F Mailer\n",[240,752,753],{"class":242,"line":526},[240,754,652],{"class":246},[203,756,757,758,544,760,544,763,544,765,544,768,771,772,367,775,778,779,782,783,786,787,789],{},"The type flows from the token wherever it is resolved: ",[207,759,389],{},[207,761,762],{},"injectOptional()",[207,764,547],{},[207,766,767],{},"ctx.resolve()",[207,769,770],{},"Resolver"," and ",[207,773,774],{},"TestApp.override()",[207,776,777],{},"provider()"," checks the factory against it, so ",[207,780,781],{},"provider(MAILER, () => 42)"," does not compile. The object form from 0.8 still works with a token object, ",[207,784,785],{},"{ token: MAILER, factory }",", but nothing checks its factory, so ",[207,788,777],{}," is the one to use by default. A token is identified by the object, not by its name, so two packages can no longer collide on a string.",[203,791,792,793,796],{},"DI errors got the same attention. They name the token instead of printing the source of a class, say who required a missing provider, and carry the token's ",[207,794,795],{},"hint"," about where it comes from:",[231,798,801],{"className":799,"code":800,"language":381,"meta":236},[379],"[Miia] No provider found for token: Mailer, required by NotificationService (NotificationsModule)\n  - Mailer is provided by MailModule; import that module where Mailer is used\n",[207,802,800],{"__ignoreMap":236},[203,804,559,805,564],{},[222,806,808],{"href":807},"\u002Fdocs\u002Fcore-concepts\u002Fproviders#typed-tokens","Providers → Typed tokens",[258,810,812],{"id":811},"request-scoped-providers-live-on-the-request","Request-scoped providers live on the request",[203,814,815,816,818],{},"A request-scoped instance now lives on the request context. The first ",[207,817,767],{}," in a request creates it, later calls in the same request return it, and concurrent requests never share one. In 0.8 the instances sat on the container, and two requests in flight could end up with the same one.",[231,820,822],{"className":282,"code":821,"language":284,"meta":236,"style":236},"@Injectable({ scope: 'request' })\nclass RequestLogger {\n  private ctx = inject(REQUEST_CONTEXT)\n  readonly requestId = this.ctx.req.headers.get('x-request-id') ?? crypto.randomUUID()\n}\n\n@Controller('\u002Forders')\nclass OrderController {\n  @Get('\u002F')\n  list(ctx: RequestContext) {\n    return { requestId: ctx.resolve(RequestLogger).requestId }\n  }\n}\n",[207,823,824,836,841,846,857,861,865,878,883,895,900,905,910],{"__ignoreMap":236},[240,825,826,828,831,834],{"class":242,"line":243},[240,827,626],{"class":291},[240,829,830],{"class":246},"({ scope: ",[240,832,833],{"class":310},"'request'",[240,835,689],{"class":246},[240,837,838],{"class":242,"line":298},[240,839,840],{"class":246},"class RequestLogger {\n",[240,842,843],{"class":242,"line":304},[240,844,845],{"class":246},"  private ctx = inject(REQUEST_CONTEXT)\n",[240,847,848,851,854],{"class":242,"line":314},[240,849,850],{"class":246},"  readonly requestId = this.ctx.req.headers.get(",[240,852,853],{"class":310},"'x-request-id'",[240,855,856],{"class":246},") ?? crypto.randomUUID()\n",[240,858,859],{"class":242,"line":320},[240,860,652],{"class":246},[240,862,863],{"class":242,"line":326},[240,864,330],{"emptyLinePlaceholder":329},[240,866,867,870,872,875],{"class":242,"line":333},[240,868,869],{"class":291},"@Controller",[240,871,484],{"class":246},[240,873,874],{"class":310},"'\u002Forders'",[240,876,877],{"class":246},")\n",[240,879,880],{"class":242,"line":340},[240,881,882],{"class":246},"class OrderController {\n",[240,884,885,888,890,893],{"class":242,"line":349},[240,886,887],{"class":291},"  @Get",[240,889,484],{"class":246},[240,891,892],{"class":310},"'\u002F'",[240,894,877],{"class":246},[240,896,897],{"class":242,"line":354},[240,898,899],{"class":246},"  list(ctx: RequestContext) {\n",[240,901,902],{"class":242,"line":508},[240,903,904],{"class":246},"    return { requestId: ctx.resolve(RequestLogger).requestId }\n",[240,906,907],{"class":242,"line":514},[240,908,909],{"class":246},"  }\n",[240,911,912],{"class":242,"line":520},[240,913,652],{"class":246},[203,915,916,919,920,923],{},[207,917,918],{},"REQUEST_CONTEXT"," is the context itself, as a request-scoped token. When the pipeline of a request has finished and its response is built, every instance the request created gets ",[207,921,922],{},"onDestroy()",", newest first. The hooks do not hold the response back.",[231,925,927],{"className":282,"code":926,"language":284,"meta":236,"style":236},"@Injectable({ scope: 'request' })\nclass RequestMetrics {\n  private metrics = inject(MetricsService)\n  private started = performance.now()\n\n  onDestroy() {\n    this.metrics.record('request.duration', performance.now() - this.started)\n  }\n}\n",[207,928,929,939,944,949,954,958,963,974,978],{"__ignoreMap":236},[240,930,931,933,935,937],{"class":242,"line":243},[240,932,626],{"class":291},[240,934,830],{"class":246},[240,936,833],{"class":310},[240,938,689],{"class":246},[240,940,941],{"class":242,"line":298},[240,942,943],{"class":246},"class RequestMetrics {\n",[240,945,946],{"class":242,"line":304},[240,947,948],{"class":246},"  private metrics = inject(MetricsService)\n",[240,950,951],{"class":242,"line":314},[240,952,953],{"class":246},"  private started = performance.now()\n",[240,955,956],{"class":242,"line":320},[240,957,330],{"emptyLinePlaceholder":329},[240,959,960],{"class":242,"line":326},[240,961,962],{"class":246},"  onDestroy() {\n",[240,964,965,968,971],{"class":242,"line":333},[240,966,967],{"class":246},"    this.metrics.record(",[240,969,970],{"class":310},"'request.duration'",[240,972,973],{"class":246},", performance.now() - this.started)\n",[240,975,976],{"class":242,"line":340},[240,977,909],{"class":246},[240,979,980],{"class":242,"line":349},[240,981,652],{"class":246},[203,983,984,985,987,988,991],{},"An instance exists from the first ",[207,986,767],{},", so resolve ",[207,989,990],{},"RequestMetrics"," in a global middleware to time the whole request.",[203,993,994],{},"Controllers and guards stay singletons. A singleton that injects a request-scoped provider would keep the instance of whichever request built it, so it fails at startup:",[231,996,998],{"className":282,"code":997,"language":284,"meta":236,"style":236},"@Injectable() \u002F\u002F a singleton\nclass AuditService {\n  private logger = inject(RequestLogger) \u002F\u002F fails at startup\n}\n",[207,999,1000,1010,1015,1023],{"__ignoreMap":236},[240,1001,1002,1004,1007],{"class":242,"line":243},[240,1003,626],{"class":291},[240,1005,1006],{"class":246},"() ",[240,1008,1009],{"class":310},"\u002F\u002F a singleton\n",[240,1011,1012],{"class":242,"line":298},[240,1013,1014],{"class":246},"class AuditService {\n",[240,1016,1017,1020],{"class":242,"line":304},[240,1018,1019],{"class":246},"  private logger = inject(RequestLogger) ",[240,1021,1022],{"class":310},"\u002F\u002F fails at startup\n",[240,1024,1025],{"class":242,"line":314},[240,1026,652],{"class":246},[231,1028,1031],{"className":1029,"code":1030,"language":381,"meta":236},[379],"[Miia] AuditService (singleton) injects request-scoped RequestLogger - resolve it with ctx.resolve() in the handler, or make AuditService request-scoped\n",[207,1032,1030],{"__ignoreMap":236},[203,1034,1035],{},"Here request scope differs from NestJS, where a request-scoped dependency makes the classes that inject it request-scoped too, controllers included. In MiiaJS the request scope stays where you declared it.",[203,1037,559,1038,564],{},[222,1039,1041],{"href":1040},"\u002Fdocs\u002Fcore-concepts\u002Fproviders#request-scope","Providers → Request scope",[258,1043,1045],{"id":1044},"lifecycle-hooks-follow-dependencies","Lifecycle hooks follow dependencies",[203,1047,1048,771,1050,1053,1054,564],{},[207,1049,374],{},[207,1051,1052],{},"onReady()"," run in dependency order: a provider's hooks run after the hooks of the singletons it injects. A factory provider that reaches a dependency lazily, after construction, lists it in ",[207,1055,1056],{},"deps",[203,1058,1059,1060,1063,1064,1066,1067,1070,1071,1073],{},"Shutdown has two phases. ",[207,1061,1062],{},"app.destroy()"," closes the server, waits for the ",[207,1065,922],{}," of requests that have finished, runs ",[207,1068,1069],{},"onShutdown()"," on every singleton (stop taking new work, wait for the work in flight), and only then ",[207,1072,922],{}," on every singleton (release resources). Both phases run in reverse dependency order, so a provider draining work can still use the connection it injects:",[231,1075,1077],{"className":282,"code":1076,"language":284,"meta":236,"style":236},"@Injectable()\nclass DbConnection {\n  async onDestroy() {\n    await this.disconnect()\n  }\n}\n\n@Injectable()\nclass ReportWorker {\n  private db = inject(DbConnection)\n\n  async onShutdown() {\n    this.stopPolling()\n    await this.currentJob \u002F\u002F may still query this.db\n  }\n}\n",[207,1078,1079,1085,1090,1095,1100,1104,1108,1112,1118,1123,1128,1132,1137,1142,1150,1154],{"__ignoreMap":236},[240,1080,1081,1083],{"class":242,"line":243},[240,1082,626],{"class":291},[240,1084,629],{"class":246},[240,1086,1087],{"class":242,"line":298},[240,1088,1089],{"class":246},"class DbConnection {\n",[240,1091,1092],{"class":242,"line":304},[240,1093,1094],{"class":246},"  async onDestroy() {\n",[240,1096,1097],{"class":242,"line":314},[240,1098,1099],{"class":246},"    await this.disconnect()\n",[240,1101,1102],{"class":242,"line":320},[240,1103,909],{"class":246},[240,1105,1106],{"class":242,"line":326},[240,1107,652],{"class":246},[240,1109,1110],{"class":242,"line":333},[240,1111,330],{"emptyLinePlaceholder":329},[240,1113,1114,1116],{"class":242,"line":340},[240,1115,626],{"class":291},[240,1117,629],{"class":246},[240,1119,1120],{"class":242,"line":349},[240,1121,1122],{"class":246},"class ReportWorker {\n",[240,1124,1125],{"class":242,"line":354},[240,1126,1127],{"class":246},"  private db = inject(DbConnection)\n",[240,1129,1130],{"class":242,"line":508},[240,1131,330],{"emptyLinePlaceholder":329},[240,1133,1134],{"class":242,"line":514},[240,1135,1136],{"class":246},"  async onShutdown() {\n",[240,1138,1139],{"class":242,"line":520},[240,1140,1141],{"class":246},"    this.stopPolling()\n",[240,1143,1144,1147],{"class":242,"line":526},[240,1145,1146],{"class":246},"    await this.currentJob ",[240,1148,1149],{"class":310},"\u002F\u002F may still query this.db\n",[240,1151,1152],{"class":242,"line":531},[240,1153,909],{"class":246},[240,1155,1157],{"class":242,"line":1156},16,[240,1158,652],{"class":246},[203,1160,1161,1164,1165,1167,1168,1171],{},[207,1162,1163],{},"@miiajs\u002Fmessaging"," uses this: message handlers drain in ",[207,1166,1069],{},", so the database they write to closes after they finish, wherever its module sits. A failing hook no longer stops the rest. ",[207,1169,1170],{},"destroy()"," runs every step, logs each failure with its source, and throws afterwards.",[203,1173,559,1174,564],{},[222,1175,1177],{"href":1176},"\u002Fdocs\u002Fcore-concepts\u002Fapp-lifecycle#shutdown-phase","App lifecycle → Shutdown phase",[258,1179,1181],{"id":1180},"event-contracts-in-messaging","Event contracts in messaging",[203,1183,1184],{},"In 0.8 a topic was a string, and the payload type was a promise the handler made:",[231,1186,1188],{"className":282,"code":1187,"language":284,"meta":236,"style":236},"@On('user.created')\nasync sendWelcome(user: { id: string; email: string }) {}\n",[207,1189,1190,1202],{"__ignoreMap":236},[240,1191,1192,1195,1197,1200],{"class":242,"line":243},[240,1193,1194],{"class":291},"@On",[240,1196,484],{"class":246},[240,1198,1199],{"class":310},"'user.created'",[240,1201,877],{"class":246},[240,1203,1204],{"class":242,"line":298},[240,1205,1206],{"class":246},"async sendWelcome(user: { id: string; email: string }) {}\n",[203,1208,1209,1210,1213,1214,1217,1218,771,1221,1224],{},"In 0.9 an event is a contract that both sides share. ",[207,1211,1212],{},"defineEvent(topic, schema?)"," returns a frozen ",[207,1215,1216],{},"{ topic, schema }",", and ",[207,1219,1220],{},"publish()",[207,1222,1223],{},"@On()"," take only contracts:",[231,1226,1228],{"className":282,"code":1227,"language":284,"meta":236,"style":236},"import { inject, Injectable } from '@miiajs\u002Fcore'\nimport { defineEvent, type EventPayload, MessageBus, On } from '@miiajs\u002Fmessaging'\nimport { z } from 'zod'\n\nexport const OrderPlaced = defineEvent(\n  'order.placed',\n  z.object({\n    orderId: z.string(),\n    total: z.number().positive(),\n    placedAt: z.coerce.date(),\n  }),\n)\nexport type OrderPlaced = EventPayload\u003Ctypeof OrderPlaced>\n\n@Injectable()\nclass Orders {\n  private bus = inject(MessageBus)\n\n  async place() {\n    await this.bus.publish(OrderPlaced, { orderId: 'o-1', total: 42, placedAt: new Date() })\n  }\n}\n\n@Injectable()\nclass Billing {\n  @On(OrderPlaced)\n  async onPlaced(order: OrderPlaced) {\n    order.placedAt.getFullYear() \u002F\u002F a Date: the schema coerced it\n  }\n}\n",[207,1229,1230,1237,1245,1253,1257,1262,1269,1274,1279,1284,1289,1294,1298,1303,1307,1312,1317,1323,1328,1334,1346,1351,1356,1361,1368,1374,1383,1389,1398,1403],{"__ignoreMap":236},[240,1231,1232,1235],{"class":242,"line":243},[240,1233,1234],{"class":246},"import { inject, Injectable } from ",[240,1236,668],{"class":310},[240,1238,1239,1242],{"class":242,"line":298},[240,1240,1241],{"class":246},"import { defineEvent, type EventPayload, MessageBus, On } from ",[240,1243,1244],{"class":310},"'@miiajs\u002Fmessaging'\n",[240,1246,1247,1250],{"class":242,"line":304},[240,1248,1249],{"class":246},"import { z } from ",[240,1251,1252],{"class":310},"'zod'\n",[240,1254,1255],{"class":242,"line":314},[240,1256,330],{"emptyLinePlaceholder":329},[240,1258,1259],{"class":242,"line":320},[240,1260,1261],{"class":246},"export const OrderPlaced = defineEvent(\n",[240,1263,1264,1267],{"class":242,"line":326},[240,1265,1266],{"class":310},"  'order.placed'",[240,1268,467],{"class":246},[240,1270,1271],{"class":242,"line":333},[240,1272,1273],{"class":246},"  z.object({\n",[240,1275,1276],{"class":242,"line":340},[240,1277,1278],{"class":246},"    orderId: z.string(),\n",[240,1280,1281],{"class":242,"line":349},[240,1282,1283],{"class":246},"    total: z.number().positive(),\n",[240,1285,1286],{"class":242,"line":354},[240,1287,1288],{"class":246},"    placedAt: z.coerce.date(),\n",[240,1290,1291],{"class":242,"line":508},[240,1292,1293],{"class":246},"  }),\n",[240,1295,1296],{"class":242,"line":514},[240,1297,877],{"class":246},[240,1299,1300],{"class":242,"line":520},[240,1301,1302],{"class":246},"export type OrderPlaced = EventPayload\u003Ctypeof OrderPlaced>\n",[240,1304,1305],{"class":242,"line":526},[240,1306,330],{"emptyLinePlaceholder":329},[240,1308,1309],{"class":242,"line":531},[240,1310,1311],{"class":246},"@Injectable()\n",[240,1313,1314],{"class":242,"line":1156},[240,1315,1316],{"class":246},"class Orders {\n",[240,1318,1320],{"class":242,"line":1319},17,[240,1321,1322],{"class":246},"  private bus = inject(MessageBus)\n",[240,1324,1326],{"class":242,"line":1325},18,[240,1327,330],{"emptyLinePlaceholder":329},[240,1329,1331],{"class":242,"line":1330},19,[240,1332,1333],{"class":246},"  async place() {\n",[240,1335,1337,1340,1343],{"class":242,"line":1336},20,[240,1338,1339],{"class":246},"    await this.bus.publish(OrderPlaced, { orderId: ",[240,1341,1342],{"class":310},"'o-1'",[240,1344,1345],{"class":246},", total: 42, placedAt: new Date() })\n",[240,1347,1349],{"class":242,"line":1348},21,[240,1350,909],{"class":246},[240,1352,1354],{"class":242,"line":1353},22,[240,1355,652],{"class":246},[240,1357,1359],{"class":242,"line":1358},23,[240,1360,330],{"emptyLinePlaceholder":329},[240,1362,1364,1366],{"class":242,"line":1363},24,[240,1365,626],{"class":291},[240,1367,629],{"class":246},[240,1369,1371],{"class":242,"line":1370},25,[240,1372,1373],{"class":246},"class Billing {\n",[240,1375,1377,1380],{"class":242,"line":1376},26,[240,1378,1379],{"class":291},"  @On",[240,1381,1382],{"class":246},"(OrderPlaced)\n",[240,1384,1386],{"class":242,"line":1385},27,[240,1387,1388],{"class":246},"  async onPlaced(order: OrderPlaced) {\n",[240,1390,1392,1395],{"class":242,"line":1391},28,[240,1393,1394],{"class":246},"    order.placedAt.getFullYear() ",[240,1396,1397],{"class":310},"\u002F\u002F a Date: the schema coerced it\n",[240,1399,1401],{"class":242,"line":1400},29,[240,1402,909],{"class":246},[240,1404,1406],{"class":242,"line":1405},30,[240,1407,652],{"class":246},[203,1409,1410,1411,1414],{},"A handler parameter of another type does not compile. Every handler validates the payload before it runs and gets the parsed data. A payload that does not match is rejected: the handler is not called, and the message goes to ",[207,1412,1413],{},"\u003Ctopic>.dlq"," at once, without retries, since a retry cannot fix a payload. The reason is in the dead letter:",[231,1416,1419],{"className":1417,"code":1418,"language":381,"meta":236},[379],"Payload validation failed for 'order.placed': orderId: Invalid input: expected string, received undefined; total: Too small: expected number to be >0\n",[207,1420,1418],{"__ignoreMap":236},[203,1422,1423],{},"The schema runs where the message is consumed because that is the side it protects. It also covers producers that never saw the contract's types: a service in another language, an older deployment, a message written by hand.",[203,1425,559,1426,564],{},[222,1427,1429],{"href":1428},"\u002Fdocs\u002Fpackages\u002Fmessaging#event-contracts","Messaging → Event contracts",[258,1431,1433],{"id":1432},"feature-configs","Feature configs",[203,1435,1436,1439,1440,1443],{},[207,1437,1438],{},"ConfigService"," values are now a snapshot taken at startup and frozen: ",[207,1441,1442],{},"config.get('ORIGINS').push(...)"," throws instead of changing the value every other caller sees.",[203,1445,1446,1447,414],{},"A feature module can own its variables with ",[207,1448,1449],{},"defineConfig()",[231,1451,1453],{"className":282,"code":1452,"language":284,"meta":236,"style":236},"export const paymentsConfig = defineConfig(\n  'payments',\n  z.object({\n    STRIPE_KEY: z.string(),\n    CURRENCY: z.string().default('usd'),\n  }),\n)\n\n@Injectable()\nexport class PaymentsService {\n  private config = inject(paymentsConfig) \u002F\u002F Readonly\u003C{ STRIPE_KEY: string; CURRENCY: string }>\n}\n\n@Module({\n  imports: [ConfigModule.register(paymentsConfig)],\n  providers: [PaymentsService],\n})\nexport class PaymentsModule {}\n",[207,1454,1455,1460,1467,1471,1476,1487,1491,1495,1499,1505,1510,1518,1522,1526,1532,1543,1548,1552],{"__ignoreMap":236},[240,1456,1457],{"class":242,"line":243},[240,1458,1459],{"class":246},"export const paymentsConfig = defineConfig(\n",[240,1461,1462,1465],{"class":242,"line":298},[240,1463,1464],{"class":310},"  'payments'",[240,1466,467],{"class":246},[240,1468,1469],{"class":242,"line":304},[240,1470,1273],{"class":246},[240,1472,1473],{"class":242,"line":314},[240,1474,1475],{"class":246},"    STRIPE_KEY: z.string(),\n",[240,1477,1478,1481,1484],{"class":242,"line":320},[240,1479,1480],{"class":246},"    CURRENCY: z.string().default(",[240,1482,1483],{"class":310},"'usd'",[240,1485,1486],{"class":246},"),\n",[240,1488,1489],{"class":242,"line":326},[240,1490,1293],{"class":246},[240,1492,1493],{"class":242,"line":333},[240,1494,877],{"class":246},[240,1496,1497],{"class":242,"line":340},[240,1498,330],{"emptyLinePlaceholder":329},[240,1500,1501,1503],{"class":242,"line":349},[240,1502,626],{"class":291},[240,1504,629],{"class":246},[240,1506,1507],{"class":242,"line":354},[240,1508,1509],{"class":246},"export class PaymentsService {\n",[240,1511,1512,1515],{"class":242,"line":508},[240,1513,1514],{"class":246},"  private config = inject(paymentsConfig) ",[240,1516,1517],{"class":310},"\u002F\u002F Readonly\u003C{ STRIPE_KEY: string; CURRENCY: string }>\n",[240,1519,1520],{"class":242,"line":514},[240,1521,652],{"class":246},[240,1523,1524],{"class":242,"line":520},[240,1525,330],{"emptyLinePlaceholder":329},[240,1527,1528,1530],{"class":242,"line":526},[240,1529,292],{"class":291},[240,1531,295],{"class":246},[240,1533,1534,1537,1540],{"class":242,"line":531},[240,1535,1536],{"class":246},"  imports: [ConfigModule.",[240,1538,1539],{"class":291},"register",[240,1541,1542],{"class":246},"(paymentsConfig)],\n",[240,1544,1545],{"class":242,"line":1156},[240,1546,1547],{"class":246},"  providers: [PaymentsService],\n",[240,1549,1550],{"class":242,"line":1319},[240,1551,317],{"class":246},[240,1553,1554],{"class":242,"line":1325},[240,1555,1556],{"class":246},"export class PaymentsModule {}\n",[203,1558,1559],{},"The schema is validated once at startup, and a failure names the config:",[231,1561,1564],{"className":1562,"code":1563,"language":381,"meta":236},[379],"[Miia] Config validation failed for 'payments':\n  - STRIPE_KEY: Invalid input: expected string, received undefined\n",[207,1565,1563],{"__ignoreMap":236},[203,1567,559,1568,564],{},[222,1569,1571],{"href":1570},"\u002Fdocs\u002Fcore-concepts\u002Fconfiguration#feature-configuration","Configuration → Feature configuration",[258,1573,1575],{"id":1574},"a-rebuilt-cli","A rebuilt CLI",[231,1577,1579],{"className":233,"code":1578,"language":235,"meta":236,"style":236},"bun create miia my-app\nnpm create miia@latest my-app\ndeno run -A npm:create-miia my-app\n",[207,1580,1581,1591,1603],{"__ignoreMap":236},[240,1582,1583,1585,1587,1589],{"class":242,"line":243},[240,1584,247],{"class":246},[240,1586,250],{"class":246},[240,1588,253],{"class":246},[240,1590,256],{"class":246},[240,1592,1593,1596,1598,1601],{"class":242,"line":298},[240,1594,1595],{"class":246},"npm ",[240,1597,250],{"class":246},[240,1599,1600],{"class":246}," miia@latest",[240,1602,256],{"class":246},[240,1604,1605,1608,1611,1614,1617],{"class":242,"line":304},[240,1606,1607],{"class":246},"deno ",[240,1609,1610],{"class":246},"run",[240,1612,1613],{"class":246}," -A",[240,1615,1616],{"class":246}," npm:create-miia",[240,1618,256],{"class":246},[203,1620,1621,1624,1625,1628,1629,544,1632,544,1635,544,1638,1641,1642,1645],{},[207,1622,1623],{},"miia new"," builds the project from template files for Bun, Node.js or Deno. The project is laid out for strict module boundaries, with a global ",[207,1626,1627],{},"ConfigModule",", a validated env schema and tests next to the code. Every prompt has a flag (",[207,1630,1631],{},"--runtime",[207,1633,1634],{},"--pm",[207,1636,1637],{},"--features",[207,1639,1640],{},"--db","), and ",[207,1643,1644],{},"-y"," takes the defaults, for CI.",[203,1647,1648,1651,1652,1655,1656,1659,1660,544,1663,544,1666,544,1669,544,1672,1675,1676,544,1679,544,1682,544,1685,544,1688,1691],{},[207,1649,1650],{},"miia add"," adds features to a project that already exists: ",[207,1653,1654],{},"jwt-auth"," (working register, login and ",[207,1657,1658],{},"me"," routes), ",[207,1661,1662],{},"swagger",[207,1664,1665],{},"cors",[207,1667,1668],{},"serve-static",[207,1670,1671],{},"rate-limit",[207,1673,1674],{},"biome",", and one database (",[207,1677,1678],{},"drizzle-postgres",[207,1680,1681],{},"drizzle-mysql",[207,1683,1684],{},"drizzle-sqlite",[207,1686,1687],{},"papr",[207,1689,1690],{},"mongoose","). It edits your files through the TypeScript compiler API and keeps the rest of each file byte for byte. When it cannot edit something safely, it says what to add by hand instead of guessing.",[231,1693,1695],{"className":233,"code":1694,"language":235,"meta":236,"style":236},"bunx miia add jwt-auth swagger drizzle-postgres\n",[207,1696,1697],{"__ignoreMap":236},[240,1698,1699,1702,1705,1708,1711,1714],{"class":242,"line":243},[240,1700,1701],{"class":246},"bunx ",[240,1703,1704],{"class":246},"miia",[240,1706,1707],{"class":246}," add",[240,1709,1710],{"class":246}," jwt-auth",[240,1712,1713],{"class":246}," swagger",[240,1715,1716],{"class":246}," drizzle-postgres\n",[203,1718,1719,1722,1723,771,1726,544,1729,1732,1733,1736,1737,1740],{},[207,1720,1721],{},"miia g resource posts"," writes a CRUD module: zod route schemas, ",[207,1724,1725],{},"@Status(201)",[207,1727,1728],{},"@Status(204)",[207,1730,1731],{},"NotFoundException"," for a missing id, an in-memory service and a ",[207,1734,1735],{},"TestApp"," test that passes without a database. ",[207,1738,1739],{},"miia g table posts"," writes a Drizzle table for the project's dialect and adds it to the schema file.",[231,1742,1745],{"className":1743,"code":1744,"language":381,"meta":236},[379],"$ bunx miia g resource posts\n  UPDATE src\u002Fapp\u002Fapp.module.ts\n  CREATE src\u002Fposts\u002Fposts.controller.ts\n  CREATE src\u002Fposts\u002Fposts.module.ts\n  CREATE src\u002Fposts\u002Fposts.service.ts\n  CREATE src\u002Fposts\u002Fposts.test.ts\n  CREATE src\u002Fposts\u002Fposts.types.ts\n  CREATE src\u002Fposts\u002Fschemas\u002Fcreate-posts.schema.ts\n  CREATE src\u002Fposts\u002Fschemas\u002Fposts-id-params.schema.ts\n  CREATE src\u002Fposts\u002Fschemas\u002Fupdate-posts.schema.ts\n",[207,1746,1744],{"__ignoreMap":236},[203,1748,559,1749,564],{},[222,1750,152],{"href":153},[258,1752,1754],{"id":1753},"smaller-changes-and-fixes","Smaller changes and fixes",[1756,1757,1758,1778,1794,1804,1839,1862,1876,1892,1902,1915],"ul",{},[1759,1760,1761,1765,1766,1769,1770,1773,1774,1777],"li",{},[1762,1763,1764],"strong",{},"Bundled apps keep their decorator metadata."," ",[207,1767,1768],{},"\"sideEffects\": false"," let wrangler, ",[207,1771,1772],{},"bun build"," and esbuild drop the ",[207,1775,1776],{},"Symbol.metadata"," polyfill, and a bundled app answered 404 on every route. A generated app now starts on workerd, the Cloudflare Workers runtime, as part of the release checks.",[1759,1779,1780,1783,1784,771,1787,544,1790,1793],{},[1762,1781,1782],{},"Router."," The trie backs up when a branch dead-ends: with ",[207,1785,1786],{},"\u002Fusers\u002F:id",[207,1788,1789],{},"\u002Fusers\u002F*",[207,1791,1792],{},"GET \u002Fusers\u002F42\u002Fposts\u002F1"," reaches the wildcard instead of a 404. Each route reads its own param names.",[1759,1795,1796,1799,1800,1803],{},[1762,1797,1798],{},"Faster 404s and pipelines."," An app without global middleware answers an unmatched route without building an exception, and ",[207,1801,1802],{},"compose()"," follows koa-compose without an async wrapper per level.",[1759,1805,1806,1809,1810,1813,1814,771,1817,1820,1821,1823,1824,1827,1828,1831,1832,1834,1835,1838],{},[1762,1807,1808],{},"CORS."," A preflight is an ",[207,1811,1812],{},"OPTIONS"," with both ",[207,1815,1816],{},"Origin",[207,1818,1819],{},"Access-Control-Request-Method",", as the Fetch spec defines it; other ",[207,1822,1812],{}," requests reach their route. Any ",[207,1825,1826],{},"origin"," but ",[207,1829,1830],{},"'*'"," adds ",[207,1833,1816],{}," to ",[207,1836,1837],{},"Vary"," on every response.",[1759,1840,1841,1765,1844,1847,1848,1851,1852,210,1855,1858,1859,564],{},[1762,1842,1843],{},"Responses.",[207,1845,1846],{},"return ctx.res.redirect('\u002Flogin')"," works, a value returned under a custom ",[207,1849,1850],{},"Content-Type"," is sent, and ",[207,1853,1854],{},"ctx.res.text()",[207,1856,1857],{},"html()"," send ",[207,1860,1861],{},"charset=utf-8",[1759,1863,1864,1867,1868,1871,1872,1875],{},[1762,1865,1866],{},"JWT."," A numeric ",[207,1869,1870],{},"expiresIn"," is seconds from signing. Before, ",[207,1873,1874],{},"expiresIn: 3600"," signed tokens that had expired in 1970.",[1759,1877,1878,1765,1881,1884,1885,1641,1888,1891],{},[1762,1879,1880],{},"Auth.",[207,1882,1883],{},"fromHeader()"," matches the scheme case-insensitively (",[207,1886,1887],{},"bearer \u003Ctoken>",[207,1889,1890],{},"fromCookie()"," matches the name literally.",[1759,1893,1894,1897,1898,1901],{},[1762,1895,1896],{},"serve-static."," Percent-encoded file names, index files in subdirectories, ",[207,1899,1900],{},"etag: false"," that really turns off conditional GET.",[1759,1903,1904,1907,1908,1910,1911,1914],{},[1762,1905,1906],{},"Adapters."," node-server and uws-server read a request body once, as a real ",[207,1909,209],{}," does. node-server's early 413 keeps the connection and drains the upload, so the client gets the answer instead of a reset, and uws-server's ",[207,1912,1913],{},"close()"," waits for the requests in flight.",[1759,1916,1917,1765,1920,1923,1924,1927],{},[1762,1918,1919],{},"Logger.",[207,1921,1922],{},"NO_COLOR"," and a ",[207,1925,1926],{},"colors"," option keep escape codes out of log files.",[258,1929,225],{"id":1930},"upgrading-from-08",[203,1932,1933,1934,1942],{},"The full list is in the changelog of each package, starting with ",[222,1935,1939],{"href":1936,"rel":1937},"https:\u002F\u002Fgithub.com\u002Fmiiajs\u002Fmiia\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002FCHANGELOG.md",[1938],"nofollow",[207,1940,1941],{},"@miiajs\u002Fcore",". The changes most apps will hit:",[1944,1945,1946,1959],"table",{},[1947,1948,1949],"thead",{},[1950,1951,1952,1956],"tr",{},[1953,1954,1955],"th",{},"In 0.8",[1953,1957,1958],{},"In 0.9",[1960,1961,1962,1984,2010,2024,2036,2050,2070,2094,2114,2147,2168],"tbody",{},[1950,1963,1964,1974],{},[1965,1966,1967,1968,544,1971],"td",{},"String tokens: ",[207,1969,1970],{},"inject\u003CT>('X')",[207,1972,1973],{},"@Injectable({ token })",[1965,1975,1976,1979,1980,1983],{},[207,1977,1978],{},"createToken\u003CT>('X')"," with ",[207,1981,1982],{},"provider(token, factory)",", or the class itself",[1950,1985,1986,1995],{},[1965,1987,1988,771,1991,1994],{},[207,1989,1990],{},"Container",[207,1992,1993],{},"runInContainerContext"," exported",[1965,1996,1997,1998,210,2001,2004,2005,2007,2008],{},"Build the app with ",[207,1999,2000],{},"new Miia().provide()",[207,2002,2003],{},"register()",", read providers with ",[207,2006,547],{},", test with ",[207,2009,1735],{},[1950,2011,2012,2015],{},[1965,2013,2014],{},"Any provider can inject any other",[1965,2016,2017,2018,2020,2021],{},"A provider injected from another module must be in that module's ",[207,2019,274],{},", and the injecting module must import it. Infrastructure: ",[207,2022,2023],{},"configure(options, { global: true })",[1950,2025,2026,2029],{},[1965,2027,2028],{},"A module configured twice: the first configuration wins",[1965,2030,2031,2032,2035],{},"Throws ",[207,2033,2034],{},"X is configured twice",". Configure it once and import the class bare elsewhere; a second connection is a named configuration",[1950,2037,2038,2041],{},[1965,2039,2040],{},"A request-scoped provider injected anywhere",[1965,2042,2043,2046,2047,2049],{},[207,2044,2045],{},"ctx.resolve(Token)"," in a handler, middleware or guard, or ",[207,2048,389],{}," in another request-scoped provider. A singleton that injects one fails at startup",[1950,2051,2052,2060],{},[1965,2053,2054,544,2057],{},[207,2055,2056],{},"@On('topic')",[207,2058,2059],{},"publish('topic', payload)",[1965,2061,2062,2065,2066,771,2068],{},[207,2063,2064],{},"defineEvent('topic', schema)",", passed to ",[207,2067,1223],{},[207,2069,1220],{},[1950,2071,2072,2081],{},[1965,2073,2074,2076,2077,2080],{},[207,2075,1438],{}," without a schema reads the live ",[207,2078,2079],{},"process.env","; values from a schema can be mutated",[1965,2082,2083,2084,2086,2087,2089,2090,2093],{},"A snapshot taken at startup, frozen. Set ",[207,2085,2079],{}," before ",[207,2088,370],{}," or pass ",[207,2091,2092],{},"env","; copy an object or array value before mutating it",[1950,2095,2096,2101],{},[1965,2097,2098],{},[207,2099,2100],{},"DiscoveryService.getSingletons()",[1965,2102,2103,210,2106,2109,2110,548,2112],{},[207,2104,2105],{},"getClassesWithMeta(key)",[207,2107,2108],{},"getMethodsWithMeta(key)",", called from ",[207,2111,374],{},[207,2113,1052],{},[1950,2115,2116,2130],{},[1965,2117,2118,544,2120,544,2123,544,2126,2129],{},[207,2119,2003],{},[207,2121,2122],{},"use()",[207,2124,2125],{},"useGuard()",[207,2127,2128],{},"addRoute()"," at any time",[1965,2131,2132,210,2134,2137,2138,210,2140,210,2142,2086,2144,2146],{},[207,2133,2003],{},[207,2135,2136],{},"provide()"," before the graph is processed, ",[207,2139,2122],{},[207,2141,2125],{},[207,2143,2128],{},[207,2145,370],{},". A route registered twice throws",[1950,2148,2149,2154],{},[1965,2150,2151,2153],{},[207,2152,774],{}," of any token",[1965,2155,2156,2157,2160,2161,2163,2164,2167],{},"An override of a token nothing provides throws on ",[207,2158,2159],{},"compile()",". A plain-object mock is not discovered: an ",[207,2162,1194],{}," handler or a controller needs a named subclass (",[207,2165,2166],{},"class FakeHandler extends Handler {}",")",[1950,2169,2170,2179],{},[1965,2171,2172,2175,2176,2178],{},[207,2173,2174],{},"cors()"," answers every ",[207,2177,1812],{}," with 204",[1965,2180,2181,2182,2184,2185,2187],{},"Only a real preflight. An ",[207,2183,1812],{}," without ",[207,2186,1819],{}," reaches the router",[203,2189,2190,2191,2194,2195,2198,2199,2202,2203,2206],{},"One change in routing can surprise an app that serves a SPA at ",[207,2192,2193],{},"\u002F"," next to an API under ",[207,2196,2197],{},"\u002Fapi",": the SPA wildcard now also answers an unknown ",[207,2200,2201],{},"GET \u002Fapi\u002F...",", since the router backs up to it. To keep those a 404, add a catch-all under the API. With ",[207,2204,2205],{},"globalPrefix: '\u002Fapi'"," on the app:",[231,2208,2210],{"className":282,"code":2209,"language":284,"meta":236,"style":236},"app.addRoute('GET', '\u002F*', () => { throw new NotFoundException() }, { skipGlobalGuards: true })\n",[207,2211,2212],{"__ignoreMap":236},[240,2213,2214,2217,2220,2222,2225],{"class":242,"line":243},[240,2215,2216],{"class":246},"app.addRoute(",[240,2218,2219],{"class":310},"'GET'",[240,2221,544],{"class":246},[240,2223,2224],{"class":310},"'\u002F*'",[240,2226,2227],{"class":246},", () => { throw new NotFoundException() }, { skipGlobalGuards: true })\n",[203,2229,2230,2231,2234,2235,564],{},"Without a global prefix the path is written out, ",[207,2232,2233],{},"'\u002Fapi\u002F*'",". The recipe is in ",[222,2236,2238],{"href":2237},"\u002Fdocs\u002Fpackages\u002Fserve-static#spa-in-front-of-a-prefixed-api","serve-static → SPA in front of a prefixed API",[203,2240,2241,2242,2244],{},"If you know NestJS, ",[222,2243,21],{"href":22}," maps each Nest concept to its MiiaJS form, 0.9 changes included.",[203,2246,559,2247,2250,2251,2256,2257],{},[222,2248,2249],{"href":6},"miiajs.com\u002Fdocs"," · GitHub: ",[222,2252,2255],{"href":2253,"rel":2254},"https:\u002F\u002Fgithub.com\u002Fmiiajs\u002Fmiia",[1938],"miiajs\u002Fmiia"," · Examples: ",[222,2258,2261],{"href":2259,"rel":2260},"https:\u002F\u002Fgithub.com\u002Fmiiajs\u002Fmiia\u002Ftree\u002Fmain\u002Fexamples",[1938],"examples\u002F",[2263,2264,2265],"style",{},"html pre.shiki code .sQCOG, html code.shiki .sQCOG{--shiki-light:#18181B;--shiki-default:#18181B;--shiki-dark:#ECEAE4}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s4dNc, html code.shiki .s4dNc{--shiki-light:#2B4ACB;--shiki-default:#2B4ACB;--shiki-dark:#7C93FF}html pre.shiki code .sM8yr, html code.shiki .sM8yr{--shiki-light:#5F5C55;--shiki-default:#5F5C55;--shiki-dark:#A3A098}",{"title":236,"searchDepth":298,"depth":298,"links":2267},[2268,2269,2270,2271,2272,2273,2274,2275,2276],{"id":260,"depth":298,"text":261},{"id":567,"depth":298,"text":568},{"id":811,"depth":298,"text":812},{"id":1044,"depth":298,"text":1045},{"id":1180,"depth":298,"text":1181},{"id":1432,"depth":298,"text":1433},{"id":1574,"depth":298,"text":1575},{"id":1753,"depth":298,"text":1754},{"id":1930,"depth":298,"text":225},"2026-11-18","The DI system redesigned: module boundaries checked at startup, typed tokens, request-scoped providers kept on the request, two-phase shutdown, event contracts and a new CLI.","md",{},"\u002Fblog\u002Fmiiajs-0-9",{"title":197,"description":2278},"2.blog\u002Fmiiajs-0-9",[2285],"release",[2287,2288,2289,2290,2291,2292,152,2293],"modules","typed tokens","request scope","lifecycle","messaging","config","upgrading from 0.8","fo3d16uUBpOebhTS6eN0eVHp0RHmLQUxWRjMpJtSems",1795025607450]