This commit is contained in:
Nawaz Dhandala
2022-03-19 15:46:13 +00:00
parent a2df57f69c
commit 8a70d8a6f1
212 changed files with 5820 additions and 2737 deletions

View File

@@ -1,7 +1,11 @@
import 'common-server/utils/env';
import 'common-server/utils/process';
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import path from 'path';
const app = express();
@@ -9,10 +13,7 @@ import compression from 'compression';
app.use(compression());
app.get(['/env.js', '/accounts/env.js'], function (
req: Request,
res: Response
) {
app.get(['/env.js', '/accounts/env.js'], function(req: Request, res: Response) {
const env = {
REACT_APP_IS_SAAS_SERVICE: process.env.IS_SAAS_SERVICE,
REACT_APP_DISABLE_SIGNUP: process.env.DISABLE_SIGNUP,
@@ -69,7 +70,7 @@ app.use(
app.use('/accounts', express.static(path.join(__dirname, 'build')));
app.get('/*', function (req: Request, res: Response) {
app.get('/*', function(req: Request, res: Response) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

View File

@@ -17,11 +17,15 @@ process.on('uncaughtException', err => {
console.error(err);
});
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import path from 'path';
const app = express();
app.get(['/env.js', '/admin/env.js'], function (req: Request, res: Response) {
app.get(['/env.js', '/admin/env.js'], function(req: Request, res: Response) {
const env = {
REACT_APP_IS_SAAS_SERVICE: process.env.IS_SAAS_SERVICE,
REACT_APP_LICENSE_URL: process.env.LICENSE_URL,
@@ -34,7 +38,7 @@ app.get(['/env.js', '/admin/env.js'], function (req: Request, res: Response) {
res.send('window._env = ' + JSON.stringify(env));
});
app.get(['/admin/status', '/status'], function (req: Request, res: Response) {
app.get(['/admin/status', '/status'], function(req: Request, res: Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({
@@ -52,7 +56,7 @@ app.use(
express.static(path.join(__dirname, 'build/static/js'))
);
app.get('/*', function (req: Request, res: Response) {
app.get('/*', function(req: Request, res: Response) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

View File

@@ -0,0 +1,103 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react" /* Specify what JSX code is generated. */,
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./types/"
] /* Specify multiple folders that act like `./node_modules/@types`. */,
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@@ -17,7 +17,11 @@ process.on('uncaughtException', err => {
console.error(err);
});
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const app = express();
import path from 'path';
import version from './api/version';
@@ -45,7 +49,7 @@ process.on('uncaughtException', err => {
console.error(err);
});
app.use(function (req: Request, res: Response, next: $TSFixMe) {
app.use(function(req: Request, res: Response, next: $TSFixMe) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -81,11 +85,11 @@ app.use(
);
// index page
app.get(['/', '/docs'], function (req: Request, res: Response) {
app.get(['/', '/docs'], function(req: Request, res: Response) {
res.render('pages/index');
});
app.listen(app.get('port'), function () {
app.listen(app.get('port'), function() {
// eslint-disable-next-line no-console
console.log('API Reference started on PORT:' + app.get('port'));
});

View File

@@ -28,6 +28,7 @@
"scripts": {
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
"start": "ts-node index.ts",
"build": "tsc index.ts",
"dev": "cross-env NODE_ENV=development ts-node-dev server.js",
"test": "cross-env NODE_ENV=development mocha --exit test/index.ts",
"audit": "npm audit --audit-level=low",

103
api-docs/tsconfig.json Normal file
View File

@@ -0,0 +1,103 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react" /* Specify what JSX code is generated. */,
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./types/"
] /* Specify multiple folders that act like `./node_modules/@types`. */,
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@@ -1,7 +1,11 @@
import 'common-server/utils/env';
import 'common-server/utils/process';
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const app = express();
import http from 'http';
@@ -18,7 +22,7 @@ const cronApplicationSecurityStartTime = Math.floor(Math.random() * 50);
app.use(cors());
app.set('port', process.env.PORT || 3005);
app.get(['/application/status', '/status'], function (
app.get(['/application/status', '/status'], function(
req: Request,
res: Response
) {
@@ -34,7 +38,7 @@ app.get(['/application/status', '/status'], function (
//App Version
app.get(['/application/version', '/version'], function (
app.get(['/application/version', '/version'], function(
req: Request,
res: Response
) {
@@ -49,7 +53,7 @@ cron.schedule('*/5 * * * *', () => {
}, cronApplicationSecurityStartTime * 1000);
});
http.listen(app.get('port'), function () {
http.listen(app.get('port'), function() {
// eslint-disable-next-line
console.log(
`Application Scanner Started on port ${app.get(

View File

@@ -0,0 +1,103 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react" /* Specify what JSX code is generated. */,
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./types/"
] /* Specify multiple folders that act like `./node_modules/@types`. */,
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import alertService from '../services/alertService';
import IncidentService from '../services/incidentService';
import alertChargeService from '../services/alertChargeService';
@@ -18,7 +22,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -43,7 +47,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
});
// Fetch alerts by projectId
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
req,
res
) {
@@ -58,7 +62,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function
}
});
router.get('/:projectId/alert', getUser, isAuthorized, async function (
router.get('/:projectId/alert', getUser, isAuthorized, async function(
req,
res
) {
@@ -93,7 +97,7 @@ router.get(
'/:projectId/incident/:incidentSlug',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const incidentSlug = req.params.incidentSlug;
// const projectId = req.params.projectId;
@@ -142,7 +146,7 @@ router.get(
);
// Mark alert as viewed. This is for Email.
router.get('/:projectId/:alertId/viewed', async function (
router.get('/:projectId/:alertId/viewed', async function(
req: Request,
res: Response
) {
@@ -171,7 +175,7 @@ router.get('/:projectId/:alertId/viewed', async function (
}
});
router.delete('/:projectId', getUser, isUserOwner, async function (
router.delete('/:projectId', getUser, isUserOwner, async function(
req: Request,
res: Response
) {
@@ -195,7 +199,7 @@ router.delete('/:projectId', getUser, isUserOwner, async function (
}
});
router.get('/:projectId/alert/charges', getUser, isAuthorized, async function (
router.get('/:projectId/alert/charges', getUser, isAuthorized, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ApplicationLogService from '../services/applicationLogService';
import UserService from '../services/userService';
import ComponentService from '../services/componentService';
@@ -34,7 +38,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const componentId = req.params.componentId;
@@ -104,7 +108,7 @@ router.post(
);
// Description: Get all Application Logs by componentId.
router.get('/:projectId/:componentId', getUser, isAuthorized, async function (
router.get('/:projectId/:componentId', getUser, isAuthorized, async function(
req,
res
) {
@@ -135,7 +139,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { applicationLogId, componentId } = req.params;
try {
const applicationLog = await ApplicationLogService.deleteBy(
@@ -160,7 +164,7 @@ router.delete(
}
);
router.post('/:applicationLogId/log', isApplicationLogValid, async function (
router.post('/:applicationLogId/log', isApplicationLogValid, async function(
req,
res
) {
@@ -196,7 +200,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/logs',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { skip, limit, startDate, endDate, type, filter } = req.body;
const applicationLogId = req.params.applicationLogId;
@@ -256,7 +260,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/stats',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const applicationLogId = req.params.applicationLogId;
@@ -311,7 +315,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const applicationLogId = req.params.applicationLogId;
const currentApplicationCount = await ApplicationLogService.countBy({
@@ -348,7 +352,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { applicationLogId, componentId } = req.params;
const data = req.body;
@@ -446,7 +450,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/search',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { applicationLogId } = req.params;
const startTime = new Date();
const { duration, filter, range } = req.body;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ApplicationSecurityService from '../services/applicationSecurityService';
import ApplicationSecurityLogService from '../services//applicationSecurityLogService';
const router = express.getRouter();
@@ -24,7 +28,7 @@ import ErrorService from 'common-server/utils/error';
router.get(
'/applicationSecurities',
isAuthorizedApplicationScanner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const response = await ApplicationSecurityService.getSecuritiesToScan();
return sendItemResponse(req, res, response);
@@ -34,7 +38,7 @@ router.get(
}
);
router.post('/scanning', isAuthorizedApplicationScanner, async function (
router.post('/scanning', isAuthorizedApplicationScanner, async function(
req,
res
) {
@@ -57,7 +61,7 @@ router.post('/scanning', isAuthorizedApplicationScanner, async function (
return sendErrorResponse(req, res, error);
}
});
router.post('/failed', isAuthorizedApplicationScanner, async function (
router.post('/failed', isAuthorizedApplicationScanner, async function(
req,
res
) {
@@ -74,7 +78,7 @@ router.post('/failed', isAuthorizedApplicationScanner, async function (
return sendErrorResponse(req, res, error);
}
});
router.post('/log', isAuthorizedApplicationScanner, async function (
router.post('/log', isAuthorizedApplicationScanner, async function(
req: Request,
res: Response
) {
@@ -265,7 +269,7 @@ router.post('/log', isAuthorizedApplicationScanner, async function (
}
});
router.post('/time', isAuthorizedApplicationScanner, async function (
router.post('/time', isAuthorizedApplicationScanner, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import AuditLogsService from '../services/auditLogsService';
@@ -11,7 +15,7 @@ import { sendListResponse } from 'common-server/utils/response';
import { sendItemResponse } from 'common-server/utils/response';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -43,7 +47,7 @@ router.get('/', getUser, isUserMasterAdmin, async function (
}
});
router.post('/search', getUser, isUserMasterAdmin, async function (
router.post('/search', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -63,7 +67,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/', getUser, isUserMasterAdmin, async function (
router.delete('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import AutomatedScriptService from '../services/automatedScriptService';
@@ -12,7 +16,7 @@ import { isAuthorized } from '../middlewares/authorization';
import { getUser } from '../middlewares/user';
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -246,7 +250,7 @@ router.delete(
'/:projectId/:automatedSlug',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, automatedSlug } = req.params;
const query = {

View File

@@ -23,7 +23,7 @@ export default ({
friendlyResourceName,
service,
}: $TSFixMe) => {
const getItemMiddleware = async function (req: Request, res: Response) {
const getItemMiddleware = async function(req: Request, res: Response) {
try {
let item = null;
@@ -59,7 +59,7 @@ export default ({
}
};
const listItemMiddleware = async function (req: Request, res: Response) {
const listItemMiddleware = async function(req: Request, res: Response) {
try {
let query = req.data.query;
let skip = req.data.skip;
@@ -138,7 +138,7 @@ export default ({
}
};
const createItemMiddleware = async function (req: Request, res: Response) {
const createItemMiddleware = async function(req: Request, res: Response) {
try {
const data = req.body;
@@ -154,7 +154,7 @@ export default ({
}
};
const deleteItemMiddleware = async function (req: Request, res: Response) {
const deleteItemMiddleware = async function(req: Request, res: Response) {
try {
if (!req.apiProps.authorizedByRole.includes(req.role)) {
return sendErrorResponse(req, res, {
@@ -180,7 +180,7 @@ export default ({
}
};
const updateItemMiddleware = async function (
const updateItemMiddleware = async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import CallLogsService from '../services/callLogsService';
@@ -11,7 +15,7 @@ import { sendListResponse } from 'common-server/utils/response';
import { sendItemResponse } from 'common-server/utils/response';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -87,7 +91,7 @@ router.post(
}
);
router.post('/search', getUser, isUserMasterAdmin, async function (
router.post('/search', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -107,7 +111,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/', getUser, isUserMasterAdmin, async function (
router.delete('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import { fetchPhoneNumbers } from '../services/twilioService';
import CallRoutingService from '../services/callRoutingService';
@@ -175,7 +179,7 @@ router.get(
}
);
router.post('/:projectId/routingNumber', getUser, isUserAdmin, async function (
router.post('/:projectId/routingNumber', getUser, isUserAdmin, async function(
req,
res
) {
@@ -192,7 +196,7 @@ router.post('/:projectId/routingNumber', getUser, isUserAdmin, async function (
}
});
router.put('/:projectId/:callRoutingId', getUser, isUserAdmin, async function (
router.put('/:projectId/:callRoutingId', getUser, isUserAdmin, async function(
req,
res
) {
@@ -211,7 +215,7 @@ router.put(
'/:projectId/:callRoutingId/:audioFieldName',
getUser,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { audioFieldName, callRoutingId } = req.params;
const upload = multer({
@@ -222,7 +226,7 @@ router.put(
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
if (error) {
return sendErrorResponse(req, res, error);
}
@@ -255,7 +259,7 @@ router.delete(
'/:projectId/:callRoutingId',
getUser,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, callRoutingId } = req.params;
@@ -284,7 +288,7 @@ router.delete(
'/:projectId/:callRoutingId/removeAudio',
getUser,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { callRoutingId, backup } = req.body;
if (!callRoutingId) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import UserService from '../services/userService';
import ComponentService from '../services/componentService';
import NotificationService from '../services/notificationService';
@@ -35,7 +39,7 @@ import moment from 'moment';
// Params:
// Param 1: req.params-> {projectId}; req.body -> {[_id], name, type, data, visibleOnStatusPage} <- Check ComponentMoal for description.
// Returns: response status, error message
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -102,7 +106,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const { componentId } = req.params;
@@ -131,7 +135,7 @@ router.put(
// Route
// Description: Get all Components by projectId.
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
req,
res
) {
@@ -152,7 +156,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function
// Route
// Description: Get all Components by pagination.
router.get('/:projectId/paginated', getUser, isAuthorized, async function (
router.get('/:projectId/paginated', getUser, isAuthorized, async function(
req,
res
) {
@@ -172,7 +176,7 @@ router.get('/:projectId/paginated', getUser, isAuthorized, async function (
}
});
router.get('/:projectId/slug/:slug', getUser, isAuthorized, async function (
router.get('/:projectId/slug/:slug', getUser, isAuthorized, async function(
req,
res
) {
@@ -202,7 +206,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const type = req.query.type;
@@ -245,7 +249,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const componentId = req.params.componentId;
const type = req.query.type;
@@ -282,7 +286,7 @@ router.post(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { startDate, endDate } = req.body;
const componentId = req.params.componentId;
@@ -382,7 +386,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const componentId = req.params.componentId;
const type = req.query.type;
@@ -489,14 +493,15 @@ router.get(
const newElement = {
_id: elem._id,
name: elem.name,
type: `${elem.type === 'server-monitor'
? 'server monitor'
: elem.type === 'url'
type: `${
elem.type === 'server-monitor'
? 'server monitor'
: elem.type === 'url'
? 'website monitor'
: elem.type === 'ip'
? 'IP monitor'
: elem.type + ` monitor`
}`,
? 'IP monitor'
: elem.type + ` monitor`
}`,
createdAt: elem.createdAt,
icon: 'monitor',
slug: elem.slug,
@@ -695,7 +700,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -759,7 +764,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { componentId, projectId } = req.params;
try {
await ComponentService.deleteBy(

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import ContainerSecurityService from '../services/containerSecurityService';
import ContainerSecurityLogService from '../services//containerSecurityLogService';
@@ -15,7 +19,7 @@ import UserService from '../services/userService';
import ProjectService from '../services/projectService';
import ErrorService from 'common-server/utils/error';
router.get('/containerSecurities', isAuthorizedContainerScanner, async function (
router.get('/containerSecurities', isAuthorizedContainerScanner, async function(
req,
res
) {
@@ -26,7 +30,7 @@ router.get('/containerSecurities', isAuthorizedContainerScanner, async function
return sendErrorResponse(req, res, error);
}
});
router.post('/scanning', isAuthorizedContainerScanner, async function (
router.post('/scanning', isAuthorizedContainerScanner, async function(
req,
res
) {
@@ -50,7 +54,7 @@ router.post('/scanning', isAuthorizedContainerScanner, async function (
}
});
router.post('/failed', isAuthorizedContainerScanner, async function (
router.post('/failed', isAuthorizedContainerScanner, async function(
req: Request,
res: Response
) {
@@ -67,7 +71,7 @@ router.post('/failed', isAuthorizedContainerScanner, async function (
return sendErrorResponse(req, res, error);
}
});
router.post('/log', isAuthorizedContainerScanner, async function (
router.post('/log', isAuthorizedContainerScanner, async function(
req: Request,
res: Response
) {
@@ -157,7 +161,7 @@ router.post('/log', isAuthorizedContainerScanner, async function (
}
});
router.post('/time', isAuthorizedContainerScanner, async function (
router.post('/time', isAuthorizedContainerScanner, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import { isAuthorized } from '../middlewares/authorization';
@@ -13,7 +17,7 @@ import CustomFieldService from '../services/customFieldService';
const router = express.getRouter();
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -63,7 +67,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -93,7 +97,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:customFieldId', getUser, isAuthorized, async function (
router.put('/:projectId/:customFieldId', getUser, isAuthorized, async function(
req,
res
) {
@@ -149,7 +153,7 @@ router.delete(
'/:projectId/:customFieldId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, customFieldId } = req.params;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import psl from 'psl';
@@ -46,8 +50,9 @@ router.put(
? txtRecords.join(', ')
: txtRecords[0];
return sendErrorResponse(req, res, {
message: `Please specify ${verificationToken} in your DNS. Looks like your current ${txtRecords.length > 1 ? 'records are' : 'record is'
} ${records}`,
message: `Please specify ${verificationToken} in your DNS. Looks like your current ${
txtRecords.length > 1 ? 'records are' : 'record is'
} ${records}`,
code: 400,
});
}

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import EmailLogsService from '../services/emailStatusService';
@@ -11,7 +15,7 @@ import { sendListResponse } from 'common-server/utils/response';
import { sendItemResponse } from 'common-server/utils/response';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -102,7 +106,7 @@ router.post(
}
);
router.put('/:emailLogsId', getUser, isUserMasterAdmin, async function (
router.put('/:emailLogsId', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -169,7 +173,7 @@ router.put('/:emailLogsId', getUser, isUserMasterAdmin, async function (
}
});
router.post('/search', getUser, isUserMasterAdmin, async function (
router.post('/search', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -189,7 +193,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/', getUser, isUserMasterAdmin, async function (
router.delete('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import EmailSmtpService from '../services/emailSmtpService';
import MailService from '../services/mailService';
const router = express.getRouter();
@@ -14,7 +18,7 @@ import {
import UserService from '../services/userService';
router.post('/test', getUser, isUserMasterAdmin, async function (
router.post('/test', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -86,7 +90,7 @@ router.post('/test', getUser, isUserMasterAdmin, async function (
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -151,7 +155,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -170,7 +174,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:emailSmtpId', getUser, isAuthorized, async function (
router.put('/:projectId/:emailSmtpId', getUser, isAuthorized, async function(
req,
res
) {
@@ -239,7 +243,7 @@ router.put('/:projectId/:emailSmtpId', getUser, isAuthorized, async function (
}
});
router.delete('/:projectId/:emailSmtpId', getUser, isUserOwner, async function (
router.delete('/:projectId/:emailSmtpId', getUser, isUserOwner, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import EmailTemplateService from '../services/emailTemplateService';
const router = express.getRouter();
@@ -17,7 +21,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -58,7 +62,7 @@ router.get(
'/:projectId/:templateId/reset',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const templateId = req.params.templateId;
@@ -73,7 +77,7 @@ router.get(
}
);
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -90,7 +94,7 @@ router.get(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const emailTemplateId = req.params.emailTemplateId;
const select = 'projectId subject body emailType allowedVariables';
@@ -110,7 +114,7 @@ router.put(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const Id = req.params.emailTemplateId;
@@ -126,7 +130,7 @@ router.put(
}
);
router.put('/:projectId', getUser, isAuthorized, async function (
router.put('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -191,7 +195,7 @@ router.delete(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const emailTemplateId = req.params.emailTemplateId;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
@@ -38,7 +42,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const componentId = req.params.componentId;
@@ -107,7 +111,7 @@ router.post(
);
// Description: Get all Error Trackers by componentId.
router.get('/:projectId/:componentId', getUser, isAuthorized, async function (
router.get('/:projectId/:componentId', getUser, isAuthorized, async function(
req,
res
) {
@@ -138,7 +142,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { errorTrackerId, componentId } = req.params;
try {
const errorTracker = await ErrorTrackerService.deleteBy(
@@ -169,7 +173,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const errorTrackerId = req.params.errorTrackerId;
const select =
'componentId name slug key showQuickStart resourceCategory createdById createdAt';
@@ -213,7 +217,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { errorTrackerId, componentId } = req.params;
const data = req.body;
@@ -322,7 +326,7 @@ router.put(
);
// Description: send an error event to the server.
router.post('/:errorTrackerId/track', isErrorTrackerValid, async function (
router.post('/:errorTrackerId/track', isErrorTrackerValid, async function(
req,
res
) {
@@ -388,7 +392,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { skip, limit, startDate, endDate, filters } = req.body;
const errorTrackerId = req.params.errorTrackerId;
@@ -444,7 +448,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/error-events/:errorEventId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const errorEventId = req.params.errorEventId;
if (!errorEventId) {
@@ -495,7 +499,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues/:issueId/details',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const issueId = req.params.issueId;
if (!issueId) {
@@ -538,7 +542,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues/action',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { issueId, action } = req.body;
if (!issueId) {
@@ -724,7 +728,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/error-events',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const {
skip,
@@ -787,7 +791,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/members/:issueId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const componentId = req.params.componentId;
if (!componentId) {
@@ -865,7 +869,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/assign/:issueId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { teamMemberId } = req.body;
if (!teamMemberId) {
@@ -1013,7 +1017,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/unassign/:issueId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { teamMemberId } = req.body;
if (!teamMemberId) {
@@ -1146,7 +1150,7 @@ router.delete(
'/:projectId/:componentId/:errorTrackerId/issue/:issueId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const componentId = req.params.componentId;
if (!componentId) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import FeedbackService from '../services/feedbackService';
@@ -11,7 +15,7 @@ const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import FileService from '../services/fileService';
@@ -11,7 +15,7 @@ import { sendFileResponse } from 'common-server/utils/response';
// Param1: req.params-> {filename};
// Returns: response uploaded files, error message
router.get('/:filename', async function (req: Request, res: Response) {
router.get('/:filename', async function(req: Request, res: Response) {
try {
const file = await FileService.findOneBy({
filename: req.params.filename,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import GlobalConfigService from '../services/globalConfigService';
@@ -15,7 +19,7 @@ import twilioService from '../services/twilioService';
// Body: [{name, value}] | {name, value}
// Return: [{name, value, createdAt}] | {name, value, createdAt}
router.post('/', getUser, isUserMasterAdmin, async function (
router.post('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -105,7 +109,7 @@ router.post('/', getUser, isUserMasterAdmin, async function (
// Params: [name];
// Return: [{name, value, createdAt}]
router.post('/configs', getUser, isUserMasterAdmin, async function (
router.post('/configs', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -135,7 +139,7 @@ router.post('/configs', getUser, isUserMasterAdmin, async function (
// Params: {name};
// Return: {name, value, createdAt}
router.get('/:name', getUser, isUserMasterAdmin, async function (
router.get('/:name', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
@@ -53,8 +57,8 @@ router.get(
async (req: Request, res: Response) => {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => {
return { id: project._id, name: project.name };
})
return { id: project._id, name: project.name };
})
: null;
try {
const groups = await Promise.all(

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import moment from 'moment';
import Handlebars from 'handlebars';
import IncidentService from '../services/incidentService';
@@ -37,7 +41,7 @@ import ErrorService from 'common-server/utils/error';
router.post(
'/data-ingestor/create-incident',
isAuthorizedService,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
@@ -55,7 +59,7 @@ router.post(
router.post(
'/data-ingestor/acknowledge-incident',
isAuthorizedService,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { incidentId, name, probeId } = req.body;
@@ -77,7 +81,7 @@ router.post(
router.post(
'/data-ingestor/resolve-incident',
isAuthorizedService,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { incidentId, name, probeId } = req.body;
@@ -99,7 +103,7 @@ router.post(
router.post(
'/data-ingestor/update-incident',
isAuthorizedService,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { data, query } = req.body;
const incident = await IncidentService.updateOneBy(query, data);
@@ -121,7 +125,7 @@ router.post(
'/:projectId/create-incident',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const incidentType = req.body.incidentType;
@@ -241,7 +245,7 @@ router.post(
'/:projectId/monitor/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { monitorId } = req.params;
// include date range
try {
@@ -303,7 +307,7 @@ router.post(
);
// Fetch incidents by projectId
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
req,
res
) {
@@ -327,7 +331,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { componentId, projectId } = req.params;
const incidents = await IncidentService.getComponentIncidents(
@@ -350,7 +354,7 @@ router.get(
'/:projectId/incidents/:componentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, componentId } = req.params;
@@ -367,7 +371,7 @@ router.get(
}
);
router.get('/:projectId/incident', getUser, isAuthorized, async function (
router.get('/:projectId/incident', getUser, isAuthorized, async function(
req,
res
) {
@@ -433,7 +437,7 @@ router.get(
'/:projectId/incident/:incidentSlug',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
// Call the IncidentService.
try {
@@ -479,7 +483,7 @@ router.get(
'/:projectId/timeline/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { incidentId } = req.params;
@@ -514,7 +518,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -540,7 +544,7 @@ router.post(
'/:projectId/acknowledge/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user
? req.user.id === 'API'
@@ -707,7 +711,7 @@ router.post(
'/:projectId/resolve/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user
? req.user.id === 'API'
@@ -870,7 +874,7 @@ router.post(
'/:projectId/close/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
const { incidentId } = req.params;
@@ -889,7 +893,7 @@ router.put(
'/:projectId/incident/:incidentId/details',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const projectId = req.params.projectId;
const incidentId = req.params.incidentId;
const { title, description, incidentPriority } = req.body;
@@ -924,7 +928,7 @@ router.post(
'/:projectId/incident/:incidentId/message',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const incidentId = req.params.incidentId;
@@ -1133,8 +1137,9 @@ router.post(
error
);
});
const status = `${incidentMessage.type} notes ${data.id ? 'updated' : 'added'
}`;
const status = `${incidentMessage.type} notes ${
data.id ? 'updated' : 'added'
}`;
const user = await UserService.findOneBy({
query: { _id: userId },
@@ -1304,7 +1309,7 @@ router.get(
'/:projectId/:incidentSlug/statuspages',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { incidentSlug } = req.params;
@@ -1337,7 +1342,7 @@ router.delete(
'/:projectId/incident/:incidentId/message/:incidentMessageId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { incidentId, incidentMessageId, projectId } = req.params;
const populateIncidentMessage = [
@@ -1527,7 +1532,7 @@ router.get(
'/:projectId/incident/:incidentSlug/message',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
let type = 'investigation';
if (req.query.type && req.query.type === 'internal') {
type = 'internal';
@@ -1695,7 +1700,7 @@ router.get(
}
);
router.delete('/:projectId/:incidentId', getUser, isUserAdmin, async function (
router.delete('/:projectId/:incidentId', getUser, isUserAdmin, async function(
req,
res
) {
@@ -1724,7 +1729,7 @@ router.delete('/:projectId/:incidentId', getUser, isUserAdmin, async function (
}
});
router.put('/:projectId/:incidentId', getUser, async function (
router.put('/:projectId/:incidentId', getUser, async function(
req: Request,
res: Response
) {
@@ -1757,7 +1762,7 @@ router.get(
'/:projectId/resolve/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
@@ -1802,7 +1807,7 @@ router.get(
'/:projectId/acknowledge/:incidentId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
@@ -12,7 +16,7 @@ import IncidentCommunicationSlaService from '../services/incidentCommunicationSl
const router = express.getRouter();
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -47,7 +51,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -101,7 +105,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:incidentSlaId', getUser, isAuthorized, async function (
router.put('/:projectId/:incidentSlaId', getUser, isAuthorized, async function(
req,
res
) {
@@ -161,7 +165,7 @@ router.delete(
'/:projectId/:incidentSlaId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, incidentSlaId } = req.params;
@@ -182,7 +186,7 @@ router.get(
'/:projectId/defaultCommunicationSla',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
@@ -11,7 +15,7 @@ import {
import { sendListResponse } from 'common-server/utils/response';
import IncidentNoteTemplateService from '../services/incidentNoteTemplateService';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -60,7 +64,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -91,7 +95,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:templateId', getUser, isAuthorized, async function (
router.put('/:projectId/:templateId', getUser, isAuthorized, async function(
req,
res
) {
@@ -144,7 +148,7 @@ router.put('/:projectId/:templateId', getUser, isAuthorized, async function (
}
});
router.delete('/:projectId/:templateId', getUser, isAuthorized, async function (
router.delete('/:projectId/:templateId', getUser, isAuthorized, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
@@ -10,7 +14,7 @@ import {
} from 'common-server/utils/response';
import IncidentPrioritiesService from '../services/incidentPrioritiesService';
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -40,7 +44,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -77,7 +81,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId', getUser, isAuthorized, async function (
router.put('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -123,7 +127,7 @@ router.put('/:projectId', getUser, isAuthorized, async function (
}
});
router.delete('/:projectId', getUser, isAuthorized, async function (
router.delete('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
@@ -14,7 +18,7 @@ import IncidentPrioritiesService from '../services/incidentPrioritiesService';
import { variables } from '../config/incidentDefaultSettings';
router.get('/variables', async function (req: Request, res: Response) {
router.get('/variables', async function(req: Request, res: Response) {
try {
return sendItemResponse(req, res, variables);
} catch (error) {
@@ -23,7 +27,7 @@ router.get('/variables', async function (req: Request, res: Response) {
});
// fetch default incident template in a project
router.get('/:projectId/default', getUser, isAuthorized, async function (
router.get('/:projectId/default', getUser, isAuthorized, async function(
req,
res
) {
@@ -51,7 +55,7 @@ router.get('/:projectId/default', getUser, isAuthorized, async function (
});
// fetch all incident template in a project
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -91,7 +95,7 @@ router.put(
'/:projectId/:templateId/setDefault',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { projectId, templateId } = req.params;
if (!projectId)
return sendErrorResponse(req, res, {
@@ -116,7 +120,7 @@ router.put(
}
);
router.put('/:projectId/:templateId', getUser, isAuthorized, async function (
router.put('/:projectId/:templateId', getUser, isAuthorized, async function(
req,
res
) {
@@ -184,7 +188,7 @@ router.put('/:projectId/:templateId', getUser, isAuthorized, async function (
}
});
router.delete('/:projectId/:templateId', getUser, isAuthorized, async function (
router.delete('/:projectId/:templateId', getUser, isAuthorized, async function(
req,
res
) {
@@ -214,7 +218,7 @@ router.delete('/:projectId/:templateId', getUser, isAuthorized, async function (
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import ProbeService from '../services/probeService';
import {
@@ -8,7 +12,7 @@ import {
import { isValidMonitor } from '../middlewares/api';
const incomingHttpRequest = async function (req: Request, res: Response) {
const incomingHttpRequest = async function(req: Request, res: Response) {
try {
const monitor = req.monitor;
const body = req.body;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
@@ -16,7 +20,7 @@ router.get(
'/:projectId/all-incoming-request',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -57,7 +61,7 @@ router.post(
'/:projectId/create-request-url',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -114,7 +118,7 @@ router.put(
'/:projectId/update/:requestId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, requestId } = req.params;
const data = req.body;
@@ -171,7 +175,7 @@ router.delete(
'/:projectId/remove/:requestId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, requestId } = req.params;
@@ -187,7 +191,7 @@ router.delete(
);
// process incoming http request from post request
router.post('/:projectId/request/:requestId', async function (
router.post('/:projectId/request/:requestId', async function(
req: Request,
res: Response
) {
@@ -212,7 +216,7 @@ router.post('/:projectId/request/:requestId', async function (
});
// process incoming http request from get request
router.get('/:projectId/request/:requestId', async function (
router.get('/:projectId/request/:requestId', async function(
req: Request,
res: Response
) {
@@ -240,7 +244,7 @@ router.post(
'/:projectId/toggle/:requestId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, requestId } = req.params;
const data = req.body;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import InvoiceService from '../services/invoiceService';
import { sendErrorResponse } from 'common-server/utils/response';
@@ -9,7 +13,7 @@ import { sendListResponse } from 'common-server/utils/response';
// Params:
// Param 1: req.headers-> {token}; req.params-> {userId}
// Returns: 200: "Invoice received"; 400: "Error"
router.post('/:userId', async function (req: Request, res: Response) {
router.post('/:userId', async function(req: Request, res: Response) {
try {
const userId = req.params.userId;
let startingAfter = req.query.startingAfter;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import LeadService from '../services/leadService';
import {
@@ -7,7 +11,7 @@ import {
} from 'common-server/utils/response';
//Public API to capture leads. Type is Demo or Whitepaper.
router.post('/', async function (req: Request, res: Response) {
router.post('/', async function(req: Request, res: Response) {
try {
const body = req.body;
const data = {};

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ProbeService from '../services/probeService';
import MonitorService from '../services/monitorService';
import LighthouseLogService from '../services/lighthouseLogService';
@@ -23,7 +27,7 @@ import ErrorService from 'common-server/utils/error';
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.get('/monitors', isAuthorizedLighthouse, async function (
router.get('/monitors', isAuthorizedLighthouse, async function(
req: Request,
res: Response
) {
@@ -41,7 +45,7 @@ router.get('/monitors', isAuthorizedLighthouse, async function (
}
});
router.post('/ping/:monitorId', isAuthorizedLighthouse, async function (
router.post('/ping/:monitorId', isAuthorizedLighthouse, async function(
req,
response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import loginHistoryService from '../services/loginHistoryService';
const router = express.getRouter();
@@ -10,7 +14,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.get('/:userId', getUser, isAuthorized, async function (
router.get('/:userId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import axios from 'axios';
import UserService from '../services/userService';
import MonitorService from '../services/monitorService';
@@ -36,7 +40,7 @@ const httpsAgent = new https.Agent({
// Params:
// Param 1: req.params-> {projectId}; req.body -> {[_id], name, type, data, visibleOnStatusPage} <- Check MonitorMoal for description.
// Returns: response status, error message
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -274,7 +278,7 @@ router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
}
});
router.post('/:projectId/identityFile', async function (
router.post('/:projectId/identityFile', async function(
req: Request,
res: Response
) {
@@ -287,7 +291,7 @@ router.post('/:projectId/identityFile', async function (
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
let identityFile;
if (error) {
return sendErrorResponse(req, res, error);
@@ -306,7 +310,7 @@ router.post('/:projectId/identityFile', async function (
}
});
router.post('/:projectId/configurationFile', async function (
router.post('/:projectId/configurationFile', async function(
req: Request,
res: Response
) {
@@ -319,7 +323,7 @@ router.post('/:projectId/configurationFile', async function (
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
let configurationFile;
if (error) {
return sendErrorResponse(req, res, error);
@@ -343,7 +347,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const { monitorId } = req.params;
@@ -434,7 +438,7 @@ router.put(
// Route
// Description: Get all Monitors by projectId.
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
req,
res
) {
@@ -456,7 +460,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function
}
});
router.get('/:projectId/paginated', getUser, isAuthorized, async function (
router.get('/:projectId/paginated', getUser, isAuthorized, async function(
req,
res
) {
@@ -504,7 +508,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const type = req.query.type;
@@ -549,7 +553,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const monitorId = req.params.monitorId;
const type = req.query.type;
@@ -589,7 +593,7 @@ router.post(
'/:projectId/monitorLogs/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const {
skip,
@@ -645,7 +649,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { monitorId, projectId } = req.params;
try {
const monitor = await MonitorService.deleteBy(
@@ -676,7 +680,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const monitorId = req.params.monitorId || req.body._id;
const data = req.body;
@@ -695,10 +699,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
data
)
monitor.type,
monitor.criteria.up,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
const {
stat: validDegraded,
@@ -707,10 +711,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
data
)
monitor.type,
monitor.criteria.degraded,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
const {
stat: validDown,
@@ -719,10 +723,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
monitor.criteria.down,
data
)
monitor.type,
monitor.criteria.down,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
if (validUp) {
@@ -771,7 +775,7 @@ router.post(
'/:projectId/monitorLog/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -793,7 +797,7 @@ router.post(
'/:projectId/monitorStatuses/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -815,7 +819,7 @@ router.get(
'/:projectId/lighthouseLog/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { skip, limit, url } = req.query;
const monitorId = req.params.monitorId;
@@ -841,7 +845,7 @@ router.get(
'/:projectId/lighthouseIssue/:issueId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const selectLighthouseLogs =
'monitorId probeId data url performance accessibility bestPractices seo pwa createdAt scanning';
@@ -870,7 +874,7 @@ router.post(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
return await _updateDeviceMonitorPingTime(req, res);
}
);
@@ -879,12 +883,12 @@ router.get(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
return await _updateDeviceMonitorPingTime(req, res);
}
);
const _updateDeviceMonitorPingTime = async function (
const _updateDeviceMonitorPingTime = async function(
req: Request,
res: Response
) {
@@ -924,7 +928,7 @@ const _updateDeviceMonitorPingTime = async function (
}
};
router.post('/:projectId/addseat', getUser, isAuthorized, async function (
router.post('/:projectId/addseat', getUser, isAuthorized, async function(
req,
res
) {
@@ -942,7 +946,7 @@ router.post(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.addSiteUrl(
@@ -962,7 +966,7 @@ router.delete(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.removeSiteUrl(
@@ -982,7 +986,7 @@ router.get(
'/:projectId/monitorSlaBreaches',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const select =
@@ -1002,7 +1006,7 @@ router.post(
'/:projectId/closeSla/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, monitorId } = req.params;
@@ -1024,7 +1028,7 @@ router.post(
'/:projectId/disableMonitor/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { monitorId } = req.params;
const select = 'disabled';
@@ -1059,7 +1063,7 @@ router.post(
'/:projectId/changeComponent/:monitorId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, monitorId } = req.params;
const { newComponentId } = req.body;
@@ -1076,7 +1080,7 @@ router.post(
);
// api to calculate time for monitorInfo (status page)
router.post('/:monitorId/calculate-time', async function (
router.post('/:monitorId/calculate-time', async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
@@ -10,7 +14,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.get('/', getUser, function (req: Request, res: Response) {
router.get('/', getUser, function(req: Request, res: Response) {
try {
const criteria = MonitorCriteriaService.getCriteria();
return sendItemResponse(req, res, criteria);

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import { isAuthorized } from '../middlewares/authorization';
@@ -13,7 +17,7 @@ import MonitorCustomFieldService from '../services/monitorCustomField';
const router = express.getRouter();
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -65,7 +69,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -97,7 +101,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:customFieldId', getUser, isAuthorized, async function (
router.put('/:projectId/:customFieldId', getUser, isAuthorized, async function(
req,
res
) {
@@ -150,7 +154,7 @@ router.delete(
'/:projectId/:customFieldId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, customFieldId } = req.params;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
@@ -12,7 +16,7 @@ import MonitorSlaService from '../services/monitorSlaService';
const router = express.getRouter();
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -45,7 +49,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -117,7 +121,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:monitorSlaId', getUser, isAuthorized, async function (
router.put('/:projectId/:monitorSlaId', getUser, isAuthorized, async function(
req,
res
) {
@@ -195,7 +199,7 @@ router.delete(
'/:projectId/:monitorSlaId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, monitorSlaId } = req.params;
@@ -214,7 +218,7 @@ router.get(
'/:projectId/defaultMonitorSla',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const selectMonSla =

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import NotificationService from '../services/notificationService';
@@ -12,7 +16,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
req,
res
) {
@@ -56,7 +60,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function
}
});
router.put('/:projectId/read', getUser, isAuthorized, async function (
router.put('/:projectId/read', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -87,7 +91,7 @@ router.put(
'/:projectId/:notificationId/closed',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const notificationId = req.params.notificationId;
@@ -115,7 +119,7 @@ router.put(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -144,7 +148,7 @@ router.put(
}
);
router.put('/:projectId/:notificationId', getUser, isAuthorized, async function (
router.put('/:projectId/:notificationId', getUser, isAuthorized, async function(
req,
res
) {
@@ -168,7 +172,7 @@ router.put('/:projectId/:notificationId', getUser, isAuthorized, async function
}
});
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import NotificationService from '../services/notificationService';
import ErrorService from 'common-server/utils/error';
@@ -27,7 +31,7 @@ router.post(
'/:projectId/:componentId/create',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const { componentId } = req.params;
@@ -75,7 +79,7 @@ router.post(
);
// Description: Get all Performance tracker by componentId.
router.get('/:projectId/:componentId', getUser, isAuthorized, async function (
router.get('/:projectId/:componentId', getUser, isAuthorized, async function(
req,
res
) {
@@ -107,7 +111,7 @@ router.get(
'/:projectId/tracker/:performanceTrackerId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { performanceTrackerId } = req.params;
const { slug } = req.query;
try {
@@ -155,7 +159,7 @@ router.delete(
'/:projectId/tracker/:performanceTrackerId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { performanceTrackerId } = req.params;
try {
const performanceTracker = await PerformanceTrackerService.deleteBy(
@@ -185,7 +189,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { performanceTrackerId } = req.params;
const select = 'componentId name slug key showQuickStart createdById';
@@ -232,7 +236,7 @@ router.put(
'/:projectId/remove-quickstart/:performanceTrackerId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { performanceTrackerId } = req.params;
const currentPerformanceTracker = await PerformanceTrackerService.findOneBy(
@@ -270,7 +274,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { performanceTrackerId, componentId } = req.params;
const data = req.body;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import PerformanceTrackerMetricService from '../services/performanceTrackerMetricService';
import moment from 'moment';
@@ -14,7 +18,7 @@ import { isValidAPIKey } from '../middlewares/performanceTracker';
// Route
// Description: Receiving Performance metric data from sdk.
// Returns: response status, error message
router.post('/:appId/key/:key', isValidAPIKey, async function (
router.post('/:appId/key/:key', isValidAPIKey, async function(
req: Request,
res: Response
) {
@@ -44,7 +48,7 @@ router.post('/:appId/key/:key', isValidAPIKey, async function (
});
// fetch transaction time for performance metrics
router.get('/:appId/key/:key/time', isValidAPIKey, async function (
router.get('/:appId/key/:key/time', isValidAPIKey, async function(
req: Request,
res: Response
) {
@@ -110,7 +114,7 @@ router.get('/:appId/key/:key/time', isValidAPIKey, async function (
});
// fetch throughput for performance metrics
router.get('/:appId/key/:key/throughput', isValidAPIKey, async function (
router.get('/:appId/key/:key/throughput', isValidAPIKey, async function(
req,
res
) {
@@ -175,7 +179,7 @@ router.get('/:appId/key/:key/throughput', isValidAPIKey, async function (
}
});
router.get('/:appId/key/:key/error', isValidAPIKey, async function (
router.get('/:appId/key/:key/error', isValidAPIKey, async function(
req: Request,
res: Response
) {
@@ -242,7 +246,7 @@ router.get('/:appId/key/:key/error', isValidAPIKey, async function (
// Route
// Description: Fetch all the Performance metrics for a particular identifier
router.get('/:appId/key/:key', isValidAPIKey, async function (
router.get('/:appId/key/:key', isValidAPIKey, async function(
req: Request,
res: Response
) {
@@ -336,7 +340,7 @@ router.get('/:appId/key/:key', isValidAPIKey, async function (
});
// Delete a performance metric
router.delete('/:appId/key/:key/:metricId', isValidAPIKey, async function (
router.delete('/:appId/key/:key/:metricId', isValidAPIKey, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ProbeService from '../services/probeService';
import MonitorService from '../services/monitorService';
import LighthouseLogService from '../services/lighthouseLogService';
@@ -18,7 +22,7 @@ import { isAuthorized } from '../middlewares/authorization';
import multer from 'multer';
import storage from '../middlewares/upload';
router.post('/', getUser, isAuthorizedAdmin, async function (
router.post('/', getUser, isAuthorizedAdmin, async function(
req: Request,
res: Response
) {
@@ -31,7 +35,7 @@ router.post('/', getUser, isAuthorizedAdmin, async function (
}
});
router.get('/', getUser, isAuthorizedAdmin, async function (
router.get('/', getUser, isAuthorizedAdmin, async function(
req: Request,
res: Response
) {
@@ -55,7 +59,7 @@ router.get('/', getUser, isAuthorizedAdmin, async function (
}
});
router.put('/:id', getUser, isAuthorizedAdmin, async function (
router.put('/:id', getUser, isAuthorizedAdmin, async function(
req: Request,
res: Response
) {
@@ -71,7 +75,7 @@ router.put('/:id', getUser, isAuthorizedAdmin, async function (
}
});
router.delete('/:id', getUser, isAuthorizedAdmin, async function (
router.delete('/:id', getUser, isAuthorizedAdmin, async function(
req: Request,
res: Response
) {
@@ -89,7 +93,7 @@ router.delete('/:id', getUser, isAuthorizedAdmin, async function (
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/update/image', getUser, async function (
router.put('/update/image', getUser, async function(
req: Request,
res: Response
) {
@@ -102,7 +106,7 @@ router.put('/update/image', getUser, async function (
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
const probeId = req.body.id;
const data = req.body;
@@ -126,7 +130,7 @@ router.put('/update/image', getUser, async function (
}
});
router.get('/monitors', isAuthorizedProbe, async function (
router.get('/monitors', isAuthorizedProbe, async function(
req: Request,
res: Response
) {
@@ -147,7 +151,7 @@ router.get('/monitors', isAuthorizedProbe, async function (
}
});
router.post('/ping/:monitorId', isAuthorizedProbe, async function (
router.post('/ping/:monitorId', isAuthorizedProbe, async function(
req,
response
) {
@@ -188,17 +192,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
successReasons: degradedSuccessReasons,
@@ -207,17 +211,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.degraded,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -226,22 +230,22 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
status = 'online';
@@ -286,17 +290,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -305,22 +309,22 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
status = 'online';
reason = upSuccessReasons;
@@ -352,14 +356,14 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.scriptConditions(
resp,
monitor.criteria.up
)
resp,
monitor.criteria.up
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
@@ -369,16 +373,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.scriptConditions(resp, [
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
])
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
])
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
@@ -388,14 +392,14 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.scriptConditions(
resp,
monitor.criteria.degraded
)
resp,
monitor.criteria.degraded
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
status = 'online';
@@ -441,15 +445,15 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
data
)
monitor.type,
monitor.criteria.up,
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
successReasons: degradedSuccessReasons,
@@ -458,15 +462,15 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
data
)
monitor.type,
monitor.criteria.degraded,
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -475,20 +479,20 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
data.status = 'online';
@@ -576,16 +580,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
monitor.type,
monitor.criteria.up,
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
@@ -595,16 +599,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
monitor.type,
monitor.criteria.degraded,
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
@@ -614,21 +618,21 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
data.status = 'online';
@@ -689,9 +693,9 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
data.reason =
data && data.reason && data.reason.length
? data.reason.filter(
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
: data.reason;
const index =
data.reason && data.reason.indexOf('Request Timed out');
@@ -699,9 +703,9 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
data.reason =
data && data.reason && data.reason.length
? data.reason.filter(
(item: $TSFixMe) =>
!item.includes('Response Time is')
)
(item: $TSFixMe) =>
!item.includes('Response Time is')
)
: data.reason;
}
@@ -763,7 +767,7 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function (
}
});
router.post('/setTime/:monitorId', isAuthorizedProbe, async function (
router.post('/setTime/:monitorId', isAuthorizedProbe, async function(
req: Request,
res: Response
) {
@@ -779,7 +783,7 @@ router.post('/setTime/:monitorId', isAuthorizedProbe, async function (
}
});
router.post('/getTime/:monitorId', isAuthorizedProbe, async function (
router.post('/getTime/:monitorId', isAuthorizedProbe, async function(
req: Request,
res: Response
) {
@@ -795,7 +799,7 @@ router.post('/getTime/:monitorId', isAuthorizedProbe, async function (
}
});
router.get('/:projectId/probes', getUser, isAuthorized, async function (
router.get('/:projectId/probes', getUser, isAuthorized, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ProjectService from '../services/projectService';
const router = express.getRouter();
@@ -28,7 +32,7 @@ import ErrorService from 'common-server/utils/error';
// Params:
// Param 1: req.body-> {project_name}; req.headers-> {token}
// Returns: 200: Project Details; 400: Error.
router.post('/create', getUser, async function (req: Request, res: Response) {
router.post('/create', getUser, async function(req: Request, res: Response) {
try {
const data = req.body;
data.name = data.projectName;
@@ -212,7 +216,7 @@ router.post('/create', getUser, async function (req: Request, res: Response) {
// Params:
// Param 1: req.headers-> {token};
// Returns: 200: [{project}]; 400: Error.
router.get('/projects', getUser, async function (req: Request, res: Response) {
router.get('/projects', getUser, async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
// find user subprojects and parent projects
@@ -280,7 +284,7 @@ router.get('/projects', getUser, async function (req: Request, res: Response) {
//Description: Get project balance of a project
// Param 1: req.headers-> {token}; req.params-> {projectId};
//Returns: 200: {projectBalance}; 400: Error.
router.get('/:projectId/balance', getUser, isAuthorized, async function (
router.get('/:projectId/balance', getUser, isAuthorized, async function(
req,
res
) {
@@ -303,7 +307,7 @@ router.get('/:projectId/balance', getUser, isAuthorized, async function (
// Params:
// Param 1: req.headers-> {token}; req.params-> {projectId};
// Returns: 200: {project}; 400: Error.
router.get('/:projectId/resetToken', getUser, isAuthorized, async function (
router.get('/:projectId/resetToken', getUser, isAuthorized, async function(
req,
res
) {
@@ -332,7 +336,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -369,7 +373,7 @@ router.put(
'/:projectId/updateBalance',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
if (!projectId) {
@@ -398,7 +402,7 @@ router.put(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
@@ -494,7 +498,7 @@ router.delete(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
@@ -556,7 +560,7 @@ router.delete(
router.delete(
'/:projectId/initScript/deleteProject',
isAuthorizedService,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
if (!projectId) {
@@ -603,7 +607,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -676,7 +680,7 @@ router.put(
'/:projectId/admin/changePlan',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -770,7 +774,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -831,7 +835,7 @@ router.delete(
'/:projectId/user/:userId/exitProject',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
// Call the ProjectService
try {
const userId = req.user ? req.user.id : null;
@@ -852,7 +856,7 @@ router.delete(
// Params:
// Param 1: req.headers-> {token}; req.params-> {projectId, userId}
// Returns: 200: subproject;
router.post('/:projectId/subProject', getUser, isAuthorized, async function (
router.post('/:projectId/subProject', getUser, isAuthorized, async function(
req,
res
) {
@@ -913,7 +917,7 @@ router.delete(
'/:projectId/:subProjectId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const parentProjectId = req.params.projectId;
const subProjectId = req.params.subProjectId;
@@ -941,7 +945,7 @@ router.delete(
// Params:
// Param 1: req.headers-> {token}; req.params-> {projectId, userId}
// Returns: 200: [...subprojects];
router.get('/:projectId/subProjects', getUser, isAuthorized, async function (
router.get('/:projectId/subProjects', getUser, isAuthorized, async function(
req,
res
) {
@@ -974,7 +978,7 @@ router.get('/:projectId/subProjects', getUser, isAuthorized, async function (
}
});
router.get('/projects/user/:userId', getUser, isUserMasterAdmin, async function (
router.get('/projects/user/:userId', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -993,7 +997,7 @@ router.get('/projects/user/:userId', getUser, isUserMasterAdmin, async function
}
});
router.get('/projects/allProjects', getUser, isUserMasterAdmin, async function (
router.get('/projects/allProjects', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1013,7 +1017,7 @@ router.get('/projects/allProjects', getUser, isUserMasterAdmin, async function (
}
});
router.get('/projects/:slug', getUser, isUserMasterAdmin, async function (
router.get('/projects/:slug', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1034,7 +1038,7 @@ router.get('/projects/:slug', getUser, isUserMasterAdmin, async function (
}
});
router.get('/project-slug/:slug', getUser, async function (
router.get('/project-slug/:slug', getUser, async function(
req: Request,
res: Response
) {
@@ -1059,7 +1063,7 @@ router.put(
'/:projectId/blockProject',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.updateOneBy(
@@ -1077,7 +1081,7 @@ router.put(
'/:projectId/renewAlertLimit',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
let limit = req.body.alertLimit;
@@ -1111,7 +1115,7 @@ router.put(
'/:projectId/unblockProject',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.updateOneBy(
@@ -1129,7 +1133,7 @@ router.put(
'/:projectId/restoreProject',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.restoreBy({
@@ -1144,7 +1148,7 @@ router.put(
);
// Description: Rename subproject.
router.put('/:projectId/:subProjectId', getUser, isAuthorized, async function (
router.put('/:projectId/:subProjectId', getUser, isAuthorized, async function(
req,
res
) {
@@ -1189,7 +1193,7 @@ router.put('/:projectId/:subProjectId', getUser, isAuthorized, async function (
}
});
router.post('/:projectId/addNote', getUser, isUserMasterAdmin, async function (
router.post('/:projectId/addNote', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1235,7 +1239,7 @@ router.post('/:projectId/addNote', getUser, isUserMasterAdmin, async function (
}
});
router.post('/projects/search', getUser, isUserMasterAdmin, async function (
router.post('/projects/search', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1270,7 +1274,7 @@ router.put(
'/:projectId/advancedOptions/email',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -1327,7 +1331,7 @@ router.put(
'/:projectId/advancedOptions/sms',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -1375,7 +1379,7 @@ router.put(
'/:projectId/advancedOptions/webhook',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;
const data = req.body;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ReportService from '../services/reportService';
import { isAuthorized } from '../middlewares/authorization';

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
@@ -20,7 +24,7 @@ import {
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.body-> {name} req.params -> {projectId}
// Returns: 200: ResourceCategory, 400: Error; 500: Server Error.
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -75,7 +79,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const resourceCategoryId = req.params.resourceCategoryId;
const projectId = req.params.projectId;
@@ -130,7 +134,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const resourceCategoryId = req.params.resourceCategoryId;
const projectId = req.params.projectId;
@@ -176,7 +180,7 @@ router.put(
}
);
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ScheduleService from '../services/scheduleService';
const router = express.getRouter();
const isUserAdmin = require('../middlewares/project').isUserAdmin;
@@ -12,7 +16,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -36,7 +40,7 @@ router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -91,7 +95,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -106,7 +110,7 @@ router.get(
}
);
router.get('/:projectId/schedule', getUser, isAuthorized, async function (
router.get('/:projectId/schedule', getUser, isAuthorized, async function(
req,
res
) {
@@ -153,7 +157,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, scheduleId } = req.params;
const data = req.body;
@@ -173,7 +177,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const scheduleId = req.params.scheduleId;
@@ -261,7 +265,7 @@ router.post(
'Please select how should OneUptime alert your team - SMS, Email, Call OR Push notification ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -273,7 +277,7 @@ router.post(
'Number of Email Reminders is required ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -285,7 +289,7 @@ router.post(
'Number of Call Reminders is required ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -297,7 +301,7 @@ router.post(
'Number of SMS Reminders is required ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -309,7 +313,7 @@ router.post(
'Number of Push notification Reminders is required ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -321,7 +325,7 @@ router.post(
'Please specify Rotation Interval ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -337,7 +341,7 @@ router.post(
'Please specify "First rotation happens on" ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -354,7 +358,7 @@ router.post(
'You must specify timezone for "First rotation happens on" ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -366,7 +370,7 @@ router.post(
'You need more than one team for rotations ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -448,7 +452,7 @@ router.post(
'Team Members are required ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -466,7 +470,7 @@ router.post(
'Please add team members or group to your on-call schedule ' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}
@@ -484,7 +488,7 @@ router.post(
'Please remove duplicate team members from your on-call schedule' +
(req.body.length > 1
? ' in Escalation Policy ' +
escalationPolicyCount
escalationPolicyCount
: ''),
});
}

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import { isAuthorized } from '../middlewares/authorization';
@@ -18,7 +22,7 @@ import moment from 'moment';
import MonitorService from '../services/monitorService';
import ErrorService from 'common-server/utils/error';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -103,7 +107,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:eventId', getUser, isAuthorized, async function (
router.put('/:projectId/:eventId', getUser, isAuthorized, async function(
req,
res
) {
@@ -219,7 +223,7 @@ router.put(
'/:projectId/resolve/:eventId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = {};
@@ -261,7 +265,7 @@ router.put(
}
);
router.delete('/:projectId/:eventId', getUser, isAuthorized, async function (
router.delete('/:projectId/:eventId', getUser, isAuthorized, async function(
req,
res
) {
@@ -281,7 +285,7 @@ router.delete('/:projectId/:eventId', getUser, isAuthorized, async function (
});
// cancel a scheduled event
router.put('/:projectId/:eventId/cancel', getUser, isAuthorized, async function (
router.put('/:projectId/:eventId/cancel', getUser, isAuthorized, async function(
req,
res
) {
@@ -356,7 +360,7 @@ router.put('/:projectId/:eventId/cancel', getUser, isAuthorized, async function
});
// get ongoing scheduled events
router.get('/:projectId/ongoingEvent', getUser, isAuthorized, async function (
router.get('/:projectId/ongoingEvent', getUser, isAuthorized, async function(
req,
res
) {
@@ -417,7 +421,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const currentDate = moment();
// this contains both projectIds and subProjectIds
@@ -442,7 +446,7 @@ router.get(
}
);
router.get('/:projectId/:eventId', getUser, isAuthorized, async function (
router.get('/:projectId/:eventId', getUser, isAuthorized, async function(
req,
res
) {
@@ -504,7 +508,7 @@ router.get('/:projectId/:eventId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -563,7 +567,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
// this contains both projectIds and subProjectIds
@@ -584,7 +588,7 @@ router.get(
router.get(
'/:projectId/:monitorId/statusPage',
checkUserBelongToProject,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const monitorId = req.params.monitorId;
@@ -660,7 +664,7 @@ router.get(
// Scheduled Event Note
// Create a Scheduled Event note of type investigation or internal
router.post('/:projectId/:eventId/notes', getUser, isAuthorized, async function (
router.post('/:projectId/:eventId/notes', getUser, isAuthorized, async function(
req,
res
) {
@@ -756,7 +760,7 @@ router.post('/:projectId/:eventId/notes', getUser, isAuthorized, async function
});
// Get all notes in a Scheduled Event (Used to fetch for investigation and internal types)
router.get('/:projectId/:eventId/notes', getUser, isAuthorized, async function (
router.get('/:projectId/:eventId/notes', getUser, isAuthorized, async function(
req,
res
) {
@@ -803,7 +807,7 @@ router.put(
'/:projectId/:eventId/notes/:noteId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { eventId, noteId, projectId } = req.params;
const data = req.body;
@@ -887,7 +891,7 @@ router.delete(
'/:projectId/:eventId/notes/:noteId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { eventId, noteId, projectId } = req.params;
@@ -908,7 +912,7 @@ router.delete(
}
);
router.get('/:projectId/slug/:slug', getUser, isAuthorized, async function (
router.get('/:projectId/slug/:slug', getUser, isAuthorized, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,
@@ -37,7 +41,7 @@ router.get(
);
// ping script monitor
router.post('/ping/:monitorId', isAuthorizedService, async function (
router.post('/ping/:monitorId', isAuthorizedService, async function(
req: Request,
res: Response
) {
@@ -69,10 +73,10 @@ router.post('/ping/:monitorId', isAuthorizedService, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? await ProbeService.scriptConditions(resp, [
...monitor.criteria.down.filter(
(criterion: $TSFixMe) => criterion.default !== true
),
])
...monitor.criteria.down.filter(
(criterion: $TSFixMe) => criterion.default !== true
),
])
: { stat: false, successReasons: [], failedReasons: [] };
// determine if monitor is degraded and reasons therefore
@@ -84,9 +88,9 @@ router.post('/ping/:monitorId', isAuthorizedService, async function (
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? await ProbeService.scriptConditions(
resp,
monitor.criteria.degraded
)
resp,
monitor.criteria.degraded
)
: { stat: false, successReasons: [], failedReasons: [] };
// normalize response
@@ -147,9 +151,9 @@ router.post('/ping/:monitorId', isAuthorizedService, async function (
data.reason =
data && data.reason && data.reason.length
? data.reason.filter(
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
: data.reason;
data.matchedUpCriterion =

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import UserService from '../services/userService';
import ComponentService from '../services/componentService';
const getUser = require('../middlewares/user').getUser;
@@ -19,7 +23,7 @@ import { getSubProjects } from '../middlewares/subProject';
const router = express.getRouter();
router.post('/:projectId', getUser, getSubProjects, async function (
router.post('/:projectId', getUser, getSubProjects, async function(
req: Request,
res: Response
) {

View File

@@ -1,11 +1,15 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import { IS_SAAS_SERVICE } from '../config/server';
import { sendItemResponse } from 'common-server/utils/response';
//This API is used to get the backend response if it's a consumer service deployed on OneUptime Cloud or an Enterprise Service deployed on Enterprise customer's cloud.
router.get('/is-saas-service', function (req: Request, res: Response) {
router.get('/is-saas-service', function(req: Request, res: Response) {
if (IS_SAAS_SERVICE) {
return sendItemResponse(req, res, { result: true });
} else {
@@ -13,7 +17,7 @@ router.get('/is-saas-service', function (req: Request, res: Response) {
}
});
router.get('/hosts', function (req: Request, res: Response) {
router.get('/hosts', function(req: Request, res: Response) {
return sendItemResponse(req, res, {
api: global.apiHost,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import request from 'request';
import IntegrationService from '../services/integrationService';
@@ -18,7 +22,7 @@ import {
const router = express.getRouter();
router.get('/auth/redirect', function (req: Request, res: Response) {
router.get('/auth/redirect', function(req: Request, res: Response) {
// get oneuptime project id from slack auth state query params
let state = req.query.state;
const slackCode = req.query.code;
@@ -63,7 +67,7 @@ router.get('/auth/redirect', function (req: Request, res: Response) {
});
});
router.post('/:projectId/link', getUser, isUserAdmin, async function (
router.post('/:projectId/link', getUser, isUserAdmin, async function(
req: Request,
res: Response
) {
@@ -140,7 +144,7 @@ router.delete(
'/:projectId/unLink/:teamId',
getUser,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const projectId = req.params.projectId;
const teamId = req.params.teamId;
@@ -165,7 +169,7 @@ router.delete(
);
// req => params => {projectId}
router.get('/:projectId/teams', getUser, async function (
router.get('/:projectId/teams', getUser, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import SmsLogsService from '../services/smsCountService';
@@ -11,7 +15,7 @@ import { sendListResponse } from 'common-server/utils/response';
import { sendItemResponse } from 'common-server/utils/response';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -92,7 +96,7 @@ router.post(
}
);
router.post('/search', getUser, isUserMasterAdmin, async function (
router.post('/search', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -112,7 +116,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/', getUser, isUserMasterAdmin, async function (
router.delete('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import SmsSmtpService from '../services/smsSmtpService';
import TwilioService from '../services/twilioService';
const router = express.getRouter();
@@ -11,7 +15,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -48,7 +52,7 @@ router.post('/:projectId', getUser, isAuthorized, async function (
}
});
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -68,7 +72,7 @@ router.get('/:projectId', getUser, isAuthorized, async function (
}
});
router.put('/:projectId/:smsSmtpId', getUser, isAuthorized, async function (
router.put('/:projectId/:smsSmtpId', getUser, isAuthorized, async function(
req,
res
) {
@@ -88,7 +92,7 @@ router.put('/:projectId/:smsSmtpId', getUser, isAuthorized, async function (
}
});
router.delete('/:projectId/:smsSmtpId', getUser, isUserOwner, async function (
router.delete('/:projectId/:smsSmtpId', getUser, isUserOwner, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import SmsTemplateService from '../services/smsTemplateService';
const router = express.getRouter();
@@ -17,7 +21,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.post('/:projectId', getUser, isAuthorized, async function (
router.post('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -44,7 +48,7 @@ router.get(
'/:projectId/:templateId/reset',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const templateId = req.params.templateId;
@@ -57,7 +61,7 @@ router.get(
}
);
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -74,7 +78,7 @@ router.get(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const smsTemplateId = req.params.smsTemplateId;
const populate = [{ path: 'projectId', select: 'name' }];
@@ -95,7 +99,7 @@ router.put(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const data = req.body;
const smsTemplateId = req.params.smsTemplateId;
@@ -112,7 +116,7 @@ router.put(
}
);
router.put('/:projectId', getUser, isAuthorized, async function (
router.put('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -157,7 +161,7 @@ router.delete(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const smsTemplateId = req.params.smsTemplateId;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import {
sendErrorResponse,
sendItemResponse,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
const isUserMasterAdmin = require('../middlewares/user').isUserMasterAdmin;
@@ -11,7 +15,7 @@ import { sendErrorResponse } from 'common-server/utils/response';
import SsoService from '../services/ssoService';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -33,7 +37,7 @@ router.get('/', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/:id', getUser, async function (req: Request, res: Response) {
router.delete('/:id', getUser, async function(req: Request, res: Response) {
try {
const sso = await SsoService.deleteBy({ _id: req.params.id });
return sendItemResponse(req, res, sso);
@@ -42,7 +46,7 @@ router.delete('/:id', getUser, async function (req: Request, res: Response) {
}
});
router.post('/', getUser, isScaleOrMasterAdmin, async function (
router.post('/', getUser, isScaleOrMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -55,7 +59,7 @@ router.post('/', getUser, isScaleOrMasterAdmin, async function (
}
});
router.get('/:id', getUser, async function (req: Request, res: Response) {
router.get('/:id', getUser, async function(req: Request, res: Response) {
try {
const selectSso =
'_id saml-enabled domain entityId remoteLoginUrl certificateFingerprint remoteLogoutUrl ipRanges createdAt deleted deletedAt deletedById samlSsoUrl projectId';
@@ -70,7 +74,7 @@ router.get('/:id', getUser, async function (req: Request, res: Response) {
}
});
router.put('/:id', getUser, async function (req: Request, res: Response) {
router.put('/:id', getUser, async function(req: Request, res: Response) {
try {
const data = req.body;
const sso = await SsoService.updateBy({ _id: req.params.id }, data);
@@ -81,7 +85,7 @@ router.put('/:id', getUser, async function (req: Request, res: Response) {
});
// USER API ENDPOINT TO GET SSO INTEGRATION
router.get('/:projectId/ssos', getUser, isScaleOrMasterAdmin, async function (
router.get('/:projectId/ssos', getUser, isScaleOrMasterAdmin, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
const getUser = require('../middlewares/user').getUser;
const isUserMasterAdmin = require('../middlewares/user').isUserMasterAdmin;
@@ -9,7 +13,7 @@ import { sendErrorResponse } from 'common-server/utils/response';
import SsoDefaultRolesService from '../services/ssoDefaultRolesService';
router.get('/', getUser, isUserMasterAdmin, async function (
router.get('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -41,7 +45,7 @@ router.get('/', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/:id', getUser, isUserMasterAdmin, async function (
router.delete('/:id', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -56,7 +60,7 @@ router.delete('/:id', getUser, isUserMasterAdmin, async function (
}
});
router.post('/', getUser, isUserMasterAdmin, async function (
router.post('/', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -69,7 +73,7 @@ router.post('/', getUser, isUserMasterAdmin, async function (
}
});
router.get('/:id', getUser, isUserMasterAdmin, async function (
router.get('/:id', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -98,7 +102,7 @@ router.get('/:id', getUser, isUserMasterAdmin, async function (
}
});
router.put('/:id', getUser, isUserMasterAdmin, async function (
router.put('/:id', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import StatusPageService from '../services/statusPageService';
import MonitorService from '../services/monitorService';
import ProbeService from '../services/probeService';
@@ -359,7 +363,7 @@ router.put(
}
);
router.post('/:projectId/certFile', async function (
router.post('/:projectId/certFile', async function(
req: Request,
res: Response
) {
@@ -372,7 +376,7 @@ router.post('/:projectId/certFile', async function (
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
let cert;
if (error) {
return sendErrorResponse(req, res, error);
@@ -388,7 +392,7 @@ router.post('/:projectId/certFile', async function (
}
});
router.post('/:projectId/privateKeyFile', async function (
router.post('/:projectId/privateKeyFile', async function(
req: Request,
res: Response
) {
@@ -401,7 +405,7 @@ router.post('/:projectId/privateKeyFile', async function (
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
let privateKey;
if (error) {
return sendErrorResponse(req, res, error);
@@ -422,7 +426,7 @@ router.post('/:projectId/privateKeyFile', async function (
// fetch details about a custom domain
// to be consumed by the status page
router.get('/tlsCredential', async function (req: Request, res: Response) {
router.get('/tlsCredential', async function(req: Request, res: Response) {
try {
const { domain } = req.query;
@@ -502,7 +506,7 @@ router.delete(
// Params:
// Param1:
// Returns: response status, error message
router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -575,7 +579,7 @@ router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
}
}
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
const files = req.files || {};
const data = req.body;
data.projectId = req.params.projectId;
@@ -698,7 +702,7 @@ router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
});
});
router.get('/statusBubble', async function (req: Request, res: Response) {
router.get('/statusBubble', async function(req: Request, res: Response) {
const statusPageId = req.query.statusPageId;
const statusBubbleId = req.query.statusBubbleId;
try {
@@ -776,7 +780,7 @@ router.get('/statusBubble', async function (req: Request, res: Response) {
// Param1: req.params-> {projectId};
// Returns: response status, error message
router.get('/:projectId/dashboard', getUser, isAuthorized, async function (
router.get('/:projectId/dashboard', getUser, isAuthorized, async function(
req,
res
) {
@@ -824,7 +828,7 @@ router.get('/:projectId/dashboard', getUser, isAuthorized, async function (
}
});
router.get('/:projectId/status-pages', getUser, isAuthorized, async function (
router.get('/:projectId/status-pages', getUser, isAuthorized, async function(
req,
res
) {
@@ -843,7 +847,7 @@ router.get('/:projectId/status-pages', getUser, isAuthorized, async function (
}
});
router.get('/:projectId/statuspage', getUser, isAuthorized, async function (
router.get('/:projectId/statuspage', getUser, isAuthorized, async function(
req,
res
) {
@@ -890,7 +894,7 @@ router.get('/:projectId/statuspage', getUser, isAuthorized, async function (
});
// External status page api - get the data to show on status page using Slug
router.get('/:statusPageSlug', checkUser, ipWhitelist, async function (
router.get('/:statusPageSlug', checkUser, ipWhitelist, async function(
req,
res
) {
@@ -962,7 +966,7 @@ router.post(
'/:projectId/:statusPageSlug/duplicateStatusPage',
getUser,
isAuthorized,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, statusPageSlug } = req.params;
const { subProjectId } = req.query;
@@ -996,7 +1000,7 @@ router.post(
}
);
router.get('/:statusPageId/rss', checkUser, async function (
router.get('/:statusPageId/rss', checkUser, async function(
req: Request,
res: Response
) {
@@ -1044,14 +1048,17 @@ router.get('/:statusPageId/rss', checkUser, async function (
guid: `${global.apiHost}/status-page/${statusPageId}/rss/${incident._id}`,
pubDate: new Date(incident.createdAt).toUTCString(),
description: `<![CDATA[Description: ${incident.description
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
incident.monitors
)}<br>Acknowledge Time: ${incident.acknowledgedAt
}<br>Resolve Time: ${incident.resolvedAt}<br>${incident.investigationNote
description: `<![CDATA[Description: ${
incident.description
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
incident.monitors
)}<br>Acknowledge Time: ${
incident.acknowledgedAt
}<br>Resolve Time: ${incident.resolvedAt}<br>${
incident.investigationNote
? `Investigation Note: ${incident.investigationNote}`
: ''
}]]>`,
}]]>`,
},
});
}
@@ -1101,7 +1108,7 @@ router.get(
'/:projectId/:statusPageSlug/notes',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
let result;
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
@@ -1149,7 +1156,7 @@ router.get(
}
);
router.get('/:projectId/incident/:incidentSlug', checkUser, async function (
router.get('/:projectId/incident/:incidentSlug', checkUser, async function(
req,
res
) {
@@ -1170,7 +1177,7 @@ router.get('/:projectId/incident/:incidentSlug', checkUser, async function (
}
});
router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function (
router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function(
req,
res
) {
@@ -1195,7 +1202,7 @@ router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function
}
});
router.get('/:projectId/:monitorId/individualnotes', checkUser, async function (
router.get('/:projectId/:monitorId/individualnotes', checkUser, async function(
req,
res
) {
@@ -1272,7 +1279,7 @@ router.get(
'/:projectId/:statusPageSlug/events',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
const limit = req.query.limit || 5;
@@ -1304,7 +1311,7 @@ router.get(
'/:projectId/:statusPageSlug/futureEvents',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1329,7 +1336,7 @@ router.get(
'/:projectId/:statusPageSlug/pastEvents',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1372,7 +1379,7 @@ const fetchNotes = async (events: $TSFixMe, limit: $TSFixMe) => {
}
};
router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function (
router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function(
req,
res
) {
@@ -1398,7 +1405,7 @@ router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function (
}
});
router.get('/:projectId/:monitorId/individualevents', checkUser, async function (
router.get('/:projectId/:monitorId/individualevents', checkUser, async function(
req,
res
) {
@@ -1457,7 +1464,7 @@ router.get('/:projectId/:monitorId/individualevents', checkUser, async function
router.get(
'/:projectId/scheduledEvent/:scheduledEventId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const { scheduledEventId } = req.params;
try {
@@ -1472,7 +1479,7 @@ router.get(
);
// Route
// Description: Get all Monitor Statuses by monitorId
router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function (
router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function(
req,
res
) {
@@ -1490,7 +1497,7 @@ router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function
}
});
router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function (
router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function(
req,
res
) {
@@ -1534,7 +1541,7 @@ router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function (
}
});
router.get('/:projectId/probes', checkUser, async function (
router.get('/:projectId/probes', checkUser, async function(
req: Request,
res: Response
) {
@@ -1563,7 +1570,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const statusPageSlug = req.params.statusPageSlug;
const userId = req.user ? req.user.id : null;
@@ -1580,7 +1587,7 @@ router.delete(
}
);
router.get('/:projectId/timeline/:incidentSlug', checkUser, async function (
router.get('/:projectId/timeline/:incidentSlug', checkUser, async function(
req,
res
) {
@@ -1621,7 +1628,7 @@ router.get(
'/:projectId/:statusPageSlug/timelines',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -1641,7 +1648,7 @@ router.get(
//get subscribers by monitorId in a statuspage
// req.params-> {projectId, monitorId, statusPageId};
// Returns: response subscribers, error message
router.get('/:projectId/monitor/:statusPageId', checkUser, async function (
router.get('/:projectId/monitor/:statusPageId', checkUser, async function(
req,
res
) {
@@ -1693,7 +1700,7 @@ router.get('/:projectId/monitor/:statusPageId', checkUser, async function (
router.post(
'/:projectId/createExternalstatus-page/:statusPageId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, statusPageId } = req.params;
const { name, url } = req.body;
@@ -1808,7 +1815,7 @@ router.post(
router.post(
'/:projectId/updateExternalstatus-page/:externalStatusPageId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, externalStatusPageId } = req.params;
const { name, url } = req.body;
@@ -1902,7 +1909,7 @@ router.post(
router.get(
'/:projectId/fetchExternalStatusPages/:statusPageId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, statusPageId } = req.params;
@@ -1936,7 +1943,7 @@ router.get(
router.post(
'/:projectId/deleteExternalstatus-page/:externalStatusPageId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, externalStatusPageId } = req.params;
@@ -1970,7 +1977,7 @@ router.post(
}
);
router.post('/:projectId/announcement/:statusPageId', checkUser, async function (
router.post('/:projectId/announcement/:statusPageId', checkUser, async function(
req,
res
) {
@@ -2022,7 +2029,7 @@ router.post('/:projectId/announcement/:statusPageId', checkUser, async function
router.put(
'/:projectId/announcement/:statusPageId/:announcementId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, statusPageId, announcementId } = req.params;
const { data } = req.body;
@@ -2108,7 +2115,7 @@ router.put(
router.get(
'/:projectId/announcementLogs/:statusPageId',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageId } = req.params;
const { skip, limit, theme } = req.query;
@@ -2148,7 +2155,7 @@ router.get(
}
);
router.get('/:projectId/announcement/:statusPageId', checkUser, async function (
router.get('/:projectId/announcement/:statusPageId', checkUser, async function(
req,
res
) {
@@ -2178,7 +2185,7 @@ router.get('/:projectId/announcement/:statusPageId', checkUser, async function (
router.get(
'/:projectId/announcement/:statusPageSlug/single/:announcementSlug',
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, statusPageSlug, announcementSlug } = req.params;
@@ -2201,7 +2208,7 @@ router.get(
router.delete(
`/:projectId/announcement/:announcementId/delete`,
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId, announcementId } = req.params;
@@ -2223,7 +2230,7 @@ router.delete(
router.delete(
`/:projectId/announcementLog/:announcementLogId/delete`,
checkUser,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { announcementLogId } = req.params;
@@ -2304,8 +2311,9 @@ function handleMonitorList(monitors: $TSFixMe) {
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name} and ${monitors[2].monitorId.name}`;
}
if (monitors.length > 3) {
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name
} and ${monitors.length - 2} others`;
return `${monitors[0].monitorId.name}, ${
monitors[1].monitorId.name
} and ${monitors.length - 2} others`;
}
}
@@ -2313,7 +2321,7 @@ router.get(
'/resources/:statusPageSlug/ongoing-events',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2341,7 +2349,7 @@ router.get(
'/resources/:statusPageSlug/future-events',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2365,7 +2373,7 @@ router.get(
'/resources/:statusPageSlug/past-events',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2389,7 +2397,7 @@ router.get(
'/resources/:statusPageSlug/probes',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2413,7 +2421,7 @@ router.get(
'/resources/:statusPageSlug/monitor-logs',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2437,7 +2445,7 @@ router.get(
'/resources/:statusPageSlug/announcements',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2467,7 +2475,7 @@ router.get(
'/resources/:statusPageSlug/announcement-logs',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2491,7 +2499,7 @@ router.get(
'/resources/:statusPageSlug/monitor-timelines',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2515,7 +2523,7 @@ router.get(
'/resources/:statusPageSlug/statuspage-notes',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2545,7 +2553,7 @@ router.get(
'/resources/:statusPageSlug/monitor-statuses',
checkUser,
ipWhitelist,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { range } = req.query;
@@ -2953,18 +2961,18 @@ const filterProbeData = (
monitorStatuses && monitorStatuses.length > 0
? probe
? monitorStatuses.filter((probeStatuses: $TSFixMe) => {
return (
probeStatuses._id === null ||
String(probeStatuses._id) === String(probe._id)
);
})
return (
probeStatuses._id === null ||
String(probeStatuses._id) === String(probe._id)
);
})
: monitorStatuses
: [];
const statuses =
probesStatus &&
probesStatus[0] &&
probesStatus[0].statuses &&
probesStatus[0].statuses.length > 0
probesStatus[0] &&
probesStatus[0].statuses &&
probesStatus[0].statuses.length > 0
? probesStatus[0].statuses
: [];

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import { isAuthorized } from '../middlewares/authorization';
@@ -16,7 +20,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageCategoryName } = req.body;
const { statusPageId } = req.params;
@@ -68,7 +72,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageCategoryId } = req.params;
@@ -107,7 +111,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { statusPageCategoryId } = req.params;
const { statusPageCategoryName } = req.body;
@@ -154,7 +158,7 @@ router.put(
}
);
router.get('/:projectId/:statusPageId', getUser, isAuthorized, async function (
router.get('/:projectId/:statusPageId', getUser, isAuthorized, async function(
req,
res
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import StripeService from '../services/stripeService';
import {
sendErrorResponse,
@@ -23,7 +27,7 @@ const router = express.getRouter();
// Params:
// Param 1: webhookURL
// Returns: 200: Event object with various status.
router.post('/events', async function (req: Request, res: Response) {
router.post('/events', async function(req: Request, res: Response) {
try {
const event = req.body;
const customerId = event.data.object.customer;
@@ -65,7 +69,7 @@ router.post('/events', async function (req: Request, res: Response) {
}
});
router.get('/:userId/charges', getUser, async function (
router.get('/:userId/charges', getUser, async function(
req: Request,
res: Response
) {
@@ -84,7 +88,7 @@ router.get('/:userId/charges', getUser, async function (
}
});
router.post('/:userId/creditCard/:token/pi', getUser, async function (
router.post('/:userId/creditCard/:token/pi', getUser, async function(
req: Request,
res: Response
) {
@@ -105,7 +109,7 @@ router.post('/:userId/creditCard/:token/pi', getUser, async function (
}
});
router.put('/:userId/creditCard/:cardId', getUser, async function (
router.put('/:userId/creditCard/:cardId', getUser, async function(
req: Request,
res: Response
) {
@@ -126,7 +130,7 @@ router.put('/:userId/creditCard/:cardId', getUser, async function (
}
});
router.delete('/:userId/creditCard/:cardId', getUser, async function (
router.delete('/:userId/creditCard/:cardId', getUser, async function(
req: Request,
res: Response
) {
@@ -147,7 +151,7 @@ router.delete('/:userId/creditCard/:cardId', getUser, async function (
}
});
router.get('/:userId/creditCard', getUser, async function (
router.get('/:userId/creditCard', getUser, async function(
req: Request,
res: Response
) {
@@ -166,7 +170,7 @@ router.get('/:userId/creditCard', getUser, async function (
}
});
router.get('/:userId/creditCard/:cardId', getUser, async function (
router.get('/:userId/creditCard/:cardId', getUser, async function(
req: Request,
res: Response
) {
@@ -192,7 +196,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
const { projectId } = req.params;
@@ -217,7 +221,7 @@ router.post(
}
);
router.post('/checkCard', async function (req: Request, res: Response) {
router.post('/checkCard', async function(req: Request, res: Response) {
try {
const { tokenId, email, companyName } = req.body;
const paymentIntent = await StripeService.makeTestCharge(
@@ -236,7 +240,7 @@ router.get(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { intentId } = req.params;
@@ -266,7 +270,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const { projectId } = req.params;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import SubscriberService from '../services/subscriberService';
@@ -16,7 +20,7 @@ import {
// req.params->{projectId}; req.body -> {monitorIds, alertVia, contactEmail, contactPhone, }
// Returns: response status page, error message
router.post('/:projectId/:statusPageId', async function (
router.post('/:projectId/:statusPageId', async function(
req: Request,
res: Response
) {
@@ -159,7 +163,7 @@ router.post('/:projectId/:statusPageId', async function (
}
});
router.post('/:projectId/subscribe/:monitorId', async function (
router.post('/:projectId/subscribe/:monitorId', async function(
req: Request,
res: Response
) {
@@ -308,7 +312,7 @@ router.post('/:projectId/subscribe/:monitorId', async function (
// get subscribers by projectId
// req.params-> {projectId};
// Returns: response subscriber, error message
router.get('/:projectId', async function (req: Request, res: Response) {
router.get('/:projectId', async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const skip = req.query.skip || 0;
@@ -329,7 +333,7 @@ router.get('/:projectId', async function (req: Request, res: Response) {
//get subscribers by monitorId
// req.params-> {projectId, monitorId};
// Returns: response subscriber, error message
router.get('/:projectId/monitor/:monitorId', async function (
router.get('/:projectId/monitor/:monitorId', async function(
req: Request,
res: Response
) {
@@ -363,7 +367,7 @@ router.get('/:projectId/monitor/:monitorId', async function (
//get monitors by subscriberId
// req.params-> {subscriberId};
// Returns: response subscriber, error message
router.get('/monitorList/:subscriberId', async function (
router.get('/monitorList/:subscriberId', async function(
req: Request,
res: Response
) {
@@ -419,7 +423,7 @@ router.get('/monitorList/:subscriberId', async function (
//Get a subscriber.
//req.params-> {projectId, subscriberId}
// Returns: response subscriber, error message
router.get('/:projectId/:subscriberId', async function (
router.get('/:projectId/:subscriberId', async function(
req: Request,
res: Response
) {
@@ -446,7 +450,7 @@ router.get('/:projectId/:subscriberId', async function (
//unsubscribe subscriber.
//req.params-> {monitorId, subscriberId}
// Returns: response subscriber, error message
router.put('/unsubscribe/:monitorId/:email', async function (
router.put('/unsubscribe/:monitorId/:email', async function(
req: Request,
res: Response
) {
@@ -464,7 +468,7 @@ router.put('/unsubscribe/:monitorId/:email', async function (
// delete a subscriber.
// req.params-> {projectId, subscriberId}
// Returns: response subscriber, error message
router.delete('/:projectId/:subscriberId', getUser, async function (
router.delete('/:projectId/:subscriberId', getUser, async function(
req: Request,
res: Response
) {
@@ -482,7 +486,7 @@ router.delete('/:projectId/:subscriberId', getUser, async function (
}
});
router.post('/:projectId/:monitorId/csv', async function (
router.post('/:projectId/:monitorId/csv', async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import SubscriberAlertService from '../services/subscriberAlertService';
import path from 'path';
import fs from 'fs';
@@ -42,7 +46,7 @@ router.post(
);
// Mark alert as viewed
router.get('/:projectId/:alertId/viewed', async function (
router.get('/:projectId/:alertId/viewed', async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import TeamService from '../services/teamService';
@@ -21,7 +25,7 @@ import ErrorService from 'common-server/utils/error';
// Params:
// Param 1: req.headers-> {token}; req.params-> {projectId}; req.user-> {id}
// Returns: 200: An array of users belonging to the project.
router.get('/:projectId', getUser, isAuthorized, async function (
router.get('/:projectId', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -41,7 +45,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
: null;
@@ -66,7 +70,7 @@ router.get(
// Description: Get individual team member details
// Params
// Returns: 200: Individual team member object; 400: Error.
router.get('/:projectId/:teamMemberId', getUser, isAuthorized, async function (
router.get('/:projectId/:teamMemberId', getUser, isAuthorized, async function(
req,
res
) {
@@ -109,7 +113,7 @@ router.get('/:projectId/:teamMemberId', getUser, isAuthorized, async function (
// Params:
// Param 1: req.body-> {emails, role}; req.headers-> {token}; req.params-> {projectId}
// Returns: 200: An array of users belonging to the project; 400: Error.
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
req,
res
) {
@@ -216,7 +220,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const userId = req.user ? req.user.id : null;
const teamMemberUserId = req.params.teamMemberId;
const projectId = req.params.projectId;
@@ -261,7 +265,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
const data = req.body;
const projectId = req.params.projectId;
data.teamMemberId = req.params.teamMemberId;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import UserService from '../services/userService';
@@ -15,7 +19,7 @@ import {
// jwtAccessToken: token.accessToken,
// jwtRefreshToken: token.refreshToken,
// }
router.post('/new', async function (req: Request, res: Response) {
router.post('/new', async function(req: Request, res: Response) {
try {
const jwtRefreshToken = req.body.refreshToken;

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import UserService from '../services/userService';
@@ -9,7 +13,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.get('/', getUser, async function (req: Request, res: Response) {
router.get('/', getUser, async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
const user = await UserService.findOneBy({
@@ -27,7 +31,7 @@ router.get('/', getUser, async function (req: Request, res: Response) {
}
});
router.put('/', getUser, async function (req: Request, res: Response) {
router.put('/', getUser, async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
let user = await UserService.findOneBy({

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import IncidentService from '../services/incidentService';
import UserService from '../services/userService';
const {
@@ -105,7 +109,7 @@ router.get('/voice/status', async (req: Request, res: Response) => {
* @returns Twiml with with action status.
*/
router.post('/sms/sendVerificationToken', getUser, isAuthorized, async function (
router.post('/sms/sendVerificationToken', getUser, isAuthorized, async function(
req,
res
) {
@@ -133,7 +137,7 @@ router.post('/sms/sendVerificationToken', getUser, isAuthorized, async function
}
});
router.post('/sms/verify', getUser, isAuthorized, async function (
router.post('/sms/verify', getUser, isAuthorized, async function(
req: Request,
res: Response
) {
@@ -186,7 +190,7 @@ router.post('/sms/verify', getUser, isAuthorized, async function (
}
});
router.post('/sms/test', getUser, isUserMasterAdmin, async function (
router.post('/sms/test', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import UserService from '../services/userService';
import ProjectService from '../services/projectService';
const jwtSecretKey = process.env['JWT_SECRET'];
@@ -36,7 +40,7 @@ import SsoDefaultRolesService from '../services/ssoDefaultRolesService';
const isUserMasterAdmin = require('../middlewares/user').isUserMasterAdmin;
import Ip from '../middlewares/ipHandler';
router.post('/signup', async function (req: Request, res: Response) {
router.post('/signup', async function(req: Request, res: Response) {
try {
if (
typeof process.env.DISABLE_SIGNUP === 'string' &&
@@ -296,7 +300,7 @@ router.post('/signup', async function (req: Request, res: Response) {
}
});
router.get('/masterAdminExists', async function (req: Request, res: Response) {
router.get('/masterAdminExists', async function(req: Request, res: Response) {
try {
const masterAdmin = await UserService.findBy({
query: { role: 'master-admin' },
@@ -318,7 +322,7 @@ router.get('/masterAdminExists', async function (req: Request, res: Response) {
// Params:
// Param 1: req.query-> {email }
// Returns: 400: Error; 500: Server Error; 200: redirect to login page
router.get('/sso/login', async function (req: Request, res: Response) {
router.get('/sso/login', async function(req: Request, res: Response) {
const { email } = req.query;
if (!email) {
return sendErrorResponse(req, res, {
@@ -369,7 +373,7 @@ router.get('/sso/login', async function (req: Request, res: Response) {
sso_login_url: remoteLoginUrl,
});
sp.create_login_request_url(idp, {}, function (
sp.create_login_request_url(idp, {}, function(
error: $TSFixMe,
login_url: $TSFixMe
) {
@@ -384,7 +388,7 @@ router.get('/sso/login', async function (req: Request, res: Response) {
// Route
// Description: Callback function after SSO authentication page
// param: query->{domain}
router.post('/sso/callback', async function (req: Request, res: Response) {
router.post('/sso/callback', async function(req: Request, res: Response) {
const options = {
request_body: req.body,
allow_unencrypted_assertion: true,
@@ -424,7 +428,7 @@ router.post('/sso/callback', async function (req: Request, res: Response) {
sso_login_url: sso.samlSsoUrl,
});
sp.post_assert(idp, options, async function (
sp.post_assert(idp, options, async function(
err: $TSFixMe,
saml_response: $TSFixMe
) {
@@ -520,14 +524,14 @@ router.post('/sso/callback', async function (req: Request, res: Response) {
return res.redirect(
`${global.accountsHost}` +
`/ssologin?id=${authUserObj.id}` +
`&name=${authUserObj.name}` +
`&email=${authUserObj.email}` +
`&jwtAccessToken=${authUserObj.tokens.jwtAccessToken}` +
`&jwtRefreshToken=${authUserObj.tokens.jwtRefreshToken}` +
`&role=${authUserObj.role}` +
`&redirect=${authUserObj.redirect}` +
`&cardRegistered=${authUserObj.cardRegistered}`
`/ssologin?id=${authUserObj.id}` +
`&name=${authUserObj.name}` +
`&email=${authUserObj.email}` +
`&jwtAccessToken=${authUserObj.tokens.jwtAccessToken}` +
`&jwtRefreshToken=${authUserObj.tokens.jwtRefreshToken}` +
`&role=${authUserObj.role}` +
`&redirect=${authUserObj.redirect}` +
`&cardRegistered=${authUserObj.cardRegistered}`
);
});
});
@@ -537,7 +541,7 @@ router.post('/sso/callback', async function (req: Request, res: Response) {
// Params:
// Param 1: req.body-> {email, password }
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/login', async function (req: Request, res: Response) {
router.post('/login', async function(req: Request, res: Response) {
try {
const data = req.body;
const clientIP = Ip.getClientIp(req)[0];
@@ -614,7 +618,7 @@ router.post('/login', async function (req: Request, res: Response) {
// Params:
// Param 1: req.body-> {token}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/totp/verifyToken', async function (req: Request, res: Response) {
router.post('/totp/verifyToken', async function(req: Request, res: Response) {
try {
const data = req.body;
const token = data.token;
@@ -680,7 +684,7 @@ router.post('/totp/verifyToken', async function (req: Request, res: Response) {
// Params:
// Param 1: req.body-> {code}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/verify/backupCode', async function (req: Request, res: Response) {
router.post('/verify/backupCode', async function(req: Request, res: Response) {
try {
const data = req.body;
// Call the UserService
@@ -764,7 +768,7 @@ router.post('/verify/backupCode', async function (req: Request, res: Response) {
// Params:
// None
// Return: return the new list of backup codes.
router.post('/generate/backupCode', getUser, async function (
router.post('/generate/backupCode', getUser, async function(
req: Request,
res: Response
) {
@@ -818,7 +822,7 @@ router.post('/generate/backupCode', getUser, async function (
// Params:
// Param 1: req.params-> {userId}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/totp/token/:userId', async function (req: Request, res: Response) {
router.post('/totp/token/:userId', async function(req: Request, res: Response) {
try {
const userId = req.params.userId;
const user = await UserService.findOneBy({
@@ -850,7 +854,7 @@ router.post('/totp/token/:userId', async function (req: Request, res: Response)
// Param 1: req.body-> {email}; req.headers-> {host}
// Returns: 400: Error; 500: Server Error: 200: User password has been reset successfully.
router.post('/forgot-password', async function (req: Request, res: Response) {
router.post('/forgot-password', async function(req: Request, res: Response) {
try {
const data = req.body;
@@ -891,7 +895,7 @@ router.post('/forgot-password', async function (req: Request, res: Response) {
// Params:
// Param 1: req.body-> {password}; req.params-> {token}
// Returns: 400: Error; 500: Server Error; 200: User password has been reset successfully.
router.post('/reset-password', async function (req: Request, res: Response) {
router.post('/reset-password', async function(req: Request, res: Response) {
try {
const data = req.body;
@@ -951,7 +955,7 @@ router.post('/reset-password', async function (req: Request, res: Response) {
// Params:
// Param 1: req.body-> {email, password }
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/isInvited', async function (req: Request, res: Response) {
router.post('/isInvited', async function(req: Request, res: Response) {
try {
const data = req.body;
@@ -995,7 +999,7 @@ router.post(
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/profile', getUser, async function (req: Request, res: Response) {
router.put('/profile', getUser, async function(req: Request, res: Response) {
try {
const upload = multer({
storage,
@@ -1005,7 +1009,7 @@ router.put('/profile', getUser, async function (req: Request, res: Response) {
maxCount: 1,
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
const userId = req.user ? req.user.id : null;
const data = req.body;
@@ -1046,7 +1050,7 @@ router.put('/profile', getUser, async function (req: Request, res: Response) {
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/push-notification', getUser, async function (
router.put('/push-notification', getUser, async function(
req: Request,
res: Response
) {
@@ -1065,7 +1069,7 @@ router.put('/push-notification', getUser, async function (
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/:userId/2fa', isUserMasterAdmin, async function (
router.put('/:userId/2fa', isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -1090,7 +1094,7 @@ router.put('/:userId/2fa', isUserMasterAdmin, async function (
}
});
router.put('/profile/:userId', getUser, isUserMasterAdmin, async function (
router.put('/profile/:userId', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1104,7 +1108,7 @@ router.put('/profile/:userId', getUser, isUserMasterAdmin, async function (
},
]);
upload(req, res, async function (error: $TSFixMe) {
upload(req, res, async function(error: $TSFixMe) {
const userId = req.params.userId;
const data = req.body;
@@ -1134,7 +1138,7 @@ router.put('/profile/:userId', getUser, isUserMasterAdmin, async function (
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic}; req.data- {currentPassword, newPassword, confirmPassword}
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/changePassword', getUser, async function (
router.put('/changePassword', getUser, async function(
req: Request,
res: Response
) {
@@ -1229,7 +1233,7 @@ router.put('/changePassword', getUser, async function (
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.get('/profile', getUser, async function (req: Request, res: Response) {
router.get('/profile', getUser, async function(req: Request, res: Response) {
try {
const userId = req.user ? req.user.id : null;
@@ -1286,7 +1290,7 @@ router.get('/profile', getUser, async function (req: Request, res: Response) {
}
});
router.get('/confirmation/:token', async function (req: Request, res: Response) {
router.get('/confirmation/:token', async function(req: Request, res: Response) {
try {
if (req.params && req.params.token) {
const token = await VerificationTokenModel.findOne({
@@ -1295,7 +1299,7 @@ router.get('/confirmation/:token', async function (req: Request, res: Response)
if (!token) {
return res.redirect(
global.accountsHost +
'/user-verify/resend?status=link-expired'
'/user-verify/resend?status=link-expired'
);
}
const user = await UserModel.findOne({
@@ -1332,7 +1336,7 @@ router.get('/confirmation/:token', async function (req: Request, res: Response)
} else {
return res.redirect(
global.accountsHost +
'/user-verify/resend?status=invalid-verification-link'
'/user-verify/resend?status=invalid-verification-link'
);
}
} catch (error) {
@@ -1341,7 +1345,7 @@ router.get('/confirmation/:token', async function (req: Request, res: Response)
}
});
router.post('/resend', async function (req: Request, res: Response) {
router.post('/resend', async function(req: Request, res: Response) {
if (req.body && req.body.email) {
const { email, userId } = req.body;
let user;
@@ -1389,7 +1393,7 @@ router.post('/resend', async function (req: Request, res: Response) {
}
});
router.get('/users', getUser, isUserMasterAdmin, async function (
router.get('/users', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -1409,7 +1413,7 @@ router.get('/users', getUser, isUserMasterAdmin, async function (
}
});
router.get('/users/:userId', getUser, isUserMasterAdmin, async function (
router.get('/users/:userId', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1428,7 +1432,7 @@ router.get('/users/:userId', getUser, isUserMasterAdmin, async function (
}
});
router.delete('/:userId', getUser, isUserMasterAdmin, async function (
router.delete('/:userId', getUser, isUserMasterAdmin, async function(
req: Request,
res: Response
) {
@@ -1453,7 +1457,7 @@ router.delete('/:userId', getUser, isUserMasterAdmin, async function (
}
});
router.put('/:userId/restoreUser', getUser, isUserMasterAdmin, async function (
router.put('/:userId/restoreUser', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1479,7 +1483,7 @@ router.put('/:userId/restoreUser', getUser, isUserMasterAdmin, async function (
}
});
router.put('/:userId/blockUser', getUser, isUserMasterAdmin, async function (
router.put('/:userId/blockUser', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1505,7 +1509,7 @@ router.put('/:userId/blockUser', getUser, isUserMasterAdmin, async function (
}
});
router.put('/:userId/unblockUser', getUser, isUserMasterAdmin, async function (
router.put('/:userId/unblockUser', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1540,7 +1544,7 @@ router.post(
'/:userId/switchToAdminMode',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.params.userId;
@@ -1574,7 +1578,7 @@ router.post(
'/:userId/exitAdminMode',
getUser,
isUserMasterAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const userId = req.params.userId;
@@ -1595,7 +1599,7 @@ router.post(
}
);
router.post('/:userId/addNote', getUser, isUserMasterAdmin, async function (
router.post('/:userId/addNote', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1641,7 +1645,7 @@ router.post('/:userId/addNote', getUser, isUserMasterAdmin, async function (
}
});
router.post('/users/search', getUser, isUserMasterAdmin, async function (
router.post('/users/search', getUser, isUserMasterAdmin, async function(
req,
res
) {
@@ -1686,7 +1690,7 @@ router.post('/users/search', getUser, isUserMasterAdmin, async function (
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 401: Unauthorized; 500: Server Error.
router.delete('/:userId/delete', getUser, async function (
router.delete('/:userId/delete', getUser, async function(
req: Request,
res: Response
) {
@@ -1766,7 +1770,7 @@ router.delete('/:userId/delete', getUser, async function (
}
});
router.get('/:token/email', async function (req: Request, res: Response) {
router.get('/:token/email', async function(req: Request, res: Response) {
try {
const token = await VerificationTokenModel.findOne({
token: req.params.token,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
const router = express.getRouter();
import {
@@ -6,7 +10,7 @@ import {
sendItemResponse,
} from 'common-server/utils/response';
router.get('/', function (req: Request, res: Response) {
router.get('/', function(req: Request, res: Response) {
try {
return sendItemResponse(req, res, {
server: process.env.npm_package_version,

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import IntegrationService from '../services/integrationService';
const getUser = require('../middlewares/user').getUser;
const isUserAdmin = require('../middlewares/project').isUserAdmin;
@@ -10,7 +14,7 @@ import {
const router = express.getRouter();
router.post('/:projectId/create', getUser, isUserAdmin, async function (
router.post('/:projectId/create', getUser, isUserAdmin, async function(
req,
res
) {
@@ -134,7 +138,7 @@ router.post('/:projectId/create', getUser, isUserAdmin, async function (
});
// update webhook
router.put('/:projectId/:integrationId', getUser, isUserAdmin, async function (
router.put('/:projectId/:integrationId', getUser, isUserAdmin, async function(
req,
res
) {
@@ -251,7 +255,7 @@ router.delete(
'/:projectId/delete/:integrationId',
getUser,
isUserAdmin,
async function (req: Request, res: Response) {
async function(req: Request, res: Response) {
try {
const projectId = req.params.projectId;
const integrationId = req.params.integrationId;
@@ -269,7 +273,7 @@ router.delete(
);
// req => params => {projectId}
router.get('/:projectId/hooks', getUser, async function (
router.get('/:projectId/hooks', getUser, async function(
req: Request,
res: Response
) {
@@ -305,7 +309,7 @@ router.get('/:projectId/hooks', getUser, async function (
});
// req => params => {projectId, monitorId}
router.get('/:projectId/hooks/:monitorId', getUser, async function (
router.get('/:projectId/hooks/:monitorId', getUser, async function(
req: Request,
res: Response
) {

View File

@@ -1,4 +1,8 @@
import express, { Request, Response, NextFunction } from 'common-server/utils/express';
import express, {
Request,
Response,
NextFunction,
} from 'common-server/utils/express';
import ZapierService from '../services/zapierService';
import MonitorService from '../services/monitorService';
import ProjectService from '../services/projectService';
@@ -13,7 +17,7 @@ import { sendEmptyResponse } from 'common-server/utils/response';
const router = express.getRouter();
router.get('/test', isAuthorized, async function (req: Request, res: Response) {
router.get('/test', isAuthorized, async function(req: Request, res: Response) {
try {
const apiKey = req.query.apiKey;
const projectId = req.query.projectId;
@@ -24,7 +28,7 @@ router.get('/test', isAuthorized, async function (req: Request, res: Response) {
}
});
router.get('/monitors', isAuthorized, async function (
router.get('/monitors', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -57,7 +61,7 @@ router.get('/monitors', isAuthorized, async function (
}
});
router.post('/incident/createIncident', isAuthorized, async function (
router.post('/incident/createIncident', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -70,7 +74,7 @@ router.post('/incident/createIncident', isAuthorized, async function (
}
});
router.get('/incidents', isAuthorized, async function (
router.get('/incidents', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -85,7 +89,7 @@ router.get('/incidents', isAuthorized, async function (
}
});
router.get('/incident-note', isAuthorized, async function (
router.get('/incident-note', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -100,7 +104,7 @@ router.get('/incident-note', isAuthorized, async function (
}
});
router.post('/incident/incident-note', isAuthorized, async function (
router.post('/incident/incident-note', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -113,7 +117,7 @@ router.post('/incident/incident-note', isAuthorized, async function (
}
});
router.get('/incident/resolved', isAuthorized, async function (
router.get('/incident/resolved', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -129,7 +133,7 @@ router.get('/incident/resolved', isAuthorized, async function (
}
});
router.post('/incident/resolveLastIncident', isAuthorized, async function (
router.post('/incident/resolveLastIncident', isAuthorized, async function(
req,
res
) {
@@ -143,7 +147,7 @@ router.post('/incident/resolveLastIncident', isAuthorized, async function (
}
});
router.post('/incident/resolveAllIncidents', isAuthorized, async function (
router.post('/incident/resolveAllIncidents', isAuthorized, async function(
req,
res
) {
@@ -158,7 +162,7 @@ router.post('/incident/resolveAllIncidents', isAuthorized, async function (
}
});
router.post('/incident/resolveIncident', isAuthorized, async function (
router.post('/incident/resolveIncident', isAuthorized, async function(
req,
res
) {
@@ -176,7 +180,7 @@ router.post('/incident/resolveIncident', isAuthorized, async function (
}
});
router.get('/incident/acknowledged', isAuthorized, async function (
router.get('/incident/acknowledged', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -197,7 +201,7 @@ router.get('/incident/acknowledged', isAuthorized, async function (
}
});
router.post('/incident/acknowledgeLastIncident', isAuthorized, async function (
router.post('/incident/acknowledgeLastIncident', isAuthorized, async function(
req,
res
) {
@@ -211,7 +215,7 @@ router.post('/incident/acknowledgeLastIncident', isAuthorized, async function (
}
});
router.post('/incident/acknowledgeAllIncidents', isAuthorized, async function (
router.post('/incident/acknowledgeAllIncidents', isAuthorized, async function(
req,
res
) {
@@ -226,7 +230,7 @@ router.post('/incident/acknowledgeAllIncidents', isAuthorized, async function (
}
});
router.post('/incident/acknowledgeIncident', isAuthorized, async function (
router.post('/incident/acknowledgeIncident', isAuthorized, async function(
req,
res
) {
@@ -244,7 +248,7 @@ router.post('/incident/acknowledgeIncident', isAuthorized, async function (
}
});
router.post('/subscribe', isAuthorized, async function (
router.post('/subscribe', isAuthorized, async function(
req: Request,
res: Response
) {
@@ -283,7 +287,7 @@ router.post('/subscribe', isAuthorized, async function (
}
});
router.delete('/unsubscribe/:id', isAuthorized, async function (
router.delete('/unsubscribe/:id', isAuthorized, async function(
req: Request,
res: Response
) {

View File

@@ -10,7 +10,7 @@ export default {
// Params:
// Param 1: req.headers-> {token}
// Returns: 400: User is unauthorized since unauthorized token was present.
isValidProjectIdAndApiKey: async function (
isValidProjectIdAndApiKey: async function(
req: Request,
res: Response,
next: NextFunction
@@ -86,13 +86,13 @@ export default {
}
},
isValidProjectId: function (projectId: $TSFixMe) {
isValidProjectId: function(projectId: $TSFixMe) {
if (!ObjectID.isValid(projectId)) {
return false;
}
return true;
},
hasAPIKey: function (req: $TSFixMe) {
hasAPIKey: function(req: $TSFixMe) {
if (req.query && req.query.apiKey) {
return true;
} else if (req.headers && (req.headers.apiKey || req.headers.apikey)) {
@@ -104,7 +104,7 @@ export default {
return false;
},
getProjectId: function (req: $TSFixMe) {
getProjectId: function(req: $TSFixMe) {
// Get Project Id, If Available
let projectId;
@@ -127,7 +127,7 @@ export default {
return projectId;
},
getStatusPageId: function (req: $TSFixMe) {
getStatusPageId: function(req: $TSFixMe) {
const statusPageId =
req.params?.statusPageId ||
req.query?.statusPageId ||
@@ -138,7 +138,7 @@ export default {
return statusPageId;
},
getStatusPageSlug: function (req: $TSFixMe) {
getStatusPageSlug: function(req: $TSFixMe) {
const statusPageSlug =
req.params?.statusPageSlug ||
req.query?.statusPageSlug ||
@@ -149,7 +149,7 @@ export default {
return statusPageSlug;
},
getStatusPageUrl: function (req: $TSFixMe) {
getStatusPageUrl: function(req: $TSFixMe) {
const statusPageUrl =
req.params?.url ||
req.query?.url ||
@@ -159,7 +159,7 @@ export default {
return statusPageUrl;
},
isValidMonitor: async function (
isValidMonitor: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -5,7 +5,7 @@ import ApplicationLogService from '../services/applicationLogService';
import { sendErrorResponse } from 'common-server/utils/response';
const _this = {
isApplicationLogValid: async function (
isApplicationLogValid: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -4,7 +4,7 @@ import { sendErrorResponse } from 'common-server/utils/response';
import ErrorService from 'common-server/utils/error';
const CLUSTER_KEY = process.env.CLUSTER_KEY;
export default {
isAuthorizedApplicationScanner: async function (
isAuthorizedApplicationScanner: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -1,7 +1,7 @@
import { sendErrorResponse } from 'common-server/utils/response';
export default {
isAuthorizedAdmin: async function (
isAuthorizedAdmin: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -4,7 +4,7 @@ import { sendErrorResponse } from 'common-server/utils/response';
import ErrorService from 'common-server/utils/error';
const CLUSTER_KEY = process.env.CLUSTER_KEY;
export default {
isAuthorizedContainerScanner: async function (
isAuthorizedContainerScanner: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -4,7 +4,7 @@ import ErrorService from 'common-server/utils/error';
import ErrorTrackerService from '../services/errorTrackerService';
const _this = {
isErrorTrackerValid: async function (
isErrorTrackerValid: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -2,7 +2,7 @@ import { sendErrorResponse } from 'common-server/utils/response';
import ErrorService from 'common-server/utils/error';
export default {
isAuthorizedLighthouse: async function (
isAuthorizedLighthouse: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -3,7 +3,11 @@ import PerformanceTrackerService from '../services/performanceTrackerService';
import { sendErrorResponse } from 'common-server/utils/response';
const _this = {
isValidAPIKey: async function (req: Request, res: Response, next: NextFunction) {
isValidAPIKey: async function(
req: Request,
res: Response,
next: NextFunction
) {
try {
const { key } = req.params;
if (!key) {

View File

@@ -18,7 +18,7 @@ const CLUSTER_KEY = process.env.CLUSTER_KEY;
global.probes = {};
export default {
isAuthorizedProbe: async function (
isAuthorizedProbe: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -11,7 +11,7 @@ export default {
// Params:
// Param 1: req.params-> {projectId}; req.user-> {id}
// Returns: 400: Project does not exist or User is not present in this project; 500: Server Error
doesUserBelongToProject: async function (
doesUserBelongToProject: async function(
req: Request,
res: Response,
next: NextFunction
@@ -104,7 +104,7 @@ export default {
// Params:
// Param 1: req.params-> {projectId}; req.user-> {id}
// Returns: 400: You are not authorized to add member to project. Only admin can add.; 500: Server Error
isUserAdmin: async function (req: Request, res: Response, next: $TSFixMe) {
isUserAdmin: async function(req: Request, res: Response, next: $TSFixMe) {
try {
const projectId = apiMiddleware.getProjectId(req);
@@ -172,7 +172,7 @@ export default {
}
},
isUserOwner: async function (req: Request, res: Response, next: $TSFixMe) {
isUserOwner: async function(req: Request, res: Response, next: $TSFixMe) {
try {
// authorize if user is master-admin
if (req.authorizationType === 'MASTER-ADMIN') {
@@ -220,7 +220,7 @@ export default {
}
},
getUserRole: async function (req: Request, res: Response, next: $TSFixMe) {
getUserRole: async function(req: Request, res: Response, next: $TSFixMe) {
try {
const UserId = req.user ? req.user.id : null;

View File

@@ -4,7 +4,7 @@ import ErrorService from 'common-server/utils/error';
const CLUSTER_KEY = process.env.CLUSTER_KEY;
export default {
isAuthorizedService: async function (
isAuthorizedService: async function(
req: Request,
res: Response,
next: NextFunction

View File

@@ -6,7 +6,7 @@ import url from 'url';
export default {
// Description: Get subprojects which user belongs to.
getSubProjects: async function (
getSubProjects: async function(
req: Request,
res: Response,
next: NextFunction
@@ -34,20 +34,20 @@ export default {
const query =
userId === 'API'
? {
$or: [
{ parentProjectId: projectId },
{ _id: projectId },
],
}
$or: [
{ parentProjectId: projectId },
{ _id: projectId },
],
}
: {
$or: [
{
parentProjectId: projectId,
'users.userId': userId,
},
{ _id: projectId, 'users.userId': userId },
],
};
$or: [
{
parentProjectId: projectId,
'users.userId': userId,
},
{ _id: projectId, 'users.userId': userId },
],
};
// Fetch user subprojects
const populate = [{ path: 'parentProjectId', select: 'name' }];
const select =

View File

@@ -17,7 +17,7 @@ const _this = {
// Param 1: req.headers-> {token}
// Returns: 400: User is unauthorized since unauthorized token was present.
getUser: async function (req: Request, res: Response, next: $TSFixMe) {
getUser: async function(req: Request, res: Response, next: $TSFixMe) {
try {
const projectId = apiMiddleware.getProjectId(req);
@@ -119,7 +119,7 @@ const _this = {
}
},
checkUser: function (req: Request, res: Response, next: $TSFixMe) {
checkUser: function(req: Request, res: Response, next: $TSFixMe) {
try {
const accessToken =
req.headers['authorization'] ||
@@ -166,7 +166,7 @@ const _this = {
throw error;
}
},
checkUserBelongToProject: function (
checkUserBelongToProject: function(
req: Request,
res: Response,
next: NextFunction
@@ -255,7 +255,7 @@ const _this = {
}
},
isUserMasterAdmin: async function (
isUserMasterAdmin: async function(
req: Request,
res: Response,
next: NextFunction
@@ -282,7 +282,7 @@ const _this = {
}
},
isScaleOrMasterAdmin: async function (
isScaleOrMasterAdmin: async function(
req: Request,
res: Response,
next: NextFunction

Some files were not shown because too many files have changed in this diff Show More