nuxt.js - 在 nuxtjs 中使用 nestjs
问题描述
为什么这不起作用https://github.com/Mitch-i/nuxt_nest?
错误 [ExceptionsHandler] 无法读取未定义的属性“findOne”类型错误:无法读取未定义的属性“findOne”
[Nest] 16671 - 09/21/2021,下午 5:00:55 错误 [ExceptionsHandler] 装饰类属性失败。请确保proposal-class-properties 已启用并在装饰器转换后运行。
但仅在我仅在正常模式下启动 nesjs 服务器时才有效(不像 nuxtjs 温和软件)。
import { NestFactory } from '@nestjs/core'
import {
FastifyAdapter,
NestFastifyApplication
} from '@nestjs/platform-fastify'
import { Request, Response } from 'express'
import { AppModule } from './app.module'
async function bootstrap () {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({ ignoreTrailingSlash: true, logger: true })
)
await app.init()
const fastify = app.getHttpAdapter().getInstance()
await fastify.ready()
return function (req: Request, res: Response) {
fastify.server.emit('request', req, res)
}
}
export default bootstrap
import { Module } from '@nestjs/common'
import { SequelizeModule } from '@nestjs/sequelize'
import { UsersModule } from './users/users.module'
@Module({
imports: [
SequelizeModule.forRoot({
dialect: 'mysql',
host: 'localhost',
port: 3306,
username: 'user',
password: 'password',
database: 'database',
autoLoadModels: true,
synchronize: true
}),
UsersModule
]
})
export class AppModule {}
import bootstrap from './server/main'
export default async () => ({
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'nuxt',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
},
serverMiddleware: [
{ path: '/api', handler: await bootstrap() }
]
})
解决方案
推荐阅读
- laravel - 使用 Docker heroku.yml 和 artisan 在 Heroku 上部署 Laravel
- events - 我们真的可以使用 Event Sourcing 和 CQRS,一种用于电子商务结账渠道的事件驱动架构吗?
- javascript - 1000 万个条目的 MongoDB 种子脚本需要 30 分钟
- excel - 如何授予 Applescript 应用程序的权利
- asp.net - IIS Windows Server 2012 - 由于捆绑/访问问题,生产网站未加载 CSS、图像或 JS
- rest - REST API 架构
- bash - 我有一个按第一列排序的制表符分隔数据框,如何在第一列的唯一值之间添加一个空行?
- python - 在python中删除joblibmem映射文件夹的Windows权限错误
- python - 我的字符串没有被读取,但是我的整数是
- javascript - 开始 Javascript 表单验证