repacked
Version:
## Initialization
62 lines (59 loc) • 2.46 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// src/features/server/server.ts
var import_express = __toESM(require("express"));
var expressServer = () => {
const app = (0, import_express.default)();
return app;
};
// src/features/server/runtimes/runtime.prod.ts
var import_express2 = __toESM(require("express"));
var import_path = __toESM(require("path"));
var import_connect_history_api_fallback = __toESM(require("connect-history-api-fallback"));
var import_yargs = __toESM(require("yargs"));
var import_server2 = __toESM(require("virtual:repacked/server"));
var serve = async (port) => {
const config = process.env.__INTERNAL_REPACKED_SERVER_CONFIG;
const clientEnabled = config.client.enabled;
const app = expressServer();
(0, import_server2.default)(app);
if (clientEnabled) {
app.use((0, import_connect_history_api_fallback.default)());
const publicAssets = import_path.default.join(__dirname, "client");
app.use(import_express2.default.static(publicAssets));
}
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
};
var exec = async () => {
const argv = await import_yargs.default.option("port", {
alias: "p",
description: "Port to run the server on",
type: "number",
default: 3e3
}).help().argv;
serve(argv.port);
};
exec();