nitro
nitro copied to clipboard
nitro + mikroorm
Environment
- Operating System:
Linux
- Node Version:
v16.15.1
- Nuxt Version:
3.0.0-rc.4
- Package Manager:
[email protected]
- Typescript:
Version 4.7.4
- Mikro-orm:
5.2.1
- Driver:
mariadb
Reproduction
https://github.com/nuxt/framework/issues/5603
Describe the bug
How to work with that if no nex() function
import { RequestContext } from '@mikro-orm/core'
import { DI } from '../data-source'
export default defineEventHandler(async (event) => {
RequestContext.create(DI.orm.em, () => {
setTimeout(() => {}, 200)
})
})
Legacy support is possible using https://github.com/unjs/h3, but it advised to avoid legacy handlers as much as you can.
export default (req, res, next) => {
console.log('Legacy middleware')
next()
}
But that also not work.
Additional context
No response
Logs
[nitro] [dev] [unhandledRejection] ValidationError: Using global EntityManager instance methods for context specific actions is disallowed. If you need to work with the global instance's iden
tity map, use `allowGlobalContext` configuration option or `fork()` instead.
https://github.com/nuxt/framework/issues/5603
Tracker for mikroorm for db layer: https://github.com/unjs/db0/issues/50