Skip to content

Commit 71965e6

Browse files
authored
Fix: Update TypeScript configuration and refactor imports (#5869)
1 parent c0598ac commit 71965e6

File tree

5 files changed

+23
-36
lines changed

5 files changed

+23
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"test-e2e-ui": "playwright test --config ./config/playwright.config.js --ui --ui-port=51063",
3333
"playwright-codegen": "playwright codegen localhost:3000 --save-storage=./private/e2e-auth.json",
3434
"playwright-show-report": "playwright show-report ./private/playwright-report",
35-
"tsc": "tsc",
35+
"tsc": "tsc --project ./tsconfig-backend.json",
3636
"vite-preview-dist": "vite preview --host --config ./config/vite.config.js",
3737
"build-docker-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base2 --target base2 . --push",
3838
"build-docker-base-slim": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base2-slim --target base2-slim . --push",

src/util.js

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,12 @@
88
// Backend uses the compiled file util.js
99
// Frontend uses util.ts
1010
*/
11-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12-
if (k2 === undefined) k2 = k;
13-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
14-
}) : (function(o, m, k, k2) {
15-
if (k2 === undefined) k2 = k;
16-
o[k2] = m[k];
17-
}));
18-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19-
Object.defineProperty(o, "default", { enumerable: true, value: v });
20-
}) : function(o, v) {
21-
o["default"] = v;
22-
});
23-
var __importStar = (this && this.__importStar) || function (mod) {
24-
if (mod && mod.__esModule) return mod;
25-
var result = {};
26-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27-
__setModuleDefault(result, mod);
28-
return result;
29-
};
30-
var __importDefault = (this && this.__importDefault) || function (mod) {
31-
return (mod && mod.__esModule) ? mod : { "default": mod };
32-
};
3311
var _a;
3412
Object.defineProperty(exports, "__esModule", { value: true });
3513
exports.CONSOLE_STYLE_FgPink = exports.CONSOLE_STYLE_FgBrown = exports.CONSOLE_STYLE_FgViolet = exports.CONSOLE_STYLE_FgLightBlue = exports.CONSOLE_STYLE_FgLightGreen = exports.CONSOLE_STYLE_FgOrange = exports.CONSOLE_STYLE_FgGray = exports.CONSOLE_STYLE_FgWhite = exports.CONSOLE_STYLE_FgCyan = exports.CONSOLE_STYLE_FgMagenta = exports.CONSOLE_STYLE_FgBlue = exports.CONSOLE_STYLE_FgYellow = exports.CONSOLE_STYLE_FgGreen = exports.CONSOLE_STYLE_FgRed = exports.CONSOLE_STYLE_FgBlack = exports.CONSOLE_STYLE_Hidden = exports.CONSOLE_STYLE_Reverse = exports.CONSOLE_STYLE_Blink = exports.CONSOLE_STYLE_Underscore = exports.CONSOLE_STYLE_Dim = exports.CONSOLE_STYLE_Bright = exports.CONSOLE_STYLE_Reset = exports.PING_PER_REQUEST_TIMEOUT_DEFAULT = exports.PING_PER_REQUEST_TIMEOUT_MAX = exports.PING_PER_REQUEST_TIMEOUT_MIN = exports.PING_COUNT_DEFAULT = exports.PING_COUNT_MAX = exports.PING_COUNT_MIN = exports.PING_GLOBAL_TIMEOUT_DEFAULT = exports.PING_GLOBAL_TIMEOUT_MAX = exports.PING_GLOBAL_TIMEOUT_MIN = exports.PING_PACKET_SIZE_DEFAULT = exports.PING_PACKET_SIZE_MAX = exports.PING_PACKET_SIZE_MIN = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isNode = exports.isDev = void 0;
3614
exports.evaluateJsonQuery = exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.CONSOLE_STYLE_BgGray = exports.CONSOLE_STYLE_BgWhite = exports.CONSOLE_STYLE_BgCyan = exports.CONSOLE_STYLE_BgMagenta = exports.CONSOLE_STYLE_BgBlue = exports.CONSOLE_STYLE_BgYellow = exports.CONSOLE_STYLE_BgGreen = exports.CONSOLE_STYLE_BgRed = exports.CONSOLE_STYLE_BgBlack = void 0;
37-
const dayjs_1 = __importDefault(require("dayjs"));
38-
const jsonata = __importStar(require("jsonata"));
15+
const dayjs = require("dayjs");
16+
const jsonata = require("jsonata");
3917
exports.isDev = process.env.NODE_ENV === "development";
4018
exports.isNode = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
4119
exports.appName = "Uptime Kuma";
@@ -187,11 +165,11 @@ class Logger {
187165
module = module.toUpperCase();
188166
level = level.toUpperCase();
189167
let now;
190-
if (dayjs_1.default.tz) {
191-
now = dayjs_1.default.tz(new Date()).format();
168+
if (dayjs.tz) {
169+
now = dayjs.tz(new Date()).format();
192170
}
193171
else {
194-
now = (0, dayjs_1.default)().format();
172+
now = dayjs().format();
195173
}
196174
const levelColor = consoleLevelColors[level];
197175
const moduleColor = consoleModuleColors[intHash(module, consoleModuleColors.length)];
@@ -292,11 +270,11 @@ function polyfill() {
292270
exports.polyfill = polyfill;
293271
class TimeLogger {
294272
constructor() {
295-
this.startTime = (0, dayjs_1.default)().valueOf();
273+
this.startTime = dayjs().valueOf();
296274
}
297275
print(name) {
298276
if (exports.isDev && process.env.TIMELOGGER === "1") {
299-
console.log(name + ": " + ((0, dayjs_1.default)().valueOf() - this.startTime) + "ms");
277+
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
300278
}
301279
}
302280
}
@@ -408,19 +386,19 @@ function parseTimeFromTimeObject(obj) {
408386
}
409387
exports.parseTimeFromTimeObject = parseTimeFromTimeObject;
410388
function isoToUTCDateTime(input) {
411-
return (0, dayjs_1.default)(input).utc().format(exports.SQL_DATETIME_FORMAT);
389+
return dayjs(input).utc().format(exports.SQL_DATETIME_FORMAT);
412390
}
413391
exports.isoToUTCDateTime = isoToUTCDateTime;
414392
function utcToISODateTime(input) {
415-
return dayjs_1.default.utc(input).toISOString();
393+
return dayjs.utc(input).toISOString();
416394
}
417395
exports.utcToISODateTime = utcToISODateTime;
418396
function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) {
419-
return dayjs_1.default.utc(input).local().format(format);
397+
return dayjs.utc(input).local().format(format);
420398
}
421399
exports.utcToLocal = utcToLocal;
422400
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
423-
return (0, dayjs_1.default)(input).utc().format(format);
401+
return dayjs(input).utc().format(format);
424402
}
425403
exports.localToUTC = localToUTC;
426404
function intHash(str, length = 10) {

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Frontend uses util.ts
1010
*/
1111

12-
import dayjs from "dayjs";
12+
import * as dayjs from "dayjs";
1313

1414
// For loading dayjs plugins, don't remove event though it is not used in this file
1515
// eslint-disable-next-line @typescript-eslint/no-unused-vars

tsconfig-backend.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"esModuleInterop": false
5+
},
6+
"files": [
7+
"./src/util.ts"
8+
]
9+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"esModuleInterop": true
1717
},
1818
"files": [
19-
"./src/util.ts"
19+
2020
]
2121
}

0 commit comments

Comments
 (0)