Skip to content

Commit 0e8a3b2

Browse files
B4nanclaude
andcommitted
fix: properly await RequestContext, move config to project root
- Make middleware async and explicitly await next() inside the RequestContext callback to preserve async local storage context - Move mikro-orm.config.ts from src/ to project root Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f58d6aa commit 0e8a3b2

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/middleware/mikro_orm_middleware.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import type { NextFn } from '@adonisjs/core/types/http'
1212
export default class MikroOrmMiddleware {
1313
constructor(protected orm: MikroORM) {}
1414

15-
handle(_ctx: HttpContext, next: NextFn) {
16-
return RequestContext.create(this.orm.em, () => next())
15+
async handle(_ctx: HttpContext, next: NextFn) {
16+
await RequestContext.create(this.orm.em, async () => {
17+
await next()
18+
})
1719
}
1820
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"mikro-orm": {
6262
"useTsNode": true,
6363
"configPaths": [
64-
"./src/mikro-orm.config.ts"
64+
"./mikro-orm.config.ts"
6565
]
6666
}
6767
}

providers/mikro_orm_provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MikroORM, EntityManager } from '@mikro-orm/sqlite'
22
import type { ApplicationService } from '@adonisjs/core/types'
3-
import config from '../src/mikro-orm.config.js'
3+
import config from '../mikro-orm.config.js'
44
import { UserRepository } from '#repositories/user_repository'
55
import { ArticleRepository } from '#repositories/article_repository'
66
import { UserSchema } from '#entities/user'

0 commit comments

Comments
 (0)