mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 23:30:10 +00:00
fix typeof
This commit is contained in:
parent
1804f5a0bf
commit
c36754b662
@ -1,5 +1,6 @@
|
||||
import BadDataException from '../Exception/BadDataException';
|
||||
import Port from '../Port';
|
||||
import Typeof from '../Typeof';
|
||||
|
||||
export default class Hostname {
|
||||
private _route: string = '';
|
||||
@ -32,9 +33,9 @@ export default class Hostname {
|
||||
if (port instanceof Port) {
|
||||
this.port = port;
|
||||
} else if (typeof port === Typeof.String) {
|
||||
this.port = new Port(port);
|
||||
} else if (typeof port === 'number') {
|
||||
this.port = new Port(port);
|
||||
this.port = new Port(port as string);
|
||||
} else if (typeof port === Typeof.Number) {
|
||||
this.port = new Port(port as number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import PositiveNumber from '../PositiveNumber';
|
||||
import Typeof from '../Typeof';
|
||||
|
||||
export default class StatusCode {
|
||||
private _statusCode: PositiveNumber = new PositiveNumber(200);
|
||||
@ -26,7 +27,7 @@ export default class StatusCode {
|
||||
public static isValidStausCode(statusCode: number | string): boolean {
|
||||
try {
|
||||
if (typeof statusCode === Typeof.String) {
|
||||
statusCode = parseInt(statusCode);
|
||||
statusCode = parseInt(statusCode as string);
|
||||
}
|
||||
|
||||
if (statusCode >= 100 && statusCode <= 599) {
|
||||
|
@ -4,6 +4,7 @@ import Hostname from './Hostname';
|
||||
import DatabaseProperty from '../Database/DatabaseProperty';
|
||||
import { FindOperator } from 'typeorm';
|
||||
import Dictionary from '../Dictionary';
|
||||
import Typeof from '../Typeof';
|
||||
|
||||
export default class URL extends DatabaseProperty {
|
||||
private _route: Route = new Route();
|
||||
@ -129,8 +130,10 @@ export default class URL extends DatabaseProperty {
|
||||
|
||||
public addRoute(route: Route | string): URL {
|
||||
if (typeof route === Typeof.String) {
|
||||
this.route.addRoute(new Route(route));
|
||||
} else {
|
||||
this.route.addRoute(new Route(route.toString()));
|
||||
}
|
||||
|
||||
if(route instanceof Route){
|
||||
this.route.addRoute(route);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Email from './Email';
|
||||
import Typeof from './Typeof';
|
||||
|
||||
export default class EmailWithName {
|
||||
private _email: Email = new Email('noreply@oneuptime.com');
|
||||
@ -7,7 +8,7 @@ export default class EmailWithName {
|
||||
}
|
||||
public set email(v: Email | string) {
|
||||
if (typeof v === Typeof.String) {
|
||||
this._email = new Email(v);
|
||||
this._email = new Email(v.toString());
|
||||
}
|
||||
|
||||
if (v instanceof Email) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import Email from './Email';
|
||||
import { JSONObject } from './JSON';
|
||||
import Name from './Name';
|
||||
import ObjectID from './ObjectID';
|
||||
|
||||
export default interface JSONWebTokenData {
|
||||
export default interface JSONWebTokenData extends JSONObject {
|
||||
userId: ObjectID;
|
||||
email: Email;
|
||||
name: Name;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import BadDataException from './Exception/BadDataException';
|
||||
import PositiveNumber from './PositiveNumber';
|
||||
import Typeof from './Typeof';
|
||||
|
||||
export default class Port {
|
||||
private _port: PositiveNumber = new PositiveNumber(0);
|
||||
@ -13,7 +14,7 @@ export default class Port {
|
||||
public constructor(port: number | string) {
|
||||
if (typeof port === Typeof.String) {
|
||||
try {
|
||||
port = Number.parseInt(port, 10);
|
||||
port = Number.parseInt(port.toString(), 10);
|
||||
} catch (error) {
|
||||
throw new BadDataException(`Invalid port: ${port}`);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import BadDataException from './Exception/BadDataException';
|
||||
import Typeof from './Typeof';
|
||||
|
||||
export default class PositiveNumber {
|
||||
private _positiveNumber: number = 0;
|
||||
@ -11,7 +12,7 @@ export default class PositiveNumber {
|
||||
|
||||
public constructor(positiveNumber: number | string) {
|
||||
if (typeof positiveNumber === Typeof.String) {
|
||||
positiveNumber = Number.parseInt(positiveNumber, 10);
|
||||
positiveNumber = Number.parseInt(positiveNumber.toString(), 10);
|
||||
if (isNaN(positiveNumber)) {
|
||||
throw new BadDataException(`Invalid number: ${positiveNumber}`);
|
||||
}
|
||||
@ -21,7 +22,7 @@ export default class PositiveNumber {
|
||||
throw new BadDataException('positiveNumber cannot be less than 0');
|
||||
}
|
||||
|
||||
this.positiveNumber = positiveNumber;
|
||||
this.positiveNumber = positiveNumber as number;
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
|
@ -45,6 +45,7 @@ import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommon
|
||||
import QueryHelper from '../Types/Database/QueryHelper';
|
||||
import { getUniqueColumnsBy } from 'Common/Types/Database/UniqueColumnBy';
|
||||
import Search from 'Common/Types/Database/Search';
|
||||
import Typeof from 'Common/Types/Typeof';
|
||||
|
||||
enum DatabaseRequestType {
|
||||
Create = 'create',
|
||||
|
@ -15,9 +15,9 @@ class JSONWebToken {
|
||||
): string {
|
||||
let jsonObj: JSONObject;
|
||||
|
||||
if (typeof data === Typeof.String) {
|
||||
if (typeof data === "string") {
|
||||
jsonObj = {
|
||||
data,
|
||||
data: data.toString(),
|
||||
};
|
||||
} else if (!(data instanceof User)) {
|
||||
jsonObj = {
|
||||
|
@ -26,7 +26,6 @@ import PermissionUtil from '../../Utils/Permission';
|
||||
import { ColumnAccessControl } from 'Common/Types/Database/AccessControl/AccessControl';
|
||||
import { getColumnAccessControlForAllColumns } from 'Common/Types/Database/AccessControl/ColumnAccessControl';
|
||||
import Query from '../../Utils/ModelAPI/Query';
|
||||
import { instanceOf } from 'prop-types';
|
||||
import Search from 'Common/Types/Database/Search';
|
||||
import Typeof from 'Common/Types/Typeof';
|
||||
|
||||
@ -234,7 +233,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
|
||||
useEffect(() => {
|
||||
fetchItems();
|
||||
}, [currentPageNumber, sortBy, sortOrder, itemsOnPage]);
|
||||
}, [currentPageNumber, sortBy, sortOrder, itemsOnPage, query]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@ -400,6 +399,8 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
query[key as keyof TBaseModel] = !!filterData[key];
|
||||
}
|
||||
}
|
||||
|
||||
setQuery(query);
|
||||
}}
|
||||
onSortChanged={(sortBy: string, sortOrder: SortOrder) => {
|
||||
setSortBy(sortBy);
|
||||
|
@ -1,12 +1,13 @@
|
||||
import URL from 'Common/Types/API/URL';
|
||||
import Email from 'Common/Types/Email';
|
||||
import { JSONFunctions, JSONValue } from 'Common/Types/JSON';
|
||||
import { JSONFunctions, JSONObject, JSONValue } from 'Common/Types/JSON';
|
||||
import Typeof from 'Common/Types/Typeof';
|
||||
|
||||
export default class LocalStorage {
|
||||
public static setItem(key: string, value: JSONValue | Email | URL): void {
|
||||
if (typeof value === Typeof.Object) {
|
||||
// if of type jsonobject.
|
||||
value = JSON.stringify(JSONFunctions.serializeValue(value as JSONValue));
|
||||
value = JSON.stringify(JSONFunctions.serializeValue(value as JSONValue) as JSONObject);
|
||||
}
|
||||
localStorage.setItem(key, value as string);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ export default function (
|
||||
}
|
||||
|
||||
const errorCode: $TSFixMe =
|
||||
typeof error === 'number' ? error : 1;
|
||||
typeof error === Typeof.Number ? error : 1;
|
||||
process.exitCode = errorCode;
|
||||
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user