Hello, node-heads I'm installing node-red in a nest.js app and I'm getting the following error when running/starting the server. I have no clue how to fix this issue and documentation for nest.js apps is quite scarce. Any help is highly appreciated...
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { json } from 'express';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.use(json({ limit: '50mb' }));
const config = new DocumentBuilder()
.setTitle('OAST')
.setDescription('The OAST API description')
.setVersion('0.1')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
/**
* Configure node-red
*/
const httpAdapter = app.getHttpAdapter();
const RED = require('node-red');
// Settings object for node-red
const nodeRedSettings = {
httpAdminRoot: '/red',
httpNodeRoot: '/api',
userDir: '/home/nol/.nodered/',
functionGlobalContext: {}, // enables global context
};
RED.init(httpAdapter, nodeRedSettings);
// Serve the editor UI from /red
app.use(nodeRedSettings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(nodeRedSettings.httpNodeRoot, RED.httpNode);
await app.listen(3001);
// Start the runtime
RED.start();
}
bootstrap();