多个同步服务器
优质
小牛编辑
148浏览
2023-12-01
多个同步服务器
Since you have full control of express instance lifecycle, it's not a problem to create a few multiple simultaneous servers (e.g. both HTTP & HTTPS). Example:
因为你已经可以完全控制express
实例的生命周期了,所以创建多个同步同步服务器(例如HTTP & HTTPS
)也是很简单的。
示例:
let httpsOptions = {
key: fs.readFileSync("./secrets/private-key.pem"),
cert: fs.readFileSync("./secrets/public-certificate.pem")
};
const server = express();
const app = NestFactory.create(ApplicationModule, server);
app.init();
http.createServer(server).listen(3000);
https.createServer(httpsOptions, server).listen(443);