我无法在node.js中使用'microframework-w3tec'和'express'实现https

问题描述

我有这个装载程序,它工作正常。 但是我需要将http更改为https,我尝试仅将https的导入http更改,但是当我运行它时,在下面显示错误。我如何使用https whitout https.createServer?

import { Application } from 'express';
import { Server } from 'http';
import { MicroframeworkLoader,MicroframeworkSettings } from 'microframework-w3tec';
import { createExpressServer } from 'routing-controllers';

import { authorizationChecker } from '../auth/authorizationChecker';
import { currentUserChecker } from '../auth/currentUserChecker';
import { env } from '../env';

export const expressLoader: MicroframeworkLoader = (settings: MicroframeworkSettings | undefined) => {
if (settings) {
    const connection = settings.getData('connection');

    /**
     * We create a new express server instance.
     * We Could have also use useExpressServer here to attach controllers to an existing express instance.
     */
    const expressApp: Application = createExpressServer({
        cors: true,classtransformer: true,routePrefix: env.app.routePrefix,defaultErrorHandler: false,/**
         * We can add options about how routing-controllers should configure itself.
         * Here we specify what controllers should be registered in our express server.
         */
        controllers: env.app.dirs.controllers,middlewares: env.app.dirs.middlewares,interceptors: env.app.dirs.interceptors,/**
         * Authorization features
         */
        authorizationChecker: authorizationChecker(connection),currentUserChecker: currentUserChecker(connection),});

    // Run application to listen on given port
    if (!env.isTest) {
        
        const server: Server =  expressApp.listen(env.app.port);
        settings.setData("express_app",server);
    }

    // Here we can set the data for other loaders
    settings.setData('express_app',expressApp);
}
};

错误

src/loaders/expressLoader.ts(56,19): error TS2719: Type 'Server' is not assignable to type 'Server'. Two different types with this name exist,but they are unrelated.
Property 'addContext' is missing in type 'Server'.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)