nitro icon indicating copy to clipboard operation
nitro copied to clipboard

nitro + mikroorm

Open max5432112345 opened this issue 2 years ago • 1 comments

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.

max5432112345 avatar Jun 26 '22 10:06 max5432112345

https://github.com/nuxt/framework/issues/5603

max5432112345 avatar Aug 11 '22 08:08 max5432112345

Tracker for mikroorm for db layer: https://github.com/unjs/db0/issues/50

pi0 avatar May 16 '24 20:05 pi0