mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix serve
This commit is contained in:
@@ -16,11 +16,6 @@ app.use(ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(
|
||||
[`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`],
|
||||
ExpressStatic(path.join(__dirname, 'dist'))
|
||||
);
|
||||
|
||||
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
||||
});
|
||||
@@ -22,7 +22,7 @@
|
||||
"build": "webpack build --mode=production",
|
||||
"test": "",
|
||||
"compile": "tsc",
|
||||
"start": "node --require ts-node/register Index.ts",
|
||||
"start": "node --require ts-node/register Serve.ts",
|
||||
"audit": "npm audit --audit-level=low",
|
||||
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
|
||||
"dep-check": "depcheck ./ --skip-missing=true'"
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from 'Common/Types/Permission';
|
||||
import UserType from 'Common/Types/UserType';
|
||||
import Dictionary from 'Common/Types/Dictionary';
|
||||
import Port from 'Common/Types/Port';
|
||||
|
||||
export type RequestHandler = express.RequestHandler;
|
||||
export type NextFunction = express.NextFunction;
|
||||
@@ -63,14 +64,14 @@ class Express {
|
||||
}
|
||||
|
||||
public static async launchApplication(
|
||||
appName: string
|
||||
appName: string, port?: Port
|
||||
): Promise<express.Application> {
|
||||
return new Promise<express.Application>((resolve: Function) => {
|
||||
if (!this.app) {
|
||||
this.setupExpress();
|
||||
}
|
||||
|
||||
this.app.listen(this.app.get('port'), () => {
|
||||
this.app.listen(port?.toNumber() || this.app.get('port'), () => {
|
||||
// eslint-disable-next-line
|
||||
logger.info(`${appName} server started on port: ${this.app.get('port')}`);
|
||||
return resolve(this.app);
|
||||
|
||||
@@ -2,7 +2,7 @@ import './Envrionment';
|
||||
import './Process';
|
||||
import logger from './Logger';
|
||||
import cors from 'cors';
|
||||
|
||||
import Port from 'Common/Types/Port';
|
||||
import Express, {
|
||||
ExpressRequest,
|
||||
ExpressResponse,
|
||||
@@ -89,8 +89,8 @@ app.use(ExpressUrlEncoded({ limit: '50mb' }));
|
||||
|
||||
app.use(logRequest);
|
||||
|
||||
const init: Function = async (appName: string): Promise<ExpressApplication> => {
|
||||
await Express.launchApplication(appName);
|
||||
const init: Function = async (appName: string, port?: Port): Promise<ExpressApplication> => {
|
||||
await Express.launchApplication(appName, port);
|
||||
LocalCache.setString('app', 'name', appName);
|
||||
CommonAPI(appName);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import Express, {
|
||||
} from 'CommonServer/Utils/Express';
|
||||
import logger from 'CommonServer/Utils/Logger';
|
||||
|
||||
export const APP_NAME: string = 'dashboard';
|
||||
export const APP_NAME: string = 'accounts';
|
||||
|
||||
const app: ExpressApplication = Express.getExpressApp();
|
||||
|
||||
@@ -16,11 +16,6 @@ app.use(ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(
|
||||
[`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`],
|
||||
ExpressStatic(path.join(__dirname, 'dist'))
|
||||
);
|
||||
|
||||
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
||||
});
|
||||
@@ -27,7 +27,7 @@
|
||||
"test": "react-app-rewired test",
|
||||
"eject": "webpack eject",
|
||||
"compile": "tsc",
|
||||
"start": "node --require ts-node/register Index.ts",
|
||||
"start": "node --require ts-node/register Serve.ts",
|
||||
"audit": "npm audit --audit-level=low",
|
||||
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
|
||||
"dep-check": "depcheck ./ --skip-missing=true'"
|
||||
|
||||
36
StatusPage/Serve.ts
Normal file
36
StatusPage/Serve.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import App from 'CommonServer/Utils/StartServer';
|
||||
import path from 'path';
|
||||
import Express, {
|
||||
ExpressApplication,
|
||||
ExpressRequest,
|
||||
ExpressResponse,
|
||||
ExpressStatic,
|
||||
} from 'CommonServer/Utils/Express';
|
||||
import logger from 'CommonServer/Utils/Logger';
|
||||
import Port from 'Common/Types/Port';
|
||||
|
||||
export const APP_NAME: string = 'accounts';
|
||||
|
||||
const app: ExpressApplication = Express.getExpressApp();
|
||||
|
||||
app.use(ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public')));
|
||||
|
||||
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
||||
});
|
||||
|
||||
const init: Function = async (): Promise<void> => {
|
||||
try {
|
||||
// init the app
|
||||
await App(APP_NAME, new Port(3106));
|
||||
} catch (err) {
|
||||
logger.error('App Init Failed:');
|
||||
logger.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
export default app;
|
||||
@@ -25,7 +25,7 @@
|
||||
"test": "react-app-rewired test",
|
||||
"eject": "webpack eject",
|
||||
"compile": "tsc",
|
||||
"start": "http-server ./public -p 3105 & node --require ts-node/register Index.ts",
|
||||
"start": "node --require ts-node/register Serve.ts & node --require ts-node/register Index.ts",
|
||||
"audit": "npm audit --audit-level=low",
|
||||
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
|
||||
"dep-check": "depcheck ./ --skip-missing=true'"
|
||||
|
||||
Reference in New Issue
Block a user