mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix api-docs
This commit is contained in:
@@ -19,24 +19,24 @@ new OneUptime.PerformanceTracker(
|
||||
options
|
||||
);
|
||||
|
||||
app.get('/', function (req: Request, res: Response) {
|
||||
app.get('/', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.send({ status: "ok" })
|
||||
})
|
||||
|
||||
app.get('/error', function (req: Request, res: Response) {
|
||||
app.get('/error', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.status(500).send({ error: "Error" })
|
||||
})
|
||||
|
||||
app.get('/outgoing-requests', async function (req: Request, res: Response) {
|
||||
app.get('/outgoing-requests', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
await axios('https://google.com');
|
||||
res.send({ status: "ok" })
|
||||
})
|
||||
|
||||
app.get('/user/:id', async function (req: Request, res: Response) {
|
||||
app.get('/user/:id', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.send({ user: req.params.id })
|
||||
})
|
||||
|
||||
app.post('/post', async function (req: Request, res: Response) {
|
||||
app.post('/post', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.send({ "status": "this is a post request" })
|
||||
})
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ app.use(compression());
|
||||
|
||||
app.get(
|
||||
['/env.js', '/accounts/env.js'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
const env = {
|
||||
REACT_APP_IS_SAAS_SERVICE: process.env.IS_SAAS_SERVICE,
|
||||
REACT_APP_DISABLE_SIGNUP: process.env.DISABLE_SIGNUP,
|
||||
@@ -70,7 +70,7 @@ app.use(
|
||||
|
||||
app.use('/accounts', express.static(path.join(__dirname, 'build')));
|
||||
|
||||
app.get('/*', function (req: Request, res: Response) {
|
||||
app.get('/*', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'build', 'index.html'));
|
||||
});
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -5,7 +5,7 @@ import express, { Request, Response } from 'common-server/utils/express';
|
||||
import path from 'path';
|
||||
const app = express.getExpressApp();
|
||||
|
||||
app.get(['/env.js', '/admin/env.js'], function (req: Request, res: Response) {
|
||||
app.get(['/env.js', '/admin/env.js'], (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const env = {
|
||||
REACT_APP_IS_SAAS_SERVICE: process.env.IS_SAAS_SERVICE,
|
||||
REACT_APP_LICENSE_URL: process.env.LICENSE_URL,
|
||||
@@ -18,7 +18,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'], (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -36,7 +36,7 @@ app.use(
|
||||
express.static(path.join(__dirname, 'build/static/js'))
|
||||
);
|
||||
|
||||
app.get('/*', function (req: Request, res: Response) {
|
||||
app.get('/*', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'build', 'index.html'));
|
||||
});
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -66,7 +66,7 @@ app.use(
|
||||
);
|
||||
|
||||
// index page
|
||||
app.get(['/', '/docs'], function (req: Request, res: Response) {
|
||||
app.get(['/', '/docs'], (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.render('pages/index');
|
||||
});
|
||||
|
||||
|
||||
5467
api-docs/package-lock.json
generated
5467
api-docs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,9 @@
|
||||
"homepage": "https://github.com/oneuptime/api-docs#readme",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"common-server": "file:../common-server",
|
||||
"chai": "^4.3.4",
|
||||
"chai-http": "^4.3.0",
|
||||
"common-server": "file:../common-server",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"ejs": "^3.1.6",
|
||||
@@ -36,6 +36,7 @@
|
||||
},
|
||||
"resolutions": {},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.22",
|
||||
"depcheck": "^1.4.3",
|
||||
"npm-force-resolutions": "0.0.10",
|
||||
"ts-node-dev": "^1.1.8"
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -20,7 +20,7 @@ app.set('port', process.env['PORT'] || 3005);
|
||||
|
||||
app.get(
|
||||
['/application/status', '/status'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -36,7 +36,7 @@ app.get(
|
||||
|
||||
app.get(
|
||||
['/application/version', '/version'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({
|
||||
applicationScannerVersion: process.env.npm_package_version,
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -22,7 +22,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
@@ -102,7 +102,7 @@ router.get(
|
||||
'/:projectId/incident/:incidentSlug',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const incidentSlug = req.params.incidentSlug;
|
||||
// const projectId = req.params.projectId;
|
||||
@@ -153,7 +153,7 @@ router.get(
|
||||
// Mark alert as viewed. This is for Email.
|
||||
router.get(
|
||||
'/:projectId/:alertId/viewed',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const alertId = req.params.alertId;
|
||||
const projectId = req.params.projectId;
|
||||
@@ -184,7 +184,7 @@ router.delete(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const componentId = req.params.componentId;
|
||||
@@ -138,7 +138,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { applicationLogId, componentId } = req.params;
|
||||
try {
|
||||
const applicationLog = await ApplicationLogService.deleteBy(
|
||||
@@ -202,7 +202,7 @@ router.post(
|
||||
'/:projectId/:componentId/:applicationLogId/logs',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { skip, limit, startDate, endDate, type, filter } = req.body;
|
||||
const applicationLogId = req.params.applicationLogId;
|
||||
@@ -262,7 +262,7 @@ router.post(
|
||||
'/:projectId/:componentId/:applicationLogId/stats',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const applicationLogId = req.params.applicationLogId;
|
||||
|
||||
@@ -313,7 +313,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const applicationLogId = req.params.applicationLogId;
|
||||
|
||||
const currentApplicationCount = await ApplicationLogService.countBy({
|
||||
@@ -350,7 +350,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { applicationLogId, componentId } = req.params;
|
||||
|
||||
const data = req.body;
|
||||
@@ -448,7 +448,7 @@ router.post(
|
||||
'/:projectId/:componentId/:applicationLogId/search',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { applicationLogId } = req.params;
|
||||
const startTime = new Date();
|
||||
const { duration, filter, range } = req.body;
|
||||
|
||||
@@ -24,7 +24,7 @@ import ErrorService from 'common-server/utils/error';
|
||||
router.get(
|
||||
'/applicationSecurities',
|
||||
isAuthorizedApplicationScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const response =
|
||||
await ApplicationSecurityService.getSecuritiesToScan();
|
||||
@@ -84,7 +84,7 @@ router.post(
|
||||
router.post(
|
||||
'/log',
|
||||
isAuthorizedApplicationScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const security = req.body;
|
||||
const securityLog = await ApplicationSecurityLogService.create({
|
||||
@@ -276,7 +276,7 @@ router.post(
|
||||
router.post(
|
||||
'/time',
|
||||
isAuthorizedApplicationScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const security = req.body;
|
||||
const updatedTime = await ApplicationSecurityService.updateScanTime(
|
||||
|
||||
@@ -15,7 +15,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
const skip = req.query['skip'];
|
||||
@@ -50,7 +50,7 @@ router.post(
|
||||
'/search',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const filter = req.body.filter;
|
||||
const skip = req.query['skip'];
|
||||
@@ -75,7 +75,7 @@ router.delete(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { skip, limit } = req.query;
|
||||
@@ -248,7 +248,7 @@ router.delete(
|
||||
'/:projectId/:automatedSlug',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, automatedSlug } = req.params;
|
||||
const query = {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default ({
|
||||
friendlyResourceName,
|
||||
service,
|
||||
}: $TSFixMe) => {
|
||||
const getItemMiddleware = async function (req: Request, res: Response) {
|
||||
const getItemMiddleware = async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
let item = null;
|
||||
|
||||
@@ -59,7 +59,7 @@ export default ({
|
||||
}
|
||||
};
|
||||
|
||||
const listItemMiddleware = async function (req: Request, res: Response) {
|
||||
const listItemMiddleware = async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -154,7 +154,7 @@ export default ({
|
||||
}
|
||||
};
|
||||
|
||||
const deleteItemMiddleware = async function (req: Request, res: Response) {
|
||||
const deleteItemMiddleware = async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (!req.apiProps.authorizedByRole.includes(req.role)) {
|
||||
return sendErrorResponse(req, res, {
|
||||
|
||||
@@ -15,7 +15,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
const skip = req.query['skip'];
|
||||
@@ -99,7 +99,7 @@ router.post(
|
||||
'/search',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const filter = req.body.filter;
|
||||
const skip = req.query['skip'];
|
||||
@@ -124,7 +124,7 @@ router.delete(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ router.put(
|
||||
'/:projectId/:callRoutingId/:audioFieldName',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { audioFieldName, callRoutingId } = req.params;
|
||||
const upload = multer({
|
||||
@@ -260,7 +260,7 @@ router.delete(
|
||||
'/:projectId/:callRoutingId',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, callRoutingId } = req.params;
|
||||
|
||||
@@ -289,7 +289,7 @@ router.delete(
|
||||
'/:projectId/:callRoutingId/removeAudio',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { callRoutingId, backup } = req.body;
|
||||
if (!callRoutingId) {
|
||||
|
||||
@@ -105,7 +105,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const { componentId } = req.params;
|
||||
@@ -213,7 +213,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const type = req.query.type;
|
||||
|
||||
@@ -256,7 +256,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const componentId = req.params.componentId;
|
||||
const type = req.query.type;
|
||||
@@ -293,7 +293,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { startDate, endDate } = req.body;
|
||||
const componentId = req.params.componentId;
|
||||
@@ -393,7 +393,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const componentId = req.params.componentId;
|
||||
const type = req.query.type;
|
||||
@@ -500,15 +500,14 @@ router.get(
|
||||
const newElement = {
|
||||
_id: elem._id,
|
||||
name: elem.name,
|
||||
type: `${
|
||||
elem.type === 'server-monitor'
|
||||
type: `${elem.type === 'server-monitor'
|
||||
? 'server monitor'
|
||||
: elem.type === 'url'
|
||||
? 'website monitor'
|
||||
: elem.type === 'ip'
|
||||
? 'IP monitor'
|
||||
: elem.type + ` monitor`
|
||||
}`,
|
||||
? 'website monitor'
|
||||
: elem.type === 'ip'
|
||||
? 'IP monitor'
|
||||
: elem.type + ` monitor`
|
||||
}`,
|
||||
createdAt: elem.createdAt,
|
||||
icon: 'monitor',
|
||||
slug: elem.slug,
|
||||
@@ -703,7 +702,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subProjectIds = req.user.subProjects
|
||||
? req.user.subProjects.map((project: $TSFixMe) => project._id)
|
||||
@@ -767,7 +766,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { componentId, projectId } = req.params;
|
||||
try {
|
||||
await ComponentService.deleteBy(
|
||||
|
||||
@@ -57,7 +57,7 @@ router.post(
|
||||
router.post(
|
||||
'/failed',
|
||||
isAuthorizedContainerScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const security = req.body;
|
||||
const containerSecurity =
|
||||
@@ -76,7 +76,7 @@ router.post(
|
||||
router.post(
|
||||
'/log',
|
||||
isAuthorizedContainerScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const security = req.body;
|
||||
const securityLog = await ContainerSecurityLogService.create({
|
||||
@@ -167,7 +167,7 @@ router.post(
|
||||
router.post(
|
||||
'/time',
|
||||
isAuthorizedContainerScanner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const security = req.body;
|
||||
const updatedTime = await ContainerSecurityService.updateScanTime({
|
||||
|
||||
@@ -17,7 +17,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { fieldName, fieldType, uniqueField } = req.body;
|
||||
@@ -70,7 +70,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { limit, skip } = req.query;
|
||||
@@ -161,7 +161,7 @@ router.delete(
|
||||
'/:projectId/:customFieldId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, customFieldId } = req.params;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
const skip = req.query['skip'];
|
||||
@@ -177,7 +177,7 @@ router.post(
|
||||
'/search',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const filter = req.body.filter;
|
||||
const skip = req.query['skip'];
|
||||
@@ -202,7 +202,7 @@ router.delete(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ router.post(
|
||||
'/test',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
let data = req.body;
|
||||
if (data.smtpToUse === 'customSmtp') {
|
||||
@@ -92,7 +92,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
@@ -159,7 +159,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const select =
|
||||
|
||||
@@ -21,7 +21,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
@@ -60,7 +60,7 @@ router.get(
|
||||
'/:projectId/:templateId/reset',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const templateId = req.params.templateId;
|
||||
@@ -79,7 +79,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const templates = await EmailTemplateService.getTemplates(
|
||||
@@ -96,7 +96,7 @@ router.get(
|
||||
'/:projectId/emailTemplate/:emailTemplateId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const emailTemplateId = req.params.emailTemplateId;
|
||||
const select = 'projectId subject body emailType allowedVariables';
|
||||
@@ -116,7 +116,7 @@ router.put(
|
||||
'/:projectId/emailTemplate/:emailTemplateId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const Id = req.params.emailTemplateId;
|
||||
@@ -136,7 +136,7 @@ router.put(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = [];
|
||||
const { projectId } = req.params;
|
||||
@@ -199,7 +199,7 @@ router.delete(
|
||||
'/:projectId/emailTemplate/:emailTemplateId',
|
||||
getUser,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const emailTemplateId = req.params.emailTemplateId;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const componentId = req.params.componentId;
|
||||
@@ -141,7 +141,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { errorTrackerId, componentId } = req.params;
|
||||
try {
|
||||
const errorTracker = await ErrorTrackerService.deleteBy(
|
||||
@@ -172,7 +172,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const errorTrackerId = req.params.errorTrackerId;
|
||||
const select =
|
||||
'componentId name slug key showQuickStart resourceCategory createdById createdAt';
|
||||
@@ -216,7 +216,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { errorTrackerId, componentId } = req.params;
|
||||
|
||||
const data = req.body;
|
||||
@@ -395,7 +395,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/issues',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { skip, limit, startDate, endDate, filters } = req.body;
|
||||
const errorTrackerId = req.params.errorTrackerId;
|
||||
@@ -451,7 +451,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/error-events/:errorEventId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const errorEventId = req.params.errorEventId;
|
||||
if (!errorEventId) {
|
||||
@@ -502,7 +502,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/issues/:issueId/details',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const issueId = req.params.issueId;
|
||||
if (!issueId) {
|
||||
@@ -545,7 +545,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/issues/action',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { issueId, action } = req.body;
|
||||
if (!issueId) {
|
||||
@@ -731,7 +731,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/error-events',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { skip, limit, startDate, endDate, fingerprintHash } =
|
||||
req.body;
|
||||
@@ -789,7 +789,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/members/:issueId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const componentId = req.params.componentId;
|
||||
if (!componentId) {
|
||||
@@ -867,7 +867,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/assign/:issueId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { teamMemberId } = req.body;
|
||||
if (!teamMemberId) {
|
||||
@@ -1015,7 +1015,7 @@ router.post(
|
||||
'/:projectId/:componentId/:errorTrackerId/unassign/:issueId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { teamMemberId } = req.body;
|
||||
if (!teamMemberId) {
|
||||
@@ -1148,7 +1148,7 @@ router.delete(
|
||||
'/:projectId/:componentId/:errorTrackerId/issue/:issueId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const componentId = req.params.componentId;
|
||||
if (!componentId) {
|
||||
|
||||
@@ -15,7 +15,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (!req.body.feedback && !req.body.page) {
|
||||
return sendErrorResponse(req, res, {
|
||||
|
||||
@@ -11,7 +11,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const file = await FileService.findOneBy({
|
||||
filename: req.params.filename,
|
||||
|
||||
@@ -19,7 +19,7 @@ router.post(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
let configs;
|
||||
|
||||
@@ -111,7 +111,7 @@ router.post(
|
||||
'/configs',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const names = req.body;
|
||||
|
||||
@@ -143,7 +143,7 @@ router.get(
|
||||
'/:name',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const selectConfig = 'name value createdAt';
|
||||
const { name } = req.params;
|
||||
|
||||
@@ -37,7 +37,7 @@ import ErrorService from 'common-server/utils/error';
|
||||
router.post(
|
||||
'/data-ingestor/create-incident',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -55,7 +55,7 @@ router.post(
|
||||
router.post(
|
||||
'/data-ingestor/acknowledge-incident',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { incidentId, name, probeId } = req.body;
|
||||
|
||||
@@ -77,7 +77,7 @@ router.post(
|
||||
router.post(
|
||||
'/data-ingestor/resolve-incident',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { incidentId, name, probeId } = req.body;
|
||||
|
||||
@@ -99,7 +99,7 @@ router.post(
|
||||
router.post(
|
||||
'/data-ingestor/update-incident',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { data, query } = req.body;
|
||||
const incident = await IncidentService.updateOneBy(query, data);
|
||||
@@ -121,7 +121,7 @@ router.post(
|
||||
'/:projectId/create-incident',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const incidentType = req.body.incidentType;
|
||||
@@ -241,7 +241,7 @@ router.post(
|
||||
'/:projectId/monitor/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { monitorId } = req.params;
|
||||
// include date range
|
||||
try {
|
||||
@@ -330,7 +330,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { componentId, projectId } = req.params;
|
||||
const incidents = await IncidentService.getComponentIncidents(
|
||||
@@ -353,7 +353,7 @@ router.get(
|
||||
'/:projectId/incidents/:componentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, componentId } = req.params;
|
||||
|
||||
@@ -438,7 +438,7 @@ router.get(
|
||||
'/:projectId/incident/:incidentSlug',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
// Call the IncidentService.
|
||||
|
||||
try {
|
||||
@@ -484,7 +484,7 @@ router.get(
|
||||
'/:projectId/timeline/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { incidentId } = req.params;
|
||||
|
||||
@@ -519,7 +519,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subProjectIds = req.user.subProjects
|
||||
? req.user.subProjects.map((project: $TSFixMe) => project._id)
|
||||
@@ -545,7 +545,7 @@ router.post(
|
||||
'/:projectId/acknowledge/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user
|
||||
? req.user.id === 'API'
|
||||
@@ -711,7 +711,7 @@ router.post(
|
||||
'/:projectId/resolve/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user
|
||||
? req.user.id === 'API'
|
||||
@@ -873,7 +873,7 @@ router.post(
|
||||
'/:projectId/close/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
const { incidentId } = req.params;
|
||||
@@ -892,7 +892,7 @@ router.put(
|
||||
'/:projectId/incident/:incidentId/details',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const projectId = req.params.projectId;
|
||||
const incidentId = req.params.incidentId;
|
||||
const { title, description, incidentPriority } = req.body;
|
||||
@@ -927,7 +927,7 @@ router.post(
|
||||
'/:projectId/incident/:incidentId/message',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const incidentId = req.params.incidentId;
|
||||
@@ -1136,9 +1136,8 @@ 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 },
|
||||
@@ -1307,7 +1306,7 @@ router.get(
|
||||
'/:projectId/:incidentSlug/statuspages',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { incidentSlug } = req.params;
|
||||
|
||||
@@ -1338,7 +1337,7 @@ router.delete(
|
||||
'/:projectId/incident/:incidentId/message/:incidentMessageId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { incidentId, incidentMessageId, projectId } = req.params;
|
||||
const populateIncidentMessage = [
|
||||
@@ -1521,7 +1520,7 @@ router.get(
|
||||
'/:projectId/incident/:incidentSlug/message',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
let type = 'investigation';
|
||||
if (req.query.type && req.query.type === 'internal') {
|
||||
type = 'internal';
|
||||
@@ -1722,7 +1721,7 @@ router.delete(
|
||||
router.put(
|
||||
'/:projectId/:incidentId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, incidentId } = req.params;
|
||||
const { hideIncident } = req.body;
|
||||
@@ -1753,7 +1752,7 @@ router.get(
|
||||
'/:projectId/resolve/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
|
||||
@@ -1798,7 +1797,7 @@ router.get(
|
||||
'/:projectId/acknowledge/:incidentId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { limit, skip } = req.query;
|
||||
@@ -53,7 +53,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { name, alertTime, duration } = req.body;
|
||||
@@ -178,7 +178,7 @@ router.delete(
|
||||
'/:projectId/:incidentSlaId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, incidentSlaId } = req.params;
|
||||
|
||||
@@ -198,7 +198,7 @@ router.get(
|
||||
'/:projectId/defaultCommunicationSla',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { incidentState, incidentNote, name } = req.body;
|
||||
@@ -65,7 +65,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { skip, limit } = req.query;
|
||||
|
||||
@@ -14,7 +14,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { projectId } = req.params;
|
||||
const { skip = 0, limit = 10 } = req.query;
|
||||
if (!projectId) {
|
||||
@@ -46,7 +46,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { projectId } = req.params;
|
||||
const { name, color } = req.body;
|
||||
if (!projectId) {
|
||||
@@ -85,7 +85,7 @@ router.put(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { projectId } = req.params;
|
||||
const { _id, name, color } = req.body;
|
||||
|
||||
@@ -134,7 +134,7 @@ router.delete(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { projectId } = req.params;
|
||||
const { _id } = req.body;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import IncidentPrioritiesService from '../services/incidentPrioritiesService';
|
||||
|
||||
import { variables } from '../config/incidentDefaultSettings';
|
||||
|
||||
router.get('/variables', async function (req: Request, res: Response) {
|
||||
router.get('/variables', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
return sendItemResponse(req, res, variables);
|
||||
} catch (error) {
|
||||
@@ -57,7 +57,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { skip, limit } = req.query;
|
||||
@@ -97,7 +97,7 @@ router.put(
|
||||
'/:projectId/:templateId/setDefault',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { projectId, templateId } = req.params;
|
||||
if (!projectId)
|
||||
return sendErrorResponse(req, res, {
|
||||
@@ -232,7 +232,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
// description is optional
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
|
||||
import { isValidMonitor } from '../middlewares/api';
|
||||
|
||||
const incomingHttpRequest = async function (req: Request, res: Response) {
|
||||
const incomingHttpRequest = async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitor = req.monitor;
|
||||
const body = req.body;
|
||||
|
||||
@@ -16,7 +16,7 @@ router.get(
|
||||
'/:projectId/all-incoming-request',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { limit, skip } = req.query;
|
||||
@@ -57,7 +57,7 @@ router.post(
|
||||
'/:projectId/create-request-url',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -114,7 +114,7 @@ router.put(
|
||||
'/:projectId/update/:requestId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, requestId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -171,7 +171,7 @@ router.delete(
|
||||
'/:projectId/remove/:requestId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, requestId } = req.params;
|
||||
|
||||
@@ -189,7 +189,7 @@ router.delete(
|
||||
// process incoming http request from post request
|
||||
router.post(
|
||||
'/:projectId/request/:requestId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// request object for use in variables
|
||||
const request = {
|
||||
@@ -213,7 +213,7 @@ router.post(
|
||||
// process incoming http request from get request
|
||||
router.get(
|
||||
'/:projectId/request/:requestId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// request object for use in variables
|
||||
// request body won't be available for a get request
|
||||
@@ -238,7 +238,7 @@ router.post(
|
||||
'/:projectId/toggle/:requestId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, requestId } = req.params;
|
||||
const data = req.body;
|
||||
|
||||
@@ -9,7 +9,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
let startingAfter = req.query.startingAfter;
|
||||
|
||||
@@ -7,7 +7,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const body = req.body;
|
||||
const data = {};
|
||||
|
||||
@@ -26,7 +26,7 @@ import ErrorService from 'common-server/utils/error';
|
||||
router.get(
|
||||
'/monitors',
|
||||
isAuthorizedLighthouse,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitors =
|
||||
await MonitorService.getUrlMonitorsNotScannedByLightHouseInPastOneDay();
|
||||
@@ -147,9 +147,9 @@ router.post(
|
||||
desc.description.split(/\[Learn more\]/i);
|
||||
const url = splitDescription[1]
|
||||
? splitDescription[1].replace(
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
: '';
|
||||
desc.description = splitDescription[0];
|
||||
desc.url = url;
|
||||
@@ -165,9 +165,9 @@ router.post(
|
||||
desc.description.split(/\[Learn more\]/i);
|
||||
const url = splitDescription[1]
|
||||
? splitDescription[1].replace(
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
: '';
|
||||
desc.description = splitDescription[0];
|
||||
desc.url = url;
|
||||
@@ -184,9 +184,9 @@ router.post(
|
||||
desc.description.split(/\[Learn more\]/i);
|
||||
const url = splitDescription[1]
|
||||
? splitDescription[1].replace(
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
: '';
|
||||
desc.description = splitDescription[0];
|
||||
desc.url = url;
|
||||
@@ -201,9 +201,9 @@ router.post(
|
||||
desc.description.split(/\[Learn more\]/i);
|
||||
const url = splitDescription[1]
|
||||
? splitDescription[1].replace(
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
: '';
|
||||
desc.description = splitDescription[0];
|
||||
desc.url = url;
|
||||
@@ -218,9 +218,9 @@ router.post(
|
||||
desc.description.split(/\[Learn more\]/i);
|
||||
const url = splitDescription[1]
|
||||
? splitDescription[1].replace(
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
/^\(|\)|\.$/gi,
|
||||
''
|
||||
)
|
||||
: '';
|
||||
desc.description = splitDescription[0];
|
||||
desc.url = url;
|
||||
|
||||
@@ -14,7 +14,7 @@ router.get(
|
||||
'/:userId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
let { skip, limit } = req.query;
|
||||
|
||||
@@ -282,7 +282,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
'/:projectId/identityFile',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -314,7 +314,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
'/:projectId/configurationFile',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -349,7 +349,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const { monitorId } = req.params;
|
||||
@@ -516,7 +516,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const type = req.query.type;
|
||||
|
||||
@@ -561,7 +561,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitorId = req.params.monitorId;
|
||||
const type = req.query.type;
|
||||
@@ -601,7 +601,7 @@ router.post(
|
||||
'/:projectId/monitorLogs/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const {
|
||||
skip,
|
||||
@@ -656,7 +656,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { monitorId, projectId } = req.params;
|
||||
try {
|
||||
const monitor = await MonitorService.deleteBy(
|
||||
@@ -687,7 +687,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitorId = req.params.monitorId || req.body._id;
|
||||
const data = req.body;
|
||||
@@ -704,34 +704,34 @@ router.post(
|
||||
successReasons: upSuccessReasons,
|
||||
failedReasons: upFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.down,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.down,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -779,7 +779,7 @@ router.post(
|
||||
'/:projectId/monitorLog/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { startDate, endDate } = req.body;
|
||||
const monitorId = req.params.monitorId;
|
||||
@@ -801,7 +801,7 @@ router.post(
|
||||
'/:projectId/monitorStatuses/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { startDate, endDate } = req.body;
|
||||
const monitorId = req.params.monitorId;
|
||||
@@ -823,7 +823,7 @@ router.get(
|
||||
'/:projectId/lighthouseLog/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { skip, limit, url } = req.query;
|
||||
const monitorId = req.params.monitorId;
|
||||
@@ -847,7 +847,7 @@ router.get(
|
||||
'/:projectId/lighthouseIssue/:issueId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const selectLighthouseLogs =
|
||||
'monitorId probeId data url performance accessibility bestPractices seo pwa createdAt scanning';
|
||||
@@ -875,7 +875,7 @@ router.post(
|
||||
'/:projectId/inbound/:deviceId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
return await _updateDeviceMonitorPingTime(req, res);
|
||||
}
|
||||
);
|
||||
@@ -884,7 +884,7 @@ router.get(
|
||||
'/:projectId/inbound/:deviceId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
return await _updateDeviceMonitorPingTime(req, res);
|
||||
}
|
||||
);
|
||||
@@ -949,7 +949,7 @@ router.post(
|
||||
'/:projectId/siteUrl/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { siteUrl } = req.body;
|
||||
const monitor = await MonitorService.addSiteUrl(
|
||||
@@ -969,7 +969,7 @@ router.delete(
|
||||
'/:projectId/siteUrl/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { siteUrl } = req.body;
|
||||
const monitor = await MonitorService.removeSiteUrl(
|
||||
@@ -989,7 +989,7 @@ router.get(
|
||||
'/:projectId/monitorSlaBreaches',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const select =
|
||||
@@ -1009,7 +1009,7 @@ router.post(
|
||||
'/:projectId/closeSla/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, monitorId } = req.params;
|
||||
|
||||
@@ -1031,7 +1031,7 @@ router.post(
|
||||
'/:projectId/disableMonitor/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitorId } = req.params;
|
||||
const select = 'disabled';
|
||||
@@ -1066,7 +1066,7 @@ router.post(
|
||||
'/:projectId/changeComponent/:monitorId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, monitorId } = req.params;
|
||||
const { newComponentId } = req.body;
|
||||
@@ -1085,7 +1085,7 @@ router.post(
|
||||
// api to calculate time for monitorInfo (status page)
|
||||
router.post(
|
||||
'/:monitorId/calculate-time',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitorId } = req.params;
|
||||
const { statuses, start, range } = req.body;
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
sendItemResponse,
|
||||
} from 'common-server/utils/response';
|
||||
|
||||
router.get('/', getUser, function (req: Request, res: Response) {
|
||||
router.get('/', getUser, (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const criteria = MonitorCriteriaService.getCriteria();
|
||||
return sendItemResponse(req, res, criteria);
|
||||
|
||||
@@ -17,7 +17,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { fieldName, fieldType, uniqueField } = req.body;
|
||||
@@ -73,7 +73,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { limit, skip } = req.query;
|
||||
@@ -163,7 +163,7 @@ router.delete(
|
||||
'/:projectId/:customFieldId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, customFieldId } = req.params;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { limit, skip } = req.query;
|
||||
@@ -51,7 +51,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { name, frequency, monitorUptime } = req.body;
|
||||
@@ -209,7 +209,7 @@ router.delete(
|
||||
'/:projectId/:monitorSlaId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, monitorSlaId } = req.params;
|
||||
|
||||
@@ -228,7 +228,7 @@ router.get(
|
||||
'/:projectId/defaultMonitorSla',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const selectMonSla =
|
||||
|
||||
@@ -63,7 +63,7 @@ router.put(
|
||||
'/:projectId/read',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// const notificationId = req.params.notificationId;
|
||||
|
||||
@@ -92,7 +92,7 @@ router.put(
|
||||
'/:projectId/:notificationId/closed',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const notificationId = req.params.notificationId;
|
||||
|
||||
@@ -120,7 +120,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subProjectIds = req.user.subProjects
|
||||
? req.user.subProjects.map((project: $TSFixMe) => project._id)
|
||||
@@ -179,7 +179,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ router.post(
|
||||
'/:projectId/:componentId/create',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const { componentId } = req.params;
|
||||
@@ -109,7 +109,7 @@ router.get(
|
||||
'/:projectId/tracker/:performanceTrackerId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { performanceTrackerId } = req.params;
|
||||
const { slug } = req.query;
|
||||
try {
|
||||
@@ -157,7 +157,7 @@ router.delete(
|
||||
'/:projectId/tracker/:performanceTrackerId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { performanceTrackerId } = req.params;
|
||||
try {
|
||||
const performanceTracker = await PerformanceTrackerService.deleteBy(
|
||||
@@ -187,7 +187,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { performanceTrackerId } = req.params;
|
||||
|
||||
const select = 'componentId name slug key showQuickStart createdById';
|
||||
@@ -234,7 +234,7 @@ router.put(
|
||||
'/:projectId/remove-quickstart/:performanceTrackerId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { performanceTrackerId } = req.params;
|
||||
|
||||
const currentPerformanceTracker =
|
||||
@@ -272,7 +272,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { performanceTrackerId, componentId } = req.params;
|
||||
const data = req.body;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import { isValidAPIKey } from '../middlewares/performanceTracker';
|
||||
router.post(
|
||||
'/:appId/key/:key',
|
||||
isValidAPIKey,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { appId } = req.params;
|
||||
const { incoming, outgoing, sentAt } = req.body;
|
||||
@@ -48,7 +48,7 @@ router.post(
|
||||
router.get(
|
||||
'/:appId/key/:key/time',
|
||||
isValidAPIKey,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { appId } = req.params;
|
||||
let { startDate, endDate } = req.query;
|
||||
@@ -183,7 +183,7 @@ router.get(
|
||||
router.get(
|
||||
'/:appId/key/:key/error',
|
||||
isValidAPIKey,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { appId } = req.params;
|
||||
let { startDate, endDate } = req.query;
|
||||
@@ -252,7 +252,7 @@ router.get(
|
||||
router.get(
|
||||
'/:appId/key/:key',
|
||||
isValidAPIKey,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { appId } = req.params;
|
||||
const { type, skip, limit } = req.query;
|
||||
|
||||
@@ -22,7 +22,7 @@ router.post(
|
||||
'/',
|
||||
getUser,
|
||||
isAuthorizedAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const probe = await ProbeService.create(data);
|
||||
@@ -37,7 +37,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isAuthorizedAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 0;
|
||||
@@ -63,7 +63,7 @@ router.put(
|
||||
'/:id',
|
||||
getUser,
|
||||
isAuthorizedAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const probe = await ProbeService.updateOneBy(
|
||||
@@ -81,7 +81,7 @@ router.delete(
|
||||
'/:id',
|
||||
getUser,
|
||||
isAuthorizedAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const probe = await ProbeService.deleteBy({ _id: req.params.id });
|
||||
return sendItemResponse(req, res, probe);
|
||||
@@ -100,7 +100,7 @@ router.delete(
|
||||
router.put(
|
||||
'/update/image',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -141,7 +141,7 @@ router.put(
|
||||
router.get(
|
||||
'/monitors',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitors = await MonitorService.getProbeMonitors(
|
||||
req.probe.id,
|
||||
@@ -199,65 +199,65 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
@@ -304,45 +304,45 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
reason = upSuccessReasons;
|
||||
@@ -381,17 +381,17 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -399,19 +399,19 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -419,17 +419,17 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
@@ -474,59 +474,59 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -618,19 +618,19 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -638,19 +638,19 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -658,24 +658,24 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -740,9 +740,9 @@ router.post(
|
||||
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');
|
||||
@@ -750,9 +750,9 @@ router.post(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ router.post(
|
||||
router.post(
|
||||
'/setTime/:monitorId',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -837,7 +837,7 @@ router.post(
|
||||
router.post(
|
||||
'/getTime/:monitorId',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
|
||||
@@ -28,7 +28,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.name = data.projectName;
|
||||
@@ -211,7 +211,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
// find user subprojects and parent projects
|
||||
@@ -335,7 +335,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const projectName = req.body.projectName;
|
||||
@@ -372,7 +372,7 @@ router.put(
|
||||
'/:projectId/updateBalance',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
if (!projectId) {
|
||||
@@ -401,7 +401,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
@@ -497,7 +497,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
@@ -559,7 +559,7 @@ router.delete(
|
||||
router.delete(
|
||||
'/:projectId/initScript/deleteProject',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
if (!projectId) {
|
||||
@@ -606,7 +606,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const projectName = req.body.projectName;
|
||||
@@ -679,7 +679,7 @@ router.put(
|
||||
'/:projectId/admin/changePlan',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const projectName = req.body.projectName;
|
||||
@@ -773,7 +773,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const projectName = req.body.projectName;
|
||||
@@ -834,7 +834,7 @@ router.delete(
|
||||
'/:projectId/user/:userId/exitProject',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
// Call the ProjectService
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
@@ -918,7 +918,7 @@ router.delete(
|
||||
'/:projectId/:subProjectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const parentProjectId = req.params.projectId;
|
||||
const subProjectId = req.params.subProjectId;
|
||||
@@ -1050,7 +1050,7 @@ router.get(
|
||||
router.get(
|
||||
'/project-slug/:slug',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { slug } = req.params;
|
||||
const populate = [{ path: 'parentProjectId', select: 'name' }];
|
||||
@@ -1073,7 +1073,7 @@ router.put(
|
||||
'/:projectId/blockProject',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const project = await ProjectService.updateOneBy(
|
||||
@@ -1091,7 +1091,7 @@ router.put(
|
||||
'/:projectId/renewAlertLimit',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
let limit = req.body.alertLimit;
|
||||
@@ -1125,7 +1125,7 @@ router.put(
|
||||
'/:projectId/unblockProject',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const project = await ProjectService.updateOneBy(
|
||||
@@ -1143,7 +1143,7 @@ router.put(
|
||||
'/:projectId/restoreProject',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const project = await ProjectService.restoreBy({
|
||||
@@ -1297,7 +1297,7 @@ router.put(
|
||||
'/:projectId/advancedOptions/email',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -1354,7 +1354,7 @@ router.put(
|
||||
'/:projectId/advancedOptions/sms',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -1402,7 +1402,7 @@ router.put(
|
||||
'/:projectId/advancedOptions/webhook',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const data = req.body;
|
||||
|
||||
@@ -78,7 +78,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const resourceCategoryId = req.params.resourceCategoryId;
|
||||
const projectId = req.params.projectId;
|
||||
@@ -134,7 +134,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const resourceCategoryId = req.params.resourceCategoryId;
|
||||
const projectId = req.params.projectId;
|
||||
@@ -185,7 +185,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const { limit, skip } = req.query;
|
||||
|
||||
@@ -43,7 +43,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const populate = [
|
||||
@@ -96,7 +96,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subProjectIds = req.user.subProjects
|
||||
? req.user.subProjects.map((project: $TSFixMe) => project._id)
|
||||
@@ -160,7 +160,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, scheduleId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -180,7 +180,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const scheduleId = req.params.scheduleId;
|
||||
|
||||
@@ -268,7 +268,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
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -280,7 +280,7 @@ router.post(
|
||||
'Number of Email Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -292,7 +292,7 @@ router.post(
|
||||
'Number of Call Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -304,7 +304,7 @@ router.post(
|
||||
'Number of SMS Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -316,7 +316,7 @@ router.post(
|
||||
'Number of Push notification Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -328,7 +328,7 @@ router.post(
|
||||
'Please specify Rotation Interval ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -344,7 +344,7 @@ router.post(
|
||||
'Please specify "First rotation happens on" ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -361,7 +361,7 @@ router.post(
|
||||
'You must specify timezone for "First rotation happens on" ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -373,7 +373,7 @@ router.post(
|
||||
'You need more than one team for rotations ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -455,7 +455,7 @@ router.post(
|
||||
'Team Members are required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -473,7 +473,7 @@ router.post(
|
||||
'Please add team members or group to your on-call schedule ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -491,7 +491,7 @@ router.post(
|
||||
'Please remove duplicate team members from your on-call schedule' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const data = req.body;
|
||||
@@ -224,7 +224,7 @@ router.put(
|
||||
'/:projectId/resolve/:eventId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = {};
|
||||
|
||||
@@ -428,7 +428,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const currentDate = moment();
|
||||
// this contains both projectIds and subProjectIds
|
||||
@@ -522,7 +522,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
|
||||
@@ -579,7 +579,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// this contains both projectIds and subProjectIds
|
||||
|
||||
@@ -601,7 +601,7 @@ router.get(
|
||||
router.get(
|
||||
'/:projectId/:monitorId/statusPage',
|
||||
checkUserBelongToProject,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const monitorId = req.params.monitorId;
|
||||
@@ -823,7 +823,7 @@ router.put(
|
||||
'/:projectId/:eventId/notes/:noteId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { eventId, noteId, projectId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -908,7 +908,7 @@ router.delete(
|
||||
'/:projectId/:eventId/notes/:noteId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { eventId, noteId, projectId } = req.params;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ router.get(
|
||||
router.post(
|
||||
'/ping/:monitorId',
|
||||
isAuthorizedService,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitor, resp } = req.body;
|
||||
|
||||
@@ -56,8 +56,8 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor && monitor.criteria && monitor.criteria.up
|
||||
? await ProbeService.scriptConditions(resp, monitor.criteria.up)
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
? await ProbeService.scriptConditions(resp, monitor.criteria.up)
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
|
||||
// determine if monitor is down and reasons therefore
|
||||
const {
|
||||
@@ -66,12 +66,12 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor && monitor.criteria && monitor.criteria.down
|
||||
? await ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) => criterion.default !== true
|
||||
),
|
||||
])
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
? await ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) => criterion.default !== true
|
||||
),
|
||||
])
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
|
||||
// determine if monitor is degraded and reasons therefore
|
||||
const {
|
||||
@@ -80,13 +80,13 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? await ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? await ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: { stat: false, successReasons: [], failedReasons: [] };
|
||||
|
||||
// normalize response
|
||||
if (validUp) {
|
||||
@@ -146,9 +146,9 @@ router.post(
|
||||
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 =
|
||||
|
||||
@@ -23,7 +23,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const val = req.body.search;
|
||||
const parentProjectId = req.params.projectId;
|
||||
|
||||
@@ -5,7 +5,7 @@ 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', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
if (IS_SAAS_SERVICE) {
|
||||
return sendItemResponse(req, res, { result: true });
|
||||
} else {
|
||||
@@ -13,7 +13,7 @@ router.get('/is-saas-service', function (req: Request, res: Response) {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/hosts', function (req: Request, res: Response) {
|
||||
router.get('/hosts', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
return sendItemResponse(req, res, {
|
||||
api: global.apiHost,
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
|
||||
const router = express.getRouter();
|
||||
|
||||
router.get('/auth/redirect', function (req: Request, res: Response) {
|
||||
router.get('/auth/redirect', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
// get oneuptime project id from slack auth state query params
|
||||
let state = req.query.state;
|
||||
const slackCode = req.query.code;
|
||||
@@ -67,7 +67,7 @@ router.post(
|
||||
'/:projectId/link',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const projectId = req.params.projectId;
|
||||
const code = req.query.code;
|
||||
|
||||
@@ -142,7 +142,7 @@ router.delete(
|
||||
'/:projectId/unLink/:teamId',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const projectId = req.params.projectId;
|
||||
const teamId = req.params.teamId;
|
||||
|
||||
@@ -170,7 +170,7 @@ router.delete(
|
||||
router.get(
|
||||
'/:projectId/teams',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const projectId = req.params.projectId;
|
||||
const integrationType = 'slack';
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const selectSmsCount =
|
||||
'userId sentTo createdAt projectId parentProjectId deleted deletedAt deletedById content status error';
|
||||
@@ -98,7 +98,7 @@ router.post(
|
||||
'/search',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const filter = req.body.filter;
|
||||
const skip = req.query['skip'];
|
||||
@@ -123,7 +123,7 @@ router.delete(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const query = {};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
@@ -54,7 +54,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const populate = [{ path: 'projectId', select: 'name' }];
|
||||
|
||||
@@ -21,7 +21,7 @@ router.post(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
@@ -46,7 +46,7 @@ router.get(
|
||||
'/:projectId/:templateId/reset',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const templateId = req.params.templateId;
|
||||
@@ -63,7 +63,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const templates = await SmsTemplateService.getTemplates(projectId);
|
||||
@@ -78,7 +78,7 @@ router.get(
|
||||
'/:projectId/smsTemplate/:smsTemplateId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const smsTemplateId = req.params.smsTemplateId;
|
||||
const populate = [{ path: 'projectId', select: 'name' }];
|
||||
@@ -99,7 +99,7 @@ router.put(
|
||||
'/:projectId/smsTemplate/:smsTemplateId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const smsTemplateId = req.params.smsTemplateId;
|
||||
@@ -120,7 +120,7 @@ router.put(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = [];
|
||||
const { projectId } = req.params;
|
||||
@@ -171,7 +171,7 @@ router.delete(
|
||||
'/:projectId/smsTemplate/:smsTemplateId',
|
||||
getUser,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const smsTemplateId = req.params.smsTemplateId;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 10;
|
||||
|
||||
@@ -40,7 +40,7 @@ router.get(
|
||||
}
|
||||
);
|
||||
|
||||
router.delete('/:id', getUser, async function (req: Request, res: Response) {
|
||||
router.delete('/:id', getUser, async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const sso = await SsoService.deleteBy({ _id: req.params.id });
|
||||
return sendItemResponse(req, res, sso);
|
||||
@@ -53,7 +53,7 @@ router.post(
|
||||
'/',
|
||||
getUser,
|
||||
isScaleOrMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const data = req.body;
|
||||
try {
|
||||
const sso = await SsoService.create(data);
|
||||
@@ -64,7 +64,7 @@ router.post(
|
||||
}
|
||||
);
|
||||
|
||||
router.get('/:id', getUser, async function (req: Request, res: Response) {
|
||||
router.get('/:id', getUser, async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const selectSso =
|
||||
'_id saml-enabled domain entityId remoteLoginUrl certificateFingerprint remoteLogoutUrl ipRanges createdAt deleted deletedAt deletedById samlSsoUrl projectId';
|
||||
@@ -79,7 +79,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const sso = await SsoService.updateBy({ _id: req.params.id }, data);
|
||||
|
||||
@@ -13,7 +13,7 @@ router.get(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 10;
|
||||
|
||||
@@ -47,7 +47,7 @@ router.delete(
|
||||
'/:id',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (!req.params.id) throw new Error('Id must be defined');
|
||||
const sso = await SsoDefaultRolesService.deleteBy({
|
||||
@@ -64,7 +64,7 @@ router.post(
|
||||
'/',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const data = req.body;
|
||||
try {
|
||||
const ssoDefaultRole = await SsoDefaultRolesService.create(data);
|
||||
@@ -79,7 +79,7 @@ router.get(
|
||||
'/:id',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const populateDefaultRoleSso = [
|
||||
{ path: 'domain', select: '_id domain' },
|
||||
@@ -110,7 +110,7 @@ router.put(
|
||||
'/:id',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
const ssoDefaultRole = await SsoDefaultRolesService.updateById(
|
||||
|
||||
@@ -362,7 +362,7 @@ router.put(
|
||||
|
||||
router.post(
|
||||
'/:projectId/certFile',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -391,7 +391,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
'/:projectId/privateKeyFile',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -423,7 +423,7 @@ router.post(
|
||||
|
||||
// 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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { domain } = req.query;
|
||||
|
||||
@@ -704,7 +704,7 @@ router.put(
|
||||
}
|
||||
);
|
||||
|
||||
router.get('/statusBubble', async function (req: Request, res: Response) {
|
||||
router.get('/statusBubble', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const statusPageId = req.query.statusPageId;
|
||||
const statusBubbleId = req.query.statusBubbleId;
|
||||
try {
|
||||
@@ -974,7 +974,7 @@ router.post(
|
||||
'/:projectId/:statusPageSlug/duplicateStatusPage',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, statusPageSlug } = req.params;
|
||||
const { subProjectId } = req.query;
|
||||
@@ -1011,7 +1011,7 @@ router.post(
|
||||
router.get(
|
||||
'/:statusPageId/rss',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const statusPageId = req.params.statusPageId;
|
||||
const url = req.query.url;
|
||||
|
||||
@@ -1056,17 +1056,14 @@ router.get(
|
||||
|
||||
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}`
|
||||
: ''
|
||||
}]]>`,
|
||||
}]]>`,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1118,7 +1115,7 @@ router.get(
|
||||
'/:projectId/:statusPageSlug/notes',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
let result;
|
||||
const statusPageSlug = req.params.statusPageSlug;
|
||||
const skip = req.query['skip'] || 0;
|
||||
@@ -1300,7 +1297,7 @@ router.get(
|
||||
'/:projectId/:statusPageSlug/events',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const statusPageSlug = req.params.statusPageSlug;
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 5;
|
||||
@@ -1332,7 +1329,7 @@ router.get(
|
||||
'/:projectId/:statusPageSlug/futureEvents',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
const { skip = 0, limit = 5, theme } = req.query;
|
||||
@@ -1357,7 +1354,7 @@ router.get(
|
||||
'/:projectId/:statusPageSlug/pastEvents',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
const { skip = 0, limit = 5, theme } = req.query;
|
||||
@@ -1487,7 +1484,7 @@ router.get(
|
||||
router.get(
|
||||
'/:projectId/scheduledEvent/:scheduledEventId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { scheduledEventId } = req.params;
|
||||
|
||||
try {
|
||||
@@ -1570,7 +1567,7 @@ router.post(
|
||||
router.get(
|
||||
'/:projectId/probes',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 0;
|
||||
@@ -1597,7 +1594,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const statusPageSlug = req.params.statusPageSlug;
|
||||
|
||||
const userId = req.user ? req.user.id : null;
|
||||
@@ -1656,7 +1653,7 @@ router.get(
|
||||
'/:projectId/:statusPageSlug/timelines',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -1735,7 +1732,7 @@ router.get(
|
||||
router.post(
|
||||
'/:projectId/createExternalstatus-page/:statusPageId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, statusPageId } = req.params;
|
||||
const { name, url } = req.body;
|
||||
@@ -1848,7 +1845,7 @@ router.post(
|
||||
router.post(
|
||||
'/:projectId/updateExternalstatus-page/:externalStatusPageId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, externalStatusPageId } = req.params;
|
||||
const { name, url } = req.body;
|
||||
@@ -1942,7 +1939,7 @@ router.post(
|
||||
router.get(
|
||||
'/:projectId/fetchExternalStatusPages/:statusPageId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, statusPageId } = req.params;
|
||||
|
||||
@@ -1976,7 +1973,7 @@ router.get(
|
||||
router.post(
|
||||
'/:projectId/deleteExternalstatus-page/:externalStatusPageId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, externalStatusPageId } = req.params;
|
||||
|
||||
@@ -2063,7 +2060,7 @@ router.post(
|
||||
router.put(
|
||||
'/:projectId/announcement/:statusPageId/:announcementId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, statusPageId, announcementId } = req.params;
|
||||
const { data } = req.body;
|
||||
@@ -2149,7 +2146,7 @@ router.put(
|
||||
router.get(
|
||||
'/:projectId/announcementLogs/:statusPageId',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageId } = req.params;
|
||||
const { skip, limit, theme } = req.query;
|
||||
@@ -2220,7 +2217,7 @@ router.get(
|
||||
router.get(
|
||||
'/:projectId/announcement/:statusPageSlug/single/:announcementSlug',
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, statusPageSlug, announcementSlug } = req.params;
|
||||
|
||||
@@ -2243,7 +2240,7 @@ router.get(
|
||||
router.delete(
|
||||
`/:projectId/announcement/:announcementId/delete`,
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId, announcementId } = req.params;
|
||||
|
||||
@@ -2265,7 +2262,7 @@ router.delete(
|
||||
router.delete(
|
||||
`/:projectId/announcementLog/:announcementLogId/delete`,
|
||||
checkUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { announcementLogId } = req.params;
|
||||
|
||||
@@ -2346,9 +2343,8 @@ 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`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2356,7 +2352,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/ongoing-events',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2384,7 +2380,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/future-events',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2408,7 +2404,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/past-events',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2432,7 +2428,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/probes',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2456,7 +2452,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/monitor-logs',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2480,7 +2476,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/announcements',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2510,7 +2506,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/announcement-logs',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2534,7 +2530,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/monitor-timelines',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2558,7 +2554,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/statuspage-notes',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
|
||||
@@ -2588,7 +2584,7 @@ router.get(
|
||||
'/resources/:statusPageSlug/monitor-statuses',
|
||||
checkUser,
|
||||
ipWhitelist,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageSlug } = req.params;
|
||||
const { range } = req.query;
|
||||
@@ -2996,18 +2992,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
|
||||
: [];
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageCategoryName } = req.body;
|
||||
const { statusPageId } = req.params;
|
||||
@@ -68,7 +68,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageCategoryId } = req.params;
|
||||
|
||||
@@ -108,7 +108,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { statusPageCategoryId } = req.params;
|
||||
const { statusPageCategoryName } = req.body;
|
||||
|
||||
@@ -23,7 +23,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const event = req.body;
|
||||
const customerId = event.data.object.customer;
|
||||
@@ -68,7 +68,7 @@ router.post('/events', async function (req: Request, res: Response) {
|
||||
router.get(
|
||||
'/:userId/charges',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user.id;
|
||||
if (userId) {
|
||||
@@ -88,7 +88,7 @@ router.get(
|
||||
router.post(
|
||||
'/:userId/creditCard/:token/pi',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { token } = req.params;
|
||||
|
||||
@@ -113,7 +113,7 @@ router.post(
|
||||
router.put(
|
||||
'/:userId/creditCard/:cardId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { cardId } = req.params;
|
||||
|
||||
@@ -138,7 +138,7 @@ router.put(
|
||||
router.delete(
|
||||
'/:userId/creditCard/:cardId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { cardId } = req.params;
|
||||
|
||||
@@ -163,7 +163,7 @@ router.delete(
|
||||
router.get(
|
||||
'/:userId/creditCard',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user.id;
|
||||
if (userId) {
|
||||
@@ -183,7 +183,7 @@ router.get(
|
||||
router.get(
|
||||
'/:userId/creditCard/:cardId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { cardId } = req.params;
|
||||
|
||||
@@ -207,7 +207,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
const { projectId } = req.params;
|
||||
@@ -232,7 +232,7 @@ router.post(
|
||||
}
|
||||
);
|
||||
|
||||
router.post('/checkCard', async function (req: Request, res: Response) {
|
||||
router.post('/checkCard', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { tokenId, email, companyName } = req.body;
|
||||
const paymentIntent = await StripeService.makeTestCharge(
|
||||
@@ -251,7 +251,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { intentId } = req.params;
|
||||
|
||||
@@ -281,7 +281,7 @@ router.post(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserOwner,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
|
||||
router.post(
|
||||
'/:projectId/:statusPageId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const body = req.body;
|
||||
const data = {};
|
||||
@@ -167,7 +167,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
'/:projectId/subscribe/:monitorId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
@@ -323,7 +323,7 @@ router.post(
|
||||
// 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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const skip = req.query['skip'] || 0;
|
||||
@@ -346,7 +346,7 @@ router.get('/:projectId', async function (req: Request, res: Response) {
|
||||
// Returns: response subscriber, error message
|
||||
router.get(
|
||||
'/:projectId/monitor/:monitorId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitorId = req.params.monitorId;
|
||||
const skip = req.query['skip'] || 0;
|
||||
@@ -380,7 +380,7 @@ router.get(
|
||||
// Returns: response subscriber, error message
|
||||
router.get(
|
||||
'/monitorList/:subscriberId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subscriberId = req.params.subscriberId;
|
||||
|
||||
@@ -436,7 +436,7 @@ router.get(
|
||||
// Returns: response subscriber, error message
|
||||
router.get(
|
||||
'/:projectId/:subscriberId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const subscriberId = req.params.subscriberId;
|
||||
@@ -463,7 +463,7 @@ router.get(
|
||||
// Returns: response subscriber, error message
|
||||
router.put(
|
||||
'/unsubscribe/:monitorId/:email',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { email, monitorId } = req.params;
|
||||
const subscriber = await SubscriberService.updateOneBy(
|
||||
@@ -482,7 +482,7 @@ router.put(
|
||||
router.delete(
|
||||
'/:projectId/:subscriberId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const subscriberId = req.params.subscriberId;
|
||||
|
||||
@@ -500,7 +500,7 @@ router.delete(
|
||||
|
||||
router.post(
|
||||
'/:projectId/:monitorId/csv',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.projectId = req.params.projectId;
|
||||
|
||||
@@ -44,7 +44,7 @@ router.post(
|
||||
// Mark alert as viewed
|
||||
router.get(
|
||||
'/:projectId/:alertId/viewed',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const alertId = req.params.alertId;
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
@@ -25,7 +25,7 @@ router.get(
|
||||
'/:projectId',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const projectId = req.params.projectId;
|
||||
|
||||
try {
|
||||
@@ -45,7 +45,7 @@ router.get(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
getSubProjects,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const subProjectIds = req.user.subProjects
|
||||
? req.user.subProjects.map((project: $TSFixMe) => project._id)
|
||||
: null;
|
||||
@@ -176,8 +176,8 @@ router.post(
|
||||
const teamMembers = await TeamService.getTeamMembers(projectId);
|
||||
const withoutViewers = teamMembers
|
||||
? teamMembers.filter(
|
||||
teamMember => teamMember.role !== 'Viewer'
|
||||
)
|
||||
teamMember => teamMember.role !== 'Viewer'
|
||||
)
|
||||
: [];
|
||||
const totalTeamMembers =
|
||||
withoutViewers.length + emailArray.length;
|
||||
@@ -228,7 +228,7 @@ router.delete(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
const teamMemberUserId = req.params.teamMemberId;
|
||||
const projectId = req.params.projectId;
|
||||
@@ -273,7 +273,7 @@ router.put(
|
||||
getUser,
|
||||
isAuthorized,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const data = req.body;
|
||||
const projectId = req.params.projectId;
|
||||
data.teamMemberId = req.params.teamMemberId;
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
// jwtAccessToken: token.accessToken,
|
||||
// jwtRefreshToken: token.refreshToken,
|
||||
// }
|
||||
router.post('/new', async function (req: Request, res: Response) {
|
||||
router.post('/new', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const jwtRefreshToken = req.body.refreshToken;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
sendItemResponse,
|
||||
} from 'common-server/utils/response';
|
||||
|
||||
router.get('/', getUser, async function (req: Request, res: Response) {
|
||||
router.get('/', getUser, async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
const user = await UserService.findOneBy({
|
||||
@@ -27,7 +27,7 @@ router.get('/', getUser, async function (req: Request, res: Response) {
|
||||
}
|
||||
});
|
||||
|
||||
router.put('/', getUser, async function (req: Request, res: Response) {
|
||||
router.put('/', getUser, async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
let user = await UserService.findOneBy({
|
||||
|
||||
@@ -141,7 +141,7 @@ router.post(
|
||||
'/sms/verify',
|
||||
getUser,
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { to, code } = req.body;
|
||||
|
||||
@@ -196,7 +196,7 @@ router.post(
|
||||
'/sms/test',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
|
||||
@@ -36,7 +36,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (
|
||||
typeof process.env.DISABLE_SIGNUP === 'string' &&
|
||||
@@ -296,7 +296,7 @@ router.post('/signup', async function (req: Request, res: Response) {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/masterAdminExists', async function (req: Request, res: Response) {
|
||||
router.get('/masterAdminExists', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const masterAdmin = await UserService.findBy({
|
||||
query: { role: 'master-admin' },
|
||||
@@ -318,7 +318,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const { email } = req.query;
|
||||
if (!email) {
|
||||
return sendErrorResponse(req, res, {
|
||||
@@ -385,7 +385,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const options = {
|
||||
request_body: req.body,
|
||||
allow_unencrypted_assertion: true,
|
||||
@@ -522,14 +522,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}`
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -540,7 +540,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const clientIP = Ip.getClientIp(req)[0];
|
||||
@@ -617,7 +617,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
const token = data.token;
|
||||
@@ -683,7 +683,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
// Call the UserService
|
||||
@@ -770,7 +770,7 @@ router.post('/verify/backupCode', async function (req: Request, res: Response) {
|
||||
router.post(
|
||||
'/generate/backupCode',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
const userId = req.user.id || null;
|
||||
const user = await UserService.findOneBy({
|
||||
query: { _id: userId },
|
||||
@@ -824,7 +824,7 @@ router.post(
|
||||
// Returns: 400: Error; 500: Server Error; 200: user
|
||||
router.post(
|
||||
'/totp/token/:userId',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
const user = await UserService.findOneBy({
|
||||
@@ -857,7 +857,7 @@ router.post(
|
||||
// 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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -898,7 +898,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -958,7 +958,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -1002,7 +1002,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const upload = multer({
|
||||
storage,
|
||||
@@ -1056,7 +1056,7 @@ router.put('/profile', getUser, async function (req: Request, res: Response) {
|
||||
router.put(
|
||||
'/push-notification',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
const data = req.body;
|
||||
@@ -1076,7 +1076,7 @@ router.put(
|
||||
router.put(
|
||||
'/:userId/2fa',
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { userId } = req.params;
|
||||
const data = req.body;
|
||||
@@ -1151,7 +1151,7 @@ router.put(
|
||||
router.put(
|
||||
'/changePassword',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
|
||||
@@ -1244,7 +1244,7 @@ router.put(
|
||||
// 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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.user ? req.user.id : null;
|
||||
|
||||
@@ -1303,7 +1303,7 @@ router.get('/profile', getUser, async function (req: Request, res: Response) {
|
||||
|
||||
router.get(
|
||||
'/confirmation/:token',
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (req.params && req.params.token) {
|
||||
const token = await VerificationTokenModel.findOne({
|
||||
@@ -1312,7 +1312,7 @@ router.get(
|
||||
if (!token) {
|
||||
return res.redirect(
|
||||
global.accountsHost +
|
||||
'/user-verify/resend?status=link-expired'
|
||||
'/user-verify/resend?status=link-expired'
|
||||
);
|
||||
}
|
||||
const user = await UserModel.findOne({
|
||||
@@ -1351,7 +1351,7 @@ router.get(
|
||||
} else {
|
||||
return res.redirect(
|
||||
global.accountsHost +
|
||||
'/user-verify/resend?status=invalid-verification-link'
|
||||
'/user-verify/resend?status=invalid-verification-link'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -1361,7 +1361,7 @@ router.get(
|
||||
}
|
||||
);
|
||||
|
||||
router.post('/resend', async function (req: Request, res: Response) {
|
||||
router.post('/resend', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
if (req.body && req.body.email) {
|
||||
const { email, userId } = req.body;
|
||||
let user;
|
||||
@@ -1413,7 +1413,7 @@ router.get(
|
||||
'/users',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const skip = req.query['skip'] || 0;
|
||||
const limit = req.query['limit'] || 10;
|
||||
@@ -1456,7 +1456,7 @@ router.delete(
|
||||
'/:userId',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
|
||||
@@ -1575,7 +1575,7 @@ router.post(
|
||||
'/:userId/switchToAdminMode',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
|
||||
@@ -1609,7 +1609,7 @@ router.post(
|
||||
'/:userId/exitAdminMode',
|
||||
getUser,
|
||||
isUserMasterAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const userId = req.params.userId;
|
||||
|
||||
@@ -1739,7 +1739,7 @@ router.post(
|
||||
router.delete(
|
||||
'/:userId/delete',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
if (req.params.userId !== req.user.id) {
|
||||
return sendErrorResponse(req, res, {
|
||||
@@ -1820,7 +1820,7 @@ router.delete(
|
||||
}
|
||||
);
|
||||
|
||||
router.get('/:token/email', async function (req: Request, res: Response) {
|
||||
router.get('/:token/email', async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const token = await VerificationTokenModel.findOne({
|
||||
token: req.params.token,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import express, { Request, Response } from 'common-server/utils/express';
|
||||
import express, { ExpressRequest, ExpressResponse } from 'common-server/utils/express';
|
||||
const router = express.getRouter();
|
||||
|
||||
import {
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
sendItemResponse,
|
||||
} from 'common-server/utils/response';
|
||||
|
||||
router.get('/', function (req: Request, res: Response) {
|
||||
router.get('/', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
return sendItemResponse(req, res, {
|
||||
server: process.env.npm_package_version,
|
||||
|
||||
@@ -264,7 +264,7 @@ router.delete(
|
||||
'/:projectId/delete/:integrationId',
|
||||
getUser,
|
||||
isUserAdmin,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const integrationId = req.params.integrationId;
|
||||
@@ -285,7 +285,7 @@ router.delete(
|
||||
router.get(
|
||||
'/:projectId/hooks',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.params.projectId;
|
||||
const integrationType = req.query.type || 'webhook';
|
||||
@@ -325,7 +325,7 @@ router.get(
|
||||
router.get(
|
||||
'/:projectId/hooks/:monitorId',
|
||||
getUser,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// const projectId = req.params.projectId;
|
||||
const integrationType = req.query.type || 'webhook';
|
||||
|
||||
@@ -13,7 +13,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 (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const apiKey = req.query.apiKey;
|
||||
const projectId = req.query.projectId;
|
||||
@@ -27,7 +27,7 @@ router.get('/test', isAuthorized, async function (req: Request, res: Response) {
|
||||
router.get(
|
||||
'/monitors',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.query.projectId;
|
||||
|
||||
@@ -61,7 +61,7 @@ router.get(
|
||||
router.post(
|
||||
'/incident/createIncident',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const monitors = req.body.monitors || [];
|
||||
const incident = await ZapierService.createIncident(monitors);
|
||||
@@ -75,7 +75,7 @@ router.post(
|
||||
router.get(
|
||||
'/incidents',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.query.projectId;
|
||||
// We return all the incidents to zapier because it gives user an option to configure zapier properly with all the steps.
|
||||
@@ -91,7 +91,7 @@ router.get(
|
||||
router.get(
|
||||
'/incident-note',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.query.projectId;
|
||||
// We return all the incidents to zapier because it gives user an option to configure zapier properly with all the steps.
|
||||
@@ -107,7 +107,7 @@ router.get(
|
||||
router.post(
|
||||
'/incident/incident-note',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { data } = req.body;
|
||||
const incidentNote = await ZapierService.createIncidentNote(data);
|
||||
@@ -121,7 +121,7 @@ router.post(
|
||||
router.get(
|
||||
'/incident/resolved',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.query.projectId;
|
||||
// We return all the incidents to zapier because it gives user an option to configure zapier properly with all the steps.
|
||||
@@ -190,7 +190,7 @@ router.post(
|
||||
router.get(
|
||||
'/incident/acknowledged',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const projectId = req.query.projectId;
|
||||
// We return all the incidents to zapier because it gives user an option to configure zapier properly with all the steps.
|
||||
@@ -265,7 +265,7 @@ router.post(
|
||||
router.post(
|
||||
'/subscribe',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const url = req.body.url;
|
||||
const type = req.body.type;
|
||||
@@ -305,7 +305,7 @@ router.post(
|
||||
router.delete(
|
||||
'/unsubscribe/:id',
|
||||
isAuthorized,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
await ZapierService.unsubscribe(id);
|
||||
|
||||
@@ -89,13 +89,11 @@ app.use(async function (req: Request, res: Response, next: NextFunction) {
|
||||
req.logdata = logdata;
|
||||
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${
|
||||
process.env['POD_NAME']
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${process.env['POD_NAME']
|
||||
} -- RECEIVED AT: ${new Date()} -- METHOD: ${method} -- URL: ${url}`
|
||||
);
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${
|
||||
req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
}`
|
||||
);
|
||||
|
||||
@@ -469,7 +467,7 @@ app.use(
|
||||
|
||||
app.use(['/api'], require('./backend/api/apiStatus'));
|
||||
|
||||
app.use('/*', function (req: Request, res: Response) {
|
||||
app.use('/*', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.status(404).send('Endpoint not found.');
|
||||
});
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -20,7 +20,7 @@ app.set('port', process.env['PORT'] || 3055);
|
||||
|
||||
app.get(
|
||||
['/container/status', '/status'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -36,7 +36,7 @@ app.get(
|
||||
|
||||
app.get(
|
||||
['/container/version', '/version'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send({ containerScannerVersion: process.env.npm_package_version });
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -9,7 +9,7 @@ const app = express.getExpressApp();
|
||||
|
||||
app.get(
|
||||
['/env.js', '/dashboard/env.js'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
const isClustLocal = req.get('host').includes('cluster.local');
|
||||
if (!isClustLocal) {
|
||||
global.dashboardHost = 'https://' + req.host + '/dashboard';
|
||||
@@ -73,7 +73,7 @@ app.get(
|
||||
//APP VERSION
|
||||
app.use(
|
||||
['/dashboard/api/version', '/dashboard/version'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.json({ dashboardVersion: process.env.npm_package_version });
|
||||
}
|
||||
@@ -81,7 +81,7 @@ app.use(
|
||||
|
||||
app.get(
|
||||
['/dashboard/status', '/status'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -133,6 +133,6 @@ app.use('/dashboard', express.static(path.join(__dirname, 'build')));
|
||||
// }
|
||||
// });
|
||||
|
||||
app.get('/*', function (req: Request, res: Response) {
|
||||
app.get('/*', (req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.sendFile(path.join(__dirname, 'build', 'index.html'));
|
||||
});
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -51,20 +51,20 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
@@ -72,20 +72,20 @@ router.post(
|
||||
// failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
@@ -93,25 +93,25 @@ router.post(
|
||||
// failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const [up, degraded, down] = await Promise.all([
|
||||
validUp,
|
||||
@@ -153,45 +153,45 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
reason = upSuccessReasons;
|
||||
@@ -230,17 +230,17 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -248,19 +248,19 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -268,17 +268,17 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
@@ -323,59 +323,59 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -467,19 +467,19 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -487,19 +487,19 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -507,24 +507,24 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -588,9 +588,9 @@ router.post(
|
||||
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');
|
||||
@@ -598,9 +598,9 @@ router.post(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ router.post(
|
||||
router.post(
|
||||
'/setTime/:monitorId',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.probeId = req.probe.id;
|
||||
@@ -682,7 +682,7 @@ router.post(
|
||||
router.post(
|
||||
'/getTime/:monitorId',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
data.probeId = req.probe.id;
|
||||
@@ -698,7 +698,7 @@ router.post(
|
||||
router.post(
|
||||
'/set-scan-status',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitorIds, scanning } = req.body;
|
||||
await MonitorService.updateScanStatus(monitorIds, scanning);
|
||||
@@ -713,7 +713,7 @@ router.post(
|
||||
router.post(
|
||||
'/add-probe-scan',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitorIds } = req.body;
|
||||
await MonitorService.addProbeScanning(monitorIds, req.probe.id);
|
||||
@@ -728,7 +728,7 @@ router.post(
|
||||
router.post(
|
||||
'/remove-probe-scan',
|
||||
isAuthorizedProbe,
|
||||
async function (req: Request, res: Response) {
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
const { monitorIds } = req.body;
|
||||
await MonitorService.removeProbeScanning(monitorIds, req.probe.id);
|
||||
|
||||
@@ -97,7 +97,7 @@ app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
|
||||
app.get(
|
||||
['/data-ingestor/status', '/status'],
|
||||
function (req: Request, res: Response) {
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
// "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. */
|
||||
], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
"types": ["node"], /* 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. */
|
||||
|
||||
13
home/package-lock.json
generated
13
home/package-lock.json
generated
@@ -26,6 +26,7 @@
|
||||
"xmlbuilder2": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.22",
|
||||
"chrome-launcher": "^0.15.0",
|
||||
"commander": "^8.3.0",
|
||||
"depcheck": "^1.4.3",
|
||||
@@ -1392,9 +1393,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "14.14.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz",
|
||||
"integrity": "sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g=="
|
||||
"version": "17.0.22",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.22.tgz",
|
||||
"integrity": "sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw=="
|
||||
},
|
||||
"node_modules/@types/parse-json": {
|
||||
"version": "4.0.0",
|
||||
@@ -10494,9 +10495,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.14.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz",
|
||||
"integrity": "sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g=="
|
||||
"version": "17.0.22",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.22.tgz",
|
||||
"integrity": "sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw=="
|
||||
},
|
||||
"@types/parse-json": {
|
||||
"version": "4.0.0",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
},
|
||||
"resolutions": {},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.22",
|
||||
"chrome-launcher": "^0.15.0",
|
||||
"commander": "^8.3.0",
|
||||
"depcheck": "^1.4.3",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user