UNPKG

@frontity/core

Version:

The core package of the Frontity framework.

26 lines (24 loc) 692 B
import { readFile } from "fs-extra"; import express from "express"; import * as http from "http"; import * as https from "https"; // Create HTTP or HTTPS server using a self-signed certificate. export default async ({ app, isHttps = true, }: { app: express.Express; isHttps: boolean; }): Promise<http.Server | https.Server> => { if (isHttps) { const key = await readFile( "./node_modules/@frontity/core/certs/localhost.key" ); const cert = await readFile( "./node_modules/@frontity/core/certs/localhost.cert" ); const options: https.ServerOptions = { key, cert }; return https.createServer(options, app); } return http.createServer(app); };