mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix
This commit is contained in:
@@ -182,7 +182,7 @@ router.post(
|
||||
const apiResponse: $TSFixMe = await axios(payload);
|
||||
const headerContentType: $TSFixMe =
|
||||
apiResponse.headers['content-type'];
|
||||
if (/text\/html/.test(headerContentType)) {
|
||||
if ((/text\/html/).test(headerContentType)) {
|
||||
return sendErrorResponse(req, res, {
|
||||
code: 400,
|
||||
message:
|
||||
@@ -391,7 +391,7 @@ router.put(
|
||||
const apiResponse: $TSFixMe = await axios(payload);
|
||||
const headerContentType: $TSFixMe =
|
||||
apiResponse.headers['content-type'];
|
||||
if (/text\/html/.test(headerContentType)) {
|
||||
if ((/text\/html/).test(headerContentType)) {
|
||||
return sendErrorResponse(req, res, {
|
||||
code: 400,
|
||||
message:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
export default function flat(arr: $TSFixMe): void {
|
||||
const flattened: $TSFixMe = [];
|
||||
(function flatten(arr: $TSFixMe): void {
|
||||
const flatten: Function = (arr: $TSFixMe): void => {
|
||||
for (const val of arr) {
|
||||
if (Array.isArray(val)) {
|
||||
flatten(val);
|
||||
@@ -14,6 +14,7 @@ export default function flat(arr: $TSFixMe): void {
|
||||
flattened.push(val);
|
||||
}
|
||||
}
|
||||
})(arr);
|
||||
};
|
||||
flatten(arr);
|
||||
return flattened;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* @return {array} a flattened array
|
||||
*/
|
||||
|
||||
export default function flat(arr: $TSFixMe): void {
|
||||
export default function flat(arr: $TSFixMe): void {
|
||||
const flattened: $TSFixMe = [];
|
||||
(function flatten(arr: $TSFixMe): void {
|
||||
const flatten: Function = (arr: $TSFixMe): void => {
|
||||
for (const val of arr) {
|
||||
if (Array.isArray(val)) {
|
||||
flatten(val);
|
||||
@@ -14,6 +14,7 @@ export default function flat(arr: $TSFixMe): void {
|
||||
flattened.push(val);
|
||||
}
|
||||
}
|
||||
})(arr);
|
||||
};
|
||||
flatten(arr);
|
||||
return flattened;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
export default function flat(arr: $TSFixMe): void {
|
||||
const flattened: $TSFixMe = [];
|
||||
(function flatten(arr: $TSFixMe): void {
|
||||
const flatten: Function = (arr: $TSFixMe): void => {
|
||||
for (const val of arr) {
|
||||
if (Array.isArray(val)) {
|
||||
flatten(val);
|
||||
@@ -14,6 +14,7 @@ export default function flat(arr: $TSFixMe): void {
|
||||
flattened.push(val);
|
||||
}
|
||||
}
|
||||
})(arr);
|
||||
};
|
||||
flatten(arr);
|
||||
return flattened;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
import logger from 'CommonServer/utils/Logger';
|
||||
import app from 'CommonServer/utils/StartServer';
|
||||
|
||||
import http from 'http';
|
||||
http.createServer(app);
|
||||
|
||||
import { mongoUrl, databaseName } from './utils/config';
|
||||
const MongoClient: $TSFixMe = require('mongodb').MongoClient;
|
||||
|
||||
// Mongodb
|
||||
function getMongoClient(): void {
|
||||
return new MongoClient(mongoUrl, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
}
|
||||
// Setup mongodb connection
|
||||
const client: $TSFixMe = getMongoClient();
|
||||
(async function (): void {
|
||||
try {
|
||||
logger.info('connecting to db');
|
||||
await client.connect();
|
||||
logger.info('connected to db');
|
||||
} catch (error) {
|
||||
logger.error('connection error: ', error);
|
||||
}
|
||||
})();
|
||||
|
||||
// Attach the database to global object
|
||||
|
||||
global.db = client.db(databaseName);
|
||||
|
||||
app.use(['/data-ingestor/probe', '/probe'], require('./api/probe'));
|
||||
|
||||
export default app;
|
||||
|
||||
@@ -50,10 +50,11 @@ class OneUptimeListener {
|
||||
// This will reset the state of the timeline array
|
||||
return this.timelineObj.clearTimeline();
|
||||
}
|
||||
|
||||
// Set up console listener
|
||||
private _setUpConsoleListener(): void {
|
||||
// Set up a console listener get the current content, pass it to the normal console and also pass it to the timeline event listener
|
||||
const console: Function = (function (oldCons: $TSFixMe): void {
|
||||
const consoleFunc: Function = (oldCons: $TSFixMe): void => {
|
||||
return {
|
||||
log: function (text: $TSFixMe): void {
|
||||
oldCons.log(text);
|
||||
@@ -81,9 +82,10 @@ class OneUptimeListener {
|
||||
);
|
||||
},
|
||||
};
|
||||
})(global.console);
|
||||
//Then redefine the old console
|
||||
};
|
||||
|
||||
const console = consoleFunc(global.console);
|
||||
//Then redefine the old console
|
||||
global.console = console;
|
||||
}
|
||||
// Set up dom listener
|
||||
|
||||
@@ -8,8 +8,6 @@ import logger from 'CommonServer/Utils/Logger';
|
||||
import path from 'path';
|
||||
const app: $TSFixMe = express.getExpressApp();
|
||||
|
||||
import https from 'https';
|
||||
import http from 'http';
|
||||
import tls from 'tls';
|
||||
import fs from 'fs';
|
||||
|
||||
@@ -17,43 +15,6 @@ import fetch from 'node-fetch';
|
||||
import { spawn } from 'child_process';
|
||||
import axios from 'axios';
|
||||
|
||||
import cors from 'cors';
|
||||
|
||||
// Mongodb
|
||||
const MongoClient: $TSFixMe = require('mongodb').MongoClient;
|
||||
const mongoUrl: $TSFixMe =
|
||||
process.env.MONGO_URL || 'mongodb://localhost:27017/oneuptimedb';
|
||||
|
||||
const { NODE_ENV }: $TSFixMe = process.env;
|
||||
|
||||
function getMongoClient(): void {
|
||||
return new MongoClient(mongoUrl, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Setup mongodb connection
|
||||
const client: $TSFixMe = getMongoClient();
|
||||
(async function (): void {
|
||||
try {
|
||||
logger.info('connecting to db');
|
||||
await client.connect();
|
||||
|
||||
logger.info('connected to db');
|
||||
} catch (error) {
|
||||
logger.info('connection error: ', error);
|
||||
}
|
||||
})();
|
||||
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /StatusPage/.env
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
app.use(cors());
|
||||
|
||||
let apiHost: $TSFixMe = 'http://localhost:3002/api';
|
||||
if (process.env.BACKEND_URL) {
|
||||
apiHost = 'http://' + process.env.BACKEND_URL + '/api';
|
||||
@@ -200,7 +161,7 @@ app.use(
|
||||
|
||||
try {
|
||||
const response: $TSFixMe = await handleCustomDomain(
|
||||
client,
|
||||
global.MongoClient,
|
||||
'statuspages',
|
||||
host
|
||||
);
|
||||
@@ -344,12 +305,7 @@ function countFreq(pat: $TSFixMe, txt: $TSFixMe): void {
|
||||
* Using an IIFE here because we have an asynchronous code we want to run as we start the server
|
||||
* And since we can't await outside an async function, we had to use an IIFE to handle that
|
||||
*/
|
||||
(async function (): void {
|
||||
// Create http server
|
||||
http.createServer(app).listen(3006, () => {
|
||||
return logger.info('Server running on port 3006');
|
||||
});
|
||||
|
||||
const setupCerts: Function = async (): void => {
|
||||
try {
|
||||
// Create https server
|
||||
await createDir('credentials');
|
||||
@@ -521,13 +477,11 @@ function countFreq(pat: $TSFixMe, txt: $TSFixMe): void {
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
https.createServer(options, app).listen(3007, () => {
|
||||
logger.info('Server running on port 3007');
|
||||
});
|
||||
} catch (e) {
|
||||
logger.info('Unable to create HTTPS Server');
|
||||
|
||||
logger.info(e);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
setupCerts();
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"uninstall": "docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)",
|
||||
"delete-all-local-branches": "git branch | grep -v 'master' | xargs git branch -D",
|
||||
"lint": "ejslint home/views/*.ejs && eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore",
|
||||
"fix-lint": "eslint --fix '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore",
|
||||
"fix-lint": "eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore --fix",
|
||||
"fix": "npm run fix-lint",
|
||||
"build": "docker-compose --env-file ./docker-enterprise.env build",
|
||||
"build-dev": "docker-compose --env-file ./docker-enterprise.env -f docker-compose.dev.yml build $npm_config_services",
|
||||
|
||||
Reference in New Issue
Block a user