add types to express routes

This commit is contained in:
Nawaz Dhandala
2022-02-28 18:57:31 +00:00
parent 985dd2914e
commit 534a7b79bb
107 changed files with 939 additions and 603 deletions

View File

@@ -52,7 +52,7 @@ app.use(
// app.use(
// /^\/accounts\/static\/js\/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\.(.+)\.chunk\.js$/,
// function(req, res, next) {
// function(req:express.Request, res: express.Response, next: express.RequestHandler) {
// let baseUrls = req.baseUrl;
// baseUrls = baseUrls.split('/');

View File

@@ -44,7 +44,7 @@ const cronApplicationSecurityStartTime = Math.floor(Math.random() * 50);
app.use(cors());
app.set('port', process.env.PORT || 3005);
app.get(['/application/status', '/status'], function(req, res) {
app.get(['/application/status', '/status'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({
@@ -57,7 +57,7 @@ app.get(['/application/status', '/status'], function(req, res) {
//App Version
app.get(['/application/version', '/version'], function(req, res) {
app.get(['/application/version', '/version'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send({ applicationScannerVersion: process.env.npm_package_version });
});

View File

@@ -6,7 +6,7 @@ import AccountStoreService from '../services/accountStoreService';
const router = express.Router();
// store account details to the db
router.post('/store', async (req, res) => {
router.post('/store', async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -18,7 +18,7 @@ router.post('/store', async (req, res) => {
});
// update account details in the db
router.put('/store/:id', async (req, res) => {
router.put('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;
const account = await AccountStoreService.updateOneBy({ id }, req.body);
@@ -30,7 +30,7 @@ router.put('/store/:id', async (req, res) => {
});
// fetch an account detail
router.get('/store/:id', async (req, res) => {
router.get('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;
const account = await AccountStoreService.findOneBy({
@@ -46,7 +46,7 @@ router.get('/store/:id', async (req, res) => {
});
// delete an account detail
router.delete('/store/:id', async (req, res) => {
router.delete('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;

View File

@@ -16,7 +16,7 @@ const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendListResponse = require('../middlewares/response').sendListResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
@@ -88,7 +88,7 @@ router.get(
'/:projectId/incident/:incidentSlug',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const incidentSlug = req.params.incidentSlug;
// const projectId = req.params.projectId;
@@ -137,7 +137,7 @@ router.get(
);
// Mark alert as viewed. This is for Email.
router.get('/:projectId/:alertId/viewed', async function(req, res) {
router.get('/:projectId/:alertId/viewed', async function(req:express.Request, res: express.Response) {
try {
const alertId = req.params.alertId;
const projectId = req.params.projectId;
@@ -163,7 +163,7 @@ router.get('/:projectId/:alertId/viewed', async function(req, res) {
}
});
router.delete('/:projectId', getUser, isUserOwner, async function(req, res) {
router.delete('/:projectId', getUser, isUserOwner, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;

View File

@@ -6,7 +6,7 @@ import ApiStatusService from '../services/apiStatusService';
const router = express.Router();
// store account details to the db
router.get('/', async (req, res) => {
router.get('/', async (req:express.Request, res: express.Response) => {
try {
const data = {
status: 'online',

View File

@@ -31,7 +31,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const componentId = req.params.componentId;
@@ -132,7 +132,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { applicationLogId, componentId } = req.params;
try {
const applicationLog = await ApplicationLogService.deleteBy(
@@ -193,7 +193,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/logs',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { skip, limit, startDate, endDate, type, filter } = req.body;
const applicationLogId = req.params.applicationLogId;
@@ -253,7 +253,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/stats',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const applicationLogId = req.params.applicationLogId;
@@ -308,7 +308,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const applicationLogId = req.params.applicationLogId;
const currentApplicationCount = await ApplicationLogService.countBy({
@@ -345,7 +345,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { applicationLogId, componentId } = req.params;
const data = req.body;
@@ -443,7 +443,7 @@ router.post(
'/:projectId/:componentId/:applicationLogId/search',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { applicationLogId } = req.params;
const startTime = new Date();
const { duration, filter, range } = req.body;

View File

@@ -21,7 +21,7 @@ import ErrorService from 'common-server/utils/error';
router.get(
'/applicationSecurities',
isAuthorizedApplicationScanner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const response = await ApplicationSecurityService.getSecuritiesToScan();
return sendItemResponse(req, res, response);
@@ -71,7 +71,7 @@ router.post('/failed', isAuthorizedApplicationScanner, async function(
return sendErrorResponse(req, res, error);
}
});
router.post('/log', isAuthorizedApplicationScanner, async function(req, res) {
router.post('/log', isAuthorizedApplicationScanner, async function(req:express.Request, res: express.Response) {
try {
const security = req.body;
const securityLog = await ApplicationSecurityLogService.create({
@@ -259,7 +259,7 @@ router.post('/log', isAuthorizedApplicationScanner, async function(req, res) {
}
});
router.post('/time', isAuthorizedApplicationScanner, async function(req, res) {
router.post('/time', isAuthorizedApplicationScanner, async function(req:express.Request, res: express.Response) {
try {
const security = req.body;
const updatedTime = await ApplicationSecurityService.updateScanTime({

View File

@@ -21,7 +21,7 @@ router.post(
'/:projectId/:componentId/application',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
data.componentId = req.params.componentId;
@@ -92,7 +92,7 @@ router.put(
'/:projectId/:componentId/application/:applicationSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId, applicationSecurityId } = req.params;
const {
@@ -151,7 +151,7 @@ router.get(
'/:projectId/:componentId/application/:applicationSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecurityId } = req.params;
@@ -200,7 +200,7 @@ router.get(
'/:projectId/:componentId/applicationSecuritySlug/:applicationSecuritySlug',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecuritySlug } = req.params;
@@ -249,7 +249,7 @@ router.get(
'/:projectId/:componentId/application',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
const { skip, limit } = req.query;
@@ -294,7 +294,7 @@ router.delete(
'/:projectId/:componentId/application/:applicationSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecurityId } = req.params;
@@ -316,7 +316,7 @@ router.delete(
'/:projectId/:componentId/application',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
@@ -338,7 +338,7 @@ router.get(
'/:projectId/application/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;
const populateApplicationSecurity = [
@@ -378,7 +378,7 @@ router.post(
'/:projectId/application/scan/:applicationSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecurityId } = req.params;
const applicationSecurity = await ApplicationSecurityService.findOneBy(

View File

@@ -16,7 +16,7 @@ router.get(
'/:projectId/:componentId/application/logs/:applicationSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecurityId, componentId } = req.params;
@@ -52,7 +52,7 @@ router.get(
'/:projectId/:componentId/applicationSecuritySlug/logs/:applicationSecuritySlug',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { applicationSecuritySlug, componentId } = req.params;
@@ -88,7 +88,7 @@ router.get(
'/:projectId/:componentId/application/logs',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
const populateApplicationSecurityLog = [

View File

@@ -10,7 +10,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
import { sendItemResponse } from '../middlewares/response';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};
const skip = req.query.skip;
@@ -39,7 +39,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/search', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const filter = req.body.filter;
const skip = req.query.skip;
@@ -56,7 +56,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};

View File

@@ -11,7 +11,7 @@ import { isAuthorized } from '../middlewares/authorization';
import { getUser } from '../middlewares/user';
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { skip, limit } = req.query;
@@ -36,7 +36,7 @@ router.get(
'/:projectId/:automatedSlug',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { automatedSlug } = req.params;
const { skip, limit } = req.query;
@@ -85,7 +85,7 @@ router.get(
// Route Description: Creates a new script
// req.body -> {name, scriptType, script, successEvent, failureEvent}
// Returns: response new script created
router.post('/:projectId', getUser, isAuthorized, async (req, res) => {
router.post('/:projectId', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -149,7 +149,7 @@ router.put(
'/:projectId/:automatedScriptId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const automatedScriptId = req.params.automatedScriptId;
const data = req.body;
@@ -216,7 +216,7 @@ router.put(
'/:projectId/:automatedScriptId/run',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { automatedScriptId } = req.params;
@@ -237,7 +237,7 @@ router.delete(
'/:projectId/:automatedSlug',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, automatedSlug } = req.params;
const query = {

View File

@@ -10,7 +10,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
import { sendItemResponse } from '../middlewares/response';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};
const skip = req.query.skip;
@@ -27,7 +27,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/', getUser, isUserMasterAdmin, async (req, res) => {
router.post('/', getUser, isUserMasterAdmin, async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -78,7 +78,7 @@ router.post('/', getUser, isUserMasterAdmin, async (req, res) => {
}
});
router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/search', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const filter = req.body.filter;
const skip = req.query.skip;
@@ -95,7 +95,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};

View File

@@ -91,7 +91,7 @@ router.post('/routeBackupCall', backupCallForward);
router.get('/statusCallback', callStatus);
router.post('/statusCallback', callStatus);
router.get('/:projectId', getUser, isAuthorized, async (req, res) => {
router.get('/:projectId', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
let { skip, limit } = req.query;
const { projectId } = req.params;
@@ -120,7 +120,7 @@ router.get('/:projectId', getUser, isAuthorized, async (req, res) => {
}
});
router.get('/:projectId/logs', getUser, isAuthorized, async (req, res) => {
router.get('/:projectId/logs', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const { projectId } = req.params;
const logs = await CallRoutingService.getCallRoutingLogs(projectId);
@@ -134,7 +134,7 @@ router.get(
'/:projectId/routingNumbers',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { countryCode, numberType } = req.query;
const { projectId } = req.params;
@@ -198,7 +198,7 @@ router.put(
'/:projectId/:callRoutingId/:audioFieldName',
getUser,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { audioFieldName, callRoutingId } = req.params;
const upload = multer({
@@ -242,7 +242,7 @@ router.delete(
'/:projectId/:callRoutingId',
getUser,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, callRoutingId } = req.params;
@@ -271,7 +271,7 @@ router.delete(
'/:projectId/:callRoutingId/removeAudio',
getUser,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { callRoutingId, backup } = req.body;
if (!callRoutingId) {

View File

@@ -8,7 +8,7 @@ import SiteManagerService from '../services/siteManagerService';
const router = express.Router();
// store certificate details to the db
router.post('/store', async (req, res) => {
router.post('/store', async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -20,7 +20,7 @@ router.post('/store', async (req, res) => {
});
// update certificate details in the db
router.put('/store/:id', async (req, res) => {
router.put('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;
const certificate = await CertificateStoreService.updateOneBy(
@@ -35,7 +35,7 @@ router.put('/store/:id', async (req, res) => {
});
// fetch a certificate detail
router.get('/store/:id', async (req, res) => {
router.get('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;
const certificate = await CertificateStoreService.findOneBy({
@@ -52,7 +52,7 @@ router.get('/store/:id', async (req, res) => {
// fetch a certificate by the subject
// called from the status page project
router.get('/store/cert/:subject', async (req, res) => {
router.get('/store/cert/:subject', async (req:express.Request, res: express.Response) => {
try {
const { subject } = req.params;
const certificate = await CertificateStoreService.findOneBy({
@@ -68,7 +68,7 @@ router.get('/store/cert/:subject', async (req, res) => {
});
// delete an certificate detail
router.delete('/store/:id', async (req, res) => {
router.delete('/store/:id', async (req:express.Request, res: express.Response) => {
try {
const { id } = req.params;
@@ -79,7 +79,7 @@ router.delete('/store/:id', async (req, res) => {
}
});
router.post('/certOrder', async (req, res) => {
router.post('/certOrder', async (req:express.Request, res: express.Response) => {
try {
const domains = [];
@@ -165,7 +165,7 @@ router.post('/certOrder', async (req, res) => {
// delete ssl certificate for a particular domain
// and remove it from certificate order queue
// id => domain/subdomain
router.delete('/certDelete/:id', async (req, res) => {
router.delete('/certDelete/:id', async (req:express.Request, res: express.Response) => {
try {
const greenlock = global.greenlock;
const { id } = req.body;

View File

@@ -99,7 +99,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const { componentId } = req.params;
@@ -199,7 +199,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const type = req.query.type;
@@ -242,7 +242,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const componentId = req.params.componentId;
const type = req.query.type;
@@ -279,7 +279,7 @@ router.post(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { startDate, endDate } = req.body;
const componentId = req.params.componentId;
@@ -379,7 +379,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const componentId = req.params.componentId;
const type = req.query.type;
@@ -693,7 +693,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -757,7 +757,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { componentId, projectId } = req.params;
try {
await ComponentService.deleteBy(

View File

@@ -47,7 +47,7 @@ router.post('/scanning', isAuthorizedContainerScanner, async function(
}
});
router.post('/failed', isAuthorizedContainerScanner, async function(req, res) {
router.post('/failed', isAuthorizedContainerScanner, async function(req:express.Request, res: express.Response) {
try {
const security = req.body;
const containerSecurity = await ContainerSecurityService.updateOneBy(
@@ -61,7 +61,7 @@ router.post('/failed', isAuthorizedContainerScanner, async function(req, res) {
return sendErrorResponse(req, res, error);
}
});
router.post('/log', isAuthorizedContainerScanner, async function(req, res) {
router.post('/log', isAuthorizedContainerScanner, async function(req:express.Request, res: express.Response) {
try {
const security = req.body;
const securityLog = await ContainerSecurityLogService.create({
@@ -148,7 +148,7 @@ router.post('/log', isAuthorizedContainerScanner, async function(req, res) {
}
});
router.post('/time', isAuthorizedContainerScanner, async function(req, res) {
router.post('/time', isAuthorizedContainerScanner, async function(req:express.Request, res: express.Response) {
try {
const security = req.body;
const updatedTime = await ContainerSecurityService.updateScanTime({

View File

@@ -21,7 +21,7 @@ router.post(
'/:projectId/:componentId/container',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
data.componentId = req.params.componentId;
@@ -91,7 +91,7 @@ router.put(
'/:projectId/:componentId/container/:containerSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId, containerSecurityId } = req.params;
const {
@@ -155,7 +155,7 @@ router.get(
'/:projectId/:componentId/container',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
const { skip, limit } = req.query;
@@ -197,7 +197,7 @@ router.get(
'/:projectId/:componentId/container/:containerSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecurityId } = req.params;
const populate = [
@@ -239,7 +239,7 @@ router.get(
'/:projectId/:componentId/containerSecuritySlug/:containerSecuritySlug',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecuritySlug } = req.params;
const populate = [
@@ -281,7 +281,7 @@ router.delete(
'/:projectId/:componentId/container/:containerSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecurityId } = req.params;
@@ -303,7 +303,7 @@ router.delete(
'/:projectId/:componentId/container',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
@@ -325,7 +325,7 @@ router.get(
'/:projectId/container/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;
const populate = [
@@ -360,7 +360,7 @@ router.post(
'/:projectId/container/scan/:containerSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecurityId } = req.params;
const containerSecurity = await ContainerSecurityService.findOneBy({

View File

@@ -16,7 +16,7 @@ router.get(
'/:projectId/:componentId/container/logs/:containerSecurityId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecurityId, componentId } = req.params;
@@ -47,7 +47,7 @@ router.get(
'/:projectId/:componentId/containerSecuritySlug/logs/:containerSecuritySlug',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { containerSecuritySlug, componentId } = req.params;
@@ -78,7 +78,7 @@ router.get(
'/:projectId/:componentId/container/logs',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { componentId } = req.params;
const selectContainerLog =

View File

@@ -12,7 +12,7 @@ import CustomFieldService from '../services/customFieldService';
const router = express.Router();
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { fieldName, fieldType, uniqueField } = req.body;
@@ -59,7 +59,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -142,7 +142,7 @@ router.delete(
'/:projectId/:customFieldId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, customFieldId } = req.params;

View File

@@ -6,7 +6,7 @@ import DefaultManagerService from '../services/defaultManagerService';
const router = express.Router();
// store default details to the db
router.put('/default', async (req, res) => {
router.put('/default', async (req:express.Request, res: express.Response) => {
try {
const {
store,
@@ -54,7 +54,7 @@ router.put('/default', async (req, res) => {
}
});
router.get('/default', async (req, res) => {
router.get('/default', async (req:express.Request, res: express.Response) => {
try {
const defaultManager = await DefaultManagerService.findOneBy({
query: { deleted: false },

View File

@@ -12,7 +12,7 @@ router.post(
'/:projectId/dockerCredential',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const {
dockerRegistryUrl,
@@ -64,7 +64,7 @@ router.get(
'/:projectId/dockerCredential',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { projectId } = req.params;
@@ -87,7 +87,7 @@ router.put(
'/:projectId/dockerCredential/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;
const {
@@ -122,7 +122,7 @@ router.delete(
'/:projectId/dockerCredential/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;

View File

@@ -23,7 +23,7 @@ router.put(
'/:projectId/verify/:domainId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { domain: subDomain, verificationToken } = req.body;
// id of the base domain
const { domainId } = req.params;
@@ -66,7 +66,7 @@ router.put(
'/:projectId/forceVerify/:domainId',
getUser,
isUserMasterAdmin,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
// id of the base domain
const { domainId } = req.params;
try {
@@ -85,7 +85,7 @@ router.put(
'/:projectId/unverify/:domainId',
getUser,
isUserMasterAdmin,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { domainId } = req.params;
const response = await DomainVerificationService.updateOneBy(
@@ -101,7 +101,7 @@ router.put(
}
);
router.get('/:projectId/domains', getUser, isAuthorized, async (req, res) => {
router.get('/:projectId/domains', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
const { projectId } = req.params;
const { skip, limit } = req.query;
const selectDomainVerify =
@@ -128,7 +128,7 @@ router.get('/:projectId/domains', getUser, isAuthorized, async (req, res) => {
}
});
router.post('/:projectId/domain', getUser, isAuthorized, async (req, res) => {
router.post('/:projectId/domain', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const { projectId } = req.params;
const { domain } = req.body;
@@ -183,7 +183,7 @@ router.put(
'/:projectId/resetDomain/:domainId',
getUser,
isUserMasterAdmin,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { domainId } = req.params;
const domain = await DomainVerificationService.resetDomain(
@@ -200,7 +200,7 @@ router.put(
'/:projectId/domain/:domainId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { projectId, domainId } = req.params;
const { domain } = req.body;
@@ -272,7 +272,7 @@ router.delete(
'/:projectId/domain/:domainId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { projectId, domainId } = req.params;
const projectArr = await ProjectService.findSubprojectId(projectId);

View File

@@ -10,7 +10,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
import { sendItemResponse } from '../middlewares/response';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};
const skip = req.query.skip;
@@ -34,7 +34,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/', getUser, isUserMasterAdmin, async (req, res) => {
router.post('/', getUser, isUserMasterAdmin, async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -160,7 +160,7 @@ router.put('/:emailLogsId', getUser, isUserMasterAdmin, async function(
}
});
router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/search', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const filter = req.body.filter;
const skip = req.query.skip;
@@ -177,7 +177,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};

View File

@@ -11,7 +11,7 @@ const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
import UserService from '../services/userService';
router.post('/test', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/test', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
let data = req.body;
if (data.smtpToUse === 'customSmtp') {
@@ -80,7 +80,7 @@ router.post('/test', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -142,7 +142,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const select =

View File

@@ -15,7 +15,7 @@ const isUserOwner = require('../middlewares/project').isUserOwner;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -53,7 +53,7 @@ router.get(
'/:projectId/:templateId/reset',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const templateId = req.params.templateId;
@@ -68,7 +68,7 @@ router.get(
}
);
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const templates = await EmailTemplateService.getTemplates(projectId);
@@ -82,7 +82,7 @@ router.get(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const emailTemplateId = req.params.emailTemplateId;
const select = 'projectId subject body emailType allowedVariables';
@@ -102,7 +102,7 @@ router.put(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const Id = req.params.emailTemplateId;
@@ -118,7 +118,7 @@ router.put(
}
);
router.put('/:projectId', getUser, isAuthorized, async function(req, res) {
router.put('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = [];
const { projectId } = req.params;
@@ -180,7 +180,7 @@ router.delete(
'/:projectId/emailTemplate/:emailTemplateId',
getUser,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const emailTemplateId = req.params.emailTemplateId;

View File

@@ -36,7 +36,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const componentId = req.params.componentId;
@@ -136,7 +136,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { errorTrackerId, componentId } = req.params;
try {
const errorTracker = await ErrorTrackerService.deleteBy(
@@ -167,7 +167,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const errorTrackerId = req.params.errorTrackerId;
const select =
'componentId name slug key showQuickStart resourceCategory createdById createdAt';
@@ -211,7 +211,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { errorTrackerId, componentId } = req.params;
const data = req.body;
@@ -386,7 +386,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { skip, limit, startDate, endDate, filters } = req.body;
const errorTrackerId = req.params.errorTrackerId;
@@ -442,7 +442,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/error-events/:errorEventId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const errorEventId = req.params.errorEventId;
if (!errorEventId) {
@@ -493,7 +493,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues/:issueId/details',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const issueId = req.params.issueId;
if (!issueId) {
@@ -536,7 +536,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/issues/action',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { issueId, action } = req.body;
if (!issueId) {
@@ -722,7 +722,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/error-events',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const {
skip,
@@ -785,7 +785,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/members/:issueId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const componentId = req.params.componentId;
if (!componentId) {
@@ -863,7 +863,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/assign/:issueId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { teamMemberId } = req.body;
if (!teamMemberId) {
@@ -1011,7 +1011,7 @@ router.post(
'/:projectId/:componentId/:errorTrackerId/unassign/:issueId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { teamMemberId } = req.body;
if (!teamMemberId) {
@@ -1144,7 +1144,7 @@ router.delete(
'/:projectId/:componentId/:errorTrackerId/issue/:issueId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const componentId = req.params.componentId;
if (!componentId) {

View File

@@ -9,7 +9,7 @@ const getUser = require('../middlewares/user').getUser;
import { isAuthorized } from '../middlewares/authorization';
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
if (!req.body.feedback && !req.body.page) {
return sendErrorResponse(req, res, {

View File

@@ -10,7 +10,7 @@ const sendFileResponse = require('../middlewares/response').sendFileResponse;
// Param1: req.params-> {filename};
// Returns: response uploaded files, error message
router.get('/:filename', async function(req, res) {
router.get('/:filename', async function(req:express.Request, res: express.Response) {
try {
const file = await FileService.findOneBy({
filename: req.params.filename,

View File

@@ -12,7 +12,7 @@ router.post(
'/:projectId/gitCredential',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const {
gitUsername,
@@ -52,7 +52,7 @@ router.get(
'/:projectId/gitCredential',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { projectId } = req.params;
@@ -78,7 +78,7 @@ router.put(
'/:projectId/gitCredential/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;
const {
@@ -120,7 +120,7 @@ router.delete(
'/:projectId/gitCredential/:credentialId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { credentialId } = req.params;

View File

@@ -13,7 +13,7 @@ import twilioService from '../services/twilioService';
// Body: [{name, value}] | {name, value}
// Return: [{name, value, createdAt}] | {name, value, createdAt}
router.post('/', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
let configs;
@@ -100,7 +100,7 @@ router.post('/', getUser, isUserMasterAdmin, async function(req, res) {
// Params: [name];
// Return: [{name, value, createdAt}]
router.post('/configs', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/configs', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const names = req.body;
@@ -127,7 +127,7 @@ router.post('/configs', getUser, isUserMasterAdmin, async function(req, res) {
// Params: {name};
// Return: {name, value, createdAt}
router.get('/:name', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/:name', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const selectConfig = 'name value createdAt';
const { name } = req.params;

View File

@@ -11,7 +11,7 @@ import EscalationService from '../services/escalationService';
const router = express.Router();
router.post('/:projectId', getUser, isAuthorized, async (req, res) => {
router.post('/:projectId', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const { name, teams } = req.body;
const { projectId } = req.params;
@@ -42,7 +42,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => {
return { id: project._id, name: project.name };
@@ -67,7 +67,7 @@ router.get(
}
);
router.get('/:projectId', getUser, isAuthorized, async (req, res) => {
router.get('/:projectId', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const { projectId } = req.params;
const { skip, limit } = req.query;
@@ -84,7 +84,7 @@ router.get('/:projectId', getUser, isAuthorized, async (req, res) => {
}
});
router.put('/:projectId/:groupId', getUser, isAuthorized, async (req, res) => {
router.put('/:projectId/:groupId', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
try {
const { groupId, projectId } = req.params;
const { name, teams } = req.body;
@@ -112,7 +112,7 @@ router.delete(
'/:projectId/:groupId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { groupId, projectId } = req.params;

View File

@@ -35,7 +35,7 @@ import ErrorService from 'common-server/utils/error';
router.post(
'/data-ingestor/create-incident',
isAuthorizedService,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -53,7 +53,7 @@ router.post(
router.post(
'/data-ingestor/acknowledge-incident',
isAuthorizedService,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { incidentId, name, probeId } = req.body;
@@ -75,7 +75,7 @@ router.post(
router.post(
'/data-ingestor/resolve-incident',
isAuthorizedService,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { incidentId, name, probeId } = req.body;
@@ -97,7 +97,7 @@ router.post(
router.post(
'/data-ingestor/update-incident',
isAuthorizedService,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { data, query } = req.body;
const incident = await IncidentService.updateOneBy(query, data);
@@ -119,7 +119,7 @@ router.post(
'/:projectId/create-incident',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const incidentType = req.body.incidentType;
@@ -239,7 +239,7 @@ router.post(
'/:projectId/monitor/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { monitorId } = req.params;
// include date range
try {
@@ -325,7 +325,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { componentId, projectId } = req.params;
const incidents = await IncidentService.getComponentIncidents(
@@ -348,7 +348,7 @@ router.get(
'/:projectId/incidents/:componentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, componentId } = req.params;
@@ -431,7 +431,7 @@ router.get(
'/:projectId/incident/:incidentSlug',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
// Call the IncidentService.
try {
@@ -477,7 +477,7 @@ router.get(
'/:projectId/timeline/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { incidentId } = req.params;
@@ -512,7 +512,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -538,7 +538,7 @@ router.post(
'/:projectId/acknowledge/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user
? req.user.id === 'API'
@@ -705,7 +705,7 @@ router.post(
'/:projectId/resolve/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user
? req.user.id === 'API'
@@ -868,7 +868,7 @@ router.post(
'/:projectId/close/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
const { incidentId } = req.params;
@@ -887,7 +887,7 @@ router.put(
'/:projectId/incident/:incidentId/details',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const projectId = req.params.projectId;
const incidentId = req.params.incidentId;
const { title, description, incidentPriority } = req.body;
@@ -922,7 +922,7 @@ router.post(
'/:projectId/incident/:incidentId/message',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const incidentId = req.params.incidentId;
@@ -1303,7 +1303,7 @@ router.get(
'/:projectId/:incidentSlug/statuspages',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { incidentSlug } = req.params;
@@ -1336,7 +1336,7 @@ router.delete(
'/:projectId/incident/:incidentId/message/:incidentMessageId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { incidentId, incidentMessageId, projectId } = req.params;
const populateIncidentMessage = [
@@ -1526,7 +1526,7 @@ router.get(
'/:projectId/incident/:incidentSlug/message',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
let type = 'investigation';
if (req.query.type && req.query.type === 'internal') {
type = 'internal';
@@ -1723,7 +1723,7 @@ router.delete('/:projectId/:incidentId', getUser, isUserAdmin, async function(
}
});
router.put('/:projectId/:incidentId', getUser, async function(req, res) {
router.put('/:projectId/:incidentId', getUser, async function(req:express.Request, res: express.Response) {
try {
const { projectId, incidentId } = req.params;
const { hideIncident } = req.body;
@@ -1753,7 +1753,7 @@ router.get(
'/:projectId/resolve/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
@@ -1798,7 +1798,7 @@ router.get(
'/:projectId/acknowledge/:incidentId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;

View File

@@ -9,7 +9,7 @@ import IncidentCommunicationSlaService from '../services/incidentCommunicationSl
const router = express.Router();
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -41,7 +41,7 @@ router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { name, alertTime, duration } = req.body;
@@ -152,7 +152,7 @@ router.delete(
'/:projectId/:incidentSlaId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, incidentSlaId } = req.params;
@@ -173,7 +173,7 @@ router.get(
'/:projectId/defaultCommunicationSla',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;

View File

@@ -8,7 +8,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
const sendListResponse = require('../middlewares/response').sendListResponse;
import IncidentNoteTemplateService from '../services/incidentNoteTemplateService';
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { incidentState, incidentNote, name } = req.body;
@@ -54,7 +54,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { skip, limit } = req.query;

View File

@@ -8,7 +8,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
import IncidentPrioritiesService from '../services/incidentPrioritiesService';
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
const { projectId } = req.params;
const { skip = 0, limit = 10 } = req.query;
if (!projectId) {
@@ -35,7 +35,7 @@ router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
const { projectId } = req.params;
const { name, color } = req.body;
if (!projectId) {
@@ -69,7 +69,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.put('/:projectId', getUser, isAuthorized, async function(req, res) {
router.put('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
const { projectId } = req.params;
const { _id, name, color } = req.body;
@@ -112,7 +112,7 @@ router.put('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.delete('/:projectId', getUser, isAuthorized, async function(req, res) {
router.delete('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
const { projectId } = req.params;
const { _id } = req.body;

View File

@@ -11,7 +11,7 @@ import IncidentPrioritiesService from '../services/incidentPrioritiesService';
import { variables } from '../config/incidentDefaultSettings';
router.get('/variables', async function(req, res) {
router.get('/variables', async function(req:express.Request, res: express.Response) {
try {
return sendItemResponse(req, res, variables);
} catch (error) {
@@ -48,7 +48,7 @@ router.get('/:projectId/default', getUser, isAuthorized, async function(
});
// fetch all incident template in a project
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { skip, limit } = req.query;
@@ -85,7 +85,7 @@ router.put(
'/:projectId/:templateId/setDefault',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { projectId, templateId } = req.params;
if (!projectId)
return sendErrorResponse(req, res, {
@@ -208,7 +208,7 @@ router.delete('/:projectId/:templateId', getUser, isAuthorized, async function(
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
// description is optional

View File

@@ -13,7 +13,7 @@ router.get(
'/:projectId/all-incoming-request',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -54,7 +54,7 @@ router.post(
'/:projectId/create-request-url',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -111,7 +111,7 @@ router.put(
'/:projectId/update/:requestId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, requestId } = req.params;
const data = req.body;
@@ -168,7 +168,7 @@ router.delete(
'/:projectId/remove/:requestId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, requestId } = req.params;
@@ -184,7 +184,7 @@ router.delete(
);
// process incoming http request from post request
router.post('/:projectId/request/:requestId', async function(req, res) {
router.post('/:projectId/request/:requestId', async function(req:express.Request, res: express.Response) {
try {
// request object for use in variables
const request = {
@@ -206,7 +206,7 @@ router.post('/:projectId/request/:requestId', async function(req, res) {
});
// process incoming http request from get request
router.get('/:projectId/request/:requestId', async function(req, res) {
router.get('/:projectId/request/:requestId', async function(req:express.Request, res: express.Response) {
try {
// request object for use in variables
// request body won't be available for a get request
@@ -231,7 +231,7 @@ router.post(
'/:projectId/toggle/:requestId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, requestId } = req.params;
const data = req.body;

View File

@@ -8,7 +8,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
// Params:
// Param 1: req.headers-> {token}; req.params-> {userId}
// Returns: 200: "Invoice received"; 400: "Error"
router.post('/:userId', async function(req, res) {
router.post('/:userId', async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
let startingAfter = req.query.startingAfter;

View File

@@ -5,7 +5,7 @@ const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
//Public API to capture leads. Type is Demo or Whitepaper.
router.post('/', async function(req, res) {
router.post('/', async function(req:express.Request, res: express.Response) {
try {
const body = req.body;
const data = {};

View File

@@ -20,7 +20,7 @@ import ErrorService from 'common-server/utils/error';
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.get('/monitors', isAuthorizedLighthouse, async function(req, res) {
router.get('/monitors', isAuthorizedLighthouse, async function(req:express.Request, res: express.Response) {
try {
const monitors = await MonitorService.getUrlMonitorsNotScannedByLightHouseInPastOneDay();

View File

@@ -8,7 +8,7 @@ const getUser = require('../middlewares/user').getUser;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.get('/:userId', getUser, isAuthorized, async function(req, res) {
router.get('/:userId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
let { skip, limit } = req.query;

View File

@@ -271,7 +271,7 @@ router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
}
});
router.post('/:projectId/identityFile', async function(req, res) {
router.post('/:projectId/identityFile', async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -300,7 +300,7 @@ router.post('/:projectId/identityFile', async function(req, res) {
}
});
router.post('/:projectId/configurationFile', async function(req, res) {
router.post('/:projectId/configurationFile', async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -334,7 +334,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const { monitorId } = req.params;
@@ -495,7 +495,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const type = req.query.type;
@@ -540,7 +540,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const monitorId = req.params.monitorId;
const type = req.query.type;
@@ -580,7 +580,7 @@ router.post(
'/:projectId/monitorLogs/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const {
skip,
@@ -636,7 +636,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { monitorId, projectId } = req.params;
try {
const monitor = await MonitorService.deleteBy(
@@ -667,7 +667,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const monitorId = req.params.monitorId || req.body._id;
const data = req.body;
@@ -762,7 +762,7 @@ router.post(
'/:projectId/monitorLog/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -784,7 +784,7 @@ router.post(
'/:projectId/monitorStatuses/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -806,7 +806,7 @@ router.get(
'/:projectId/lighthouseLog/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { skip, limit, url } = req.query;
const monitorId = req.params.monitorId;
@@ -832,7 +832,7 @@ router.get(
'/:projectId/lighthouseIssue/:issueId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const selectLighthouseLogs =
'monitorId probeId data url performance accessibility bestPractices seo pwa createdAt scanning';
@@ -861,8 +861,8 @@ router.post(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function(req, res) {
return await _updateDeviceMonitorPingTime(req, res);
async function(req:express.Request, res: express.Response) {
return await _updateDeviceMonitorPingTime(req:express.Request, res: express.Response);
}
);
@@ -870,8 +870,8 @@ router.get(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function(req, res) {
return await _updateDeviceMonitorPingTime(req, res);
async function(req:express.Request, res: express.Response) {
return await _updateDeviceMonitorPingTime(req:express.Request, res: express.Response);
}
);
@@ -933,7 +933,7 @@ router.post(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.addSiteUrl(
@@ -953,7 +953,7 @@ router.delete(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.removeSiteUrl(
@@ -973,7 +973,7 @@ router.get(
'/:projectId/monitorSlaBreaches',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const select =
@@ -993,7 +993,7 @@ router.post(
'/:projectId/closeSla/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, monitorId } = req.params;
@@ -1015,7 +1015,7 @@ router.post(
'/:projectId/disableMonitor/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { monitorId } = req.params;
const select = 'disabled';
@@ -1050,7 +1050,7 @@ router.post(
'/:projectId/changeComponent/:monitorId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, monitorId } = req.params;
const { newComponentId } = req.body;
@@ -1067,7 +1067,7 @@ router.post(
);
// api to calculate time for monitorInfo (status page)
router.post('/:monitorId/calculate-time', async function(req, res) {
router.post('/:monitorId/calculate-time', async function(req:express.Request, res: express.Response) {
try {
const { monitorId } = req.params;
const { statuses, start, range } = req.body;

View File

@@ -8,7 +8,7 @@ import MonitorCriteriaService from '../services/monitorCriteriaService';
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.get('/', getUser, function(req, res) {
router.get('/', getUser, function(req:express.Request, res: express.Response) {
try {
const criteria = MonitorCriteriaService.getCriteria();
return sendItemResponse(req, res, criteria);

View File

@@ -12,7 +12,7 @@ import MonitorCustomFieldService from '../services/monitorCustomField';
const router = express.Router();
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { fieldName, fieldType, uniqueField } = req.body;
@@ -61,7 +61,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -143,7 +143,7 @@ router.delete(
'/:projectId/:customFieldId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, customFieldId } = req.params;

View File

@@ -9,7 +9,7 @@ import MonitorSlaService from '../services/monitorSlaService';
const router = express.Router();
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { limit, skip } = req.query;
@@ -39,7 +39,7 @@ router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const { name, frequency, monitorUptime } = req.body;
@@ -186,7 +186,7 @@ router.delete(
'/:projectId/:monitorSlaId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, monitorSlaId } = req.params;
@@ -205,7 +205,7 @@ router.get(
'/:projectId/defaultMonitorSla',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const selectMonSla =

View File

@@ -54,7 +54,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
}
});
router.put('/:projectId/read', getUser, isAuthorized, async function(req, res) {
router.put('/:projectId/read', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
// const notificationId = req.params.notificationId;
@@ -82,7 +82,7 @@ router.put(
'/:projectId/:notificationId/closed',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const notificationId = req.params.notificationId;
@@ -110,7 +110,7 @@ router.put(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -163,7 +163,7 @@ router.put('/:projectId/:notificationId', getUser, isAuthorized, async function(
}
});
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;

View File

@@ -24,7 +24,7 @@ router.post(
'/:projectId/:componentId/create',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const { componentId } = req.params;
@@ -104,7 +104,7 @@ router.get(
'/:projectId/tracker/:performanceTrackerId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { performanceTrackerId } = req.params;
const { slug } = req.query;
try {
@@ -152,7 +152,7 @@ router.delete(
'/:projectId/tracker/:performanceTrackerId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { performanceTrackerId } = req.params;
try {
const performanceTracker = await PerformanceTrackerService.deleteBy(
@@ -182,7 +182,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { performanceTrackerId } = req.params;
const select = 'componentId name slug key showQuickStart createdById';
@@ -229,7 +229,7 @@ router.put(
'/:projectId/remove-quickstart/:performanceTrackerId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { performanceTrackerId } = req.params;
const currentPerformanceTracker = await PerformanceTrackerService.findOneBy(
@@ -267,7 +267,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { performanceTrackerId, componentId } = req.params;
const data = req.body;
@@ -343,7 +343,7 @@ router.get(
'/:projectId/last-metrics/:performanceTrackerId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { performanceTrackerId } = req.params;
let { startDate, endDate } = req.query;

View File

@@ -14,7 +14,7 @@ import { isValidAPIKey } from '../middlewares/performanceTracker';
// Route
// Description: Receiving Performance metric data from sdk.
// Returns: response status, error message
router.post('/:appId/key/:key', isValidAPIKey, async function(req, res) {
router.post('/:appId/key/:key', isValidAPIKey, async function(req:express.Request, res: express.Response) {
try {
const { appId } = req.params;
const { incoming, outgoing, sentAt } = req.body;
@@ -41,7 +41,7 @@ router.post('/:appId/key/:key', isValidAPIKey, async function(req, res) {
});
// fetch transaction time for performance metrics
router.get('/:appId/key/:key/time', isValidAPIKey, async function(req, res) {
router.get('/:appId/key/:key/time', isValidAPIKey, async function(req:express.Request, res: express.Response) {
try {
const { appId } = req.params;
let { startDate, endDate } = req.query;
@@ -169,7 +169,7 @@ router.get('/:appId/key/:key/throughput', isValidAPIKey, async function(
}
});
router.get('/:appId/key/:key/error', isValidAPIKey, async function(req, res) {
router.get('/:appId/key/:key/error', isValidAPIKey, async function(req:express.Request, res: express.Response) {
try {
const { appId } = req.params;
let { startDate, endDate } = req.query;
@@ -233,7 +233,7 @@ router.get('/:appId/key/:key/error', isValidAPIKey, async function(req, res) {
// Route
// Description: Fetch all the Performance metrics for a particular identifier
router.get('/:appId/key/:key', isValidAPIKey, async function(req, res) {
router.get('/:appId/key/:key', isValidAPIKey, async function(req:express.Request, res: express.Response) {
try {
const { appId } = req.params;
const { type, skip, limit } = req.query;

View File

@@ -16,7 +16,7 @@ import { isAuthorized } from '../middlewares/authorization';
import multer from 'multer';
import storage from '../middlewares/upload';
router.post('/', getUser, isAuthorizedAdmin, async function(req, res) {
router.post('/', getUser, isAuthorizedAdmin, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const probe = await ProbeService.create(data);
@@ -26,7 +26,7 @@ router.post('/', getUser, isAuthorizedAdmin, async function(req, res) {
}
});
router.get('/', getUser, isAuthorizedAdmin, async function(req, res) {
router.get('/', getUser, isAuthorizedAdmin, async function(req:express.Request, res: express.Response) {
try {
const skip = req.query.skip || 0;
const limit = req.query.limit || 0;
@@ -47,7 +47,7 @@ router.get('/', getUser, isAuthorizedAdmin, async function(req, res) {
}
});
router.put('/:id', getUser, isAuthorizedAdmin, async function(req, res) {
router.put('/:id', getUser, isAuthorizedAdmin, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const probe = await ProbeService.updateOneBy(
@@ -60,7 +60,7 @@ router.put('/:id', getUser, isAuthorizedAdmin, async function(req, res) {
}
});
router.delete('/:id', getUser, isAuthorizedAdmin, async function(req, res) {
router.delete('/:id', getUser, isAuthorizedAdmin, async function(req:express.Request, res: express.Response) {
try {
const probe = await ProbeService.deleteBy({ _id: req.params.id });
return sendItemResponse(req, res, probe);
@@ -75,7 +75,7 @@ router.delete('/:id', getUser, isAuthorizedAdmin, async function(req, res) {
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/update/image', getUser, async function(req, res) {
router.put('/update/image', getUser, async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -109,7 +109,7 @@ router.put('/update/image', getUser, async function(req, res) {
}
});
router.get('/monitors', isAuthorizedProbe, async function(req, res) {
router.get('/monitors', isAuthorizedProbe, async function(req:express.Request, res: express.Response) {
try {
const monitors = await MonitorService.getProbeMonitors(
req.probe.id,
@@ -743,7 +743,7 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}
});
router.post('/setTime/:monitorId', isAuthorizedProbe, async function(req, res) {
router.post('/setTime/:monitorId', isAuthorizedProbe, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -756,7 +756,7 @@ router.post('/setTime/:monitorId', isAuthorizedProbe, async function(req, res) {
}
});
router.post('/getTime/:monitorId', isAuthorizedProbe, async function(req, res) {
router.post('/getTime/:monitorId', isAuthorizedProbe, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;

View File

@@ -26,7 +26,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, res) {
router.post('/create', getUser, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.name = data.projectName;
@@ -210,7 +210,7 @@ router.post('/create', getUser, async function(req, res) {
// Params:
// Param 1: req.headers-> {token};
// Returns: 200: [{project}]; 400: Error.
router.get('/projects', getUser, async function(req, res) {
router.get('/projects', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
// find user subprojects and parent projects
@@ -330,7 +330,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -367,7 +367,7 @@ router.put(
'/:projectId/updateBalance',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
if (!projectId) {
@@ -396,7 +396,7 @@ router.put(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
@@ -492,7 +492,7 @@ router.delete(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
@@ -554,7 +554,7 @@ router.delete(
router.delete(
'/:projectId/initScript/deleteProject',
isAuthorizedService,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
if (!projectId) {
@@ -601,7 +601,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -674,7 +674,7 @@ router.put(
'/:projectId/admin/changePlan',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -768,7 +768,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const projectName = req.body.projectName;
@@ -829,7 +829,7 @@ router.delete(
'/:projectId/user/:userId/exitProject',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
// Call the ProjectService
try {
const userId = req.user ? req.user.id : null;
@@ -911,7 +911,7 @@ router.delete(
'/:projectId/:subProjectId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const parentProjectId = req.params.projectId;
const subProjectId = req.params.subProjectId;
@@ -1032,7 +1032,7 @@ router.get('/projects/:slug', getUser, isUserMasterAdmin, async function(
}
});
router.get('/project-slug/:slug', getUser, async function(req, res) {
router.get('/project-slug/:slug', getUser, async function(req:express.Request, res: express.Response) {
try {
const { slug } = req.params;
const populate = [{ path: 'parentProjectId', select: 'name' }];
@@ -1054,7 +1054,7 @@ router.put(
'/:projectId/blockProject',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.updateOneBy(
@@ -1072,7 +1072,7 @@ router.put(
'/:projectId/renewAlertLimit',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
let limit = req.body.alertLimit;
@@ -1106,7 +1106,7 @@ router.put(
'/:projectId/unblockProject',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.updateOneBy(
@@ -1124,7 +1124,7 @@ router.put(
'/:projectId/restoreProject',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const project = await ProjectService.restoreBy({
@@ -1265,7 +1265,7 @@ router.put(
'/:projectId/advancedOptions/email',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -1322,7 +1322,7 @@ router.put(
'/:projectId/advancedOptions/sms',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const data = req.body;
@@ -1370,7 +1370,7 @@ router.put(
'/:projectId/advancedOptions/webhook',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
const data = req.body;

View File

@@ -19,7 +19,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { startDate, endDate, skip, limit } = req.query;
@@ -55,7 +55,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { startDate, endDate, skip, limit } = req.query;
@@ -91,7 +91,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { startDate, endDate, filter } = req.query;
@@ -123,7 +123,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const { startDate, endDate, filter } = req.query;

View File

@@ -73,7 +73,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const resourceCategoryId = req.params.resourceCategoryId;
const projectId = req.params.projectId;
@@ -128,7 +128,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const resourceCategoryId = req.params.resourceCategoryId;
const projectId = req.params.projectId;
@@ -174,7 +174,7 @@ router.put(
}
);
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const { limit, skip } = req.query;

View File

@@ -34,7 +34,7 @@ router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const populate = [
@@ -86,7 +86,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -148,7 +148,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, scheduleId } = req.params;
const data = req.body;
@@ -168,7 +168,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const scheduleId = req.params.scheduleId;
@@ -196,7 +196,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
@@ -217,7 +217,7 @@ router.get(
'/:projectId/:scheduleId/getescalation',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const scheduleId = req.params.scheduleId;
const response = await ScheduleService.getEscalations(scheduleId);
@@ -238,7 +238,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
try {
const userId = req.user ? req.user.id : null;
const scheduleId = req.params.scheduleId;

View File

@@ -16,7 +16,7 @@ import moment from 'moment';
import MonitorService from '../services/monitorService';
import ErrorService from 'common-server/utils/error';
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const data = req.body;
@@ -214,7 +214,7 @@ router.put(
'/:projectId/resolve/:eventId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = {};
@@ -412,7 +412,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const currentDate = moment();
// this contains both projectIds and subProjectIds
@@ -499,7 +499,7 @@ router.get('/:projectId/:eventId', getUser, isAuthorized, async function(
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;
@@ -555,7 +555,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
// this contains both projectIds and subProjectIds
@@ -576,7 +576,7 @@ router.get(
router.get(
'/:projectId/:monitorId/statusPage',
checkUserBelongToProject,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const monitorId = req.params.monitorId;
@@ -795,7 +795,7 @@ router.put(
'/:projectId/:eventId/notes/:noteId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { eventId, noteId, projectId } = req.params;
const data = req.body;
@@ -879,7 +879,7 @@ router.delete(
'/:projectId/:eventId/notes/:noteId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { eventId, noteId, projectId } = req.params;

View File

@@ -10,7 +10,7 @@ import { isAuthorizedService } from '../middlewares/serviceAuthorization';
const router = express.Router();
// get all script monitors for script-runner
router.get('/monitors', isAuthorizedService, async (req, res) => {
router.get('/monitors', isAuthorizedService, async (req:express.Request, res: express.Response) => {
try {
//get top 10 monitors.
const allScriptMonitors = await MonitorService.getScriptMonitors({
@@ -30,7 +30,7 @@ router.get('/monitors', isAuthorizedService, async (req, res) => {
});
// ping script monitor
router.post('/ping/:monitorId', isAuthorizedService, async function(req, res) {
router.post('/ping/:monitorId', isAuthorizedService, async function(req:express.Request, res: express.Response) {
try {
const { monitor, resp } = req.body;

View File

@@ -18,7 +18,7 @@ import { getSubProjects } from '../middlewares/subProject';
const router = express.Router();
router.post('/:projectId', getUser, getSubProjects, async function(req, res) {
router.post('/:projectId', getUser, getSubProjects, async function(req:express.Request, res: express.Response) {
try {
const val = req.body.search;
const parentProjectId = req.params.projectId;

View File

@@ -5,7 +5,7 @@ import { IS_SAAS_SERVICE } from '../config/server';
const sendItemResponse = require('../middlewares/response').sendItemResponse;
//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, res) {
router.get('/is-saas-service', function(req:express.Request, res: express.Response) {
if (IS_SAAS_SERVICE) {
return sendItemResponse(req, res, { result: true });
} else {
@@ -13,7 +13,7 @@ router.get('/is-saas-service', function(req, res) {
}
});
router.get('/hosts', function(req, res) {
router.get('/hosts', function(req:express.Request, res: express.Response) {
return sendItemResponse(req, res, {
api: global.apiHost,

View File

@@ -6,7 +6,7 @@ import SiteManagerService from '../services/siteManagerService';
const router = express.Router();
// store site details to the db
router.post('/site', async (req, res) => {
router.post('/site', async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -18,7 +18,7 @@ router.post('/site', async (req, res) => {
});
// update site details in the db
router.put('/site', async (req, res) => {
router.put('/site', async (req:express.Request, res: express.Response) => {
try {
const { subject } = req.query;
const site = await SiteManagerService.updateOneBy(
@@ -33,7 +33,7 @@ router.put('/site', async (req, res) => {
});
// fetch a site detail
router.get('/site', async (req, res) => {
router.get('/site', async (req:express.Request, res: express.Response) => {
try {
const { servername } = req.query;
const site = await SiteManagerService.findOneBy({
@@ -49,7 +49,7 @@ router.get('/site', async (req, res) => {
});
// fetch all sites
router.get('/sites', async (req, res) => {
router.get('/sites', async (req:express.Request, res: express.Response) => {
try {
const sites = await SiteManagerService.findBy({
query: {},
@@ -63,7 +63,7 @@ router.get('/sites', async (req, res) => {
});
// fetch all sites by servernames
router.post('/site/servernames', async (req, res) => {
router.post('/site/servernames', async (req:express.Request, res: express.Response) => {
try {
const { servernames = [] } = req.body;
const sites = await SiteManagerService.findBy({
@@ -78,7 +78,7 @@ router.post('/site/servernames', async (req, res) => {
});
// fetch sites base on the options
router.post('/site/opts', async (req, res) => {
router.post('/site/opts', async (req:express.Request, res: express.Response) => {
try {
const { issuedBefore, expiresBefore, renewBefore } = req.body;
const query = { $or: [] };
@@ -118,7 +118,7 @@ router.post('/site/opts', async (req, res) => {
});
// delete an site detail
router.delete('/site', async (req, res) => {
router.delete('/site', async (req:express.Request, res: express.Response) => {
try {
const { subject } = req.query; // still handle this for legacy code
const { domains } = req.body;

View File

@@ -16,7 +16,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
const router = express.Router();
router.get('/auth/redirect', function(req, res) {
router.get('/auth/redirect', function(req:express.Request, res: express.Response) {
// get oneuptime project id from slack auth state query params
let state = req.query.state;
const slackCode = req.query.code;
@@ -61,7 +61,7 @@ router.get('/auth/redirect', function(req, res) {
});
});
router.post('/:projectId/link', getUser, isUserAdmin, async function(req, res) {
router.post('/:projectId/link', getUser, isUserAdmin, async function(req:express.Request, res: express.Response) {
const projectId = req.params.projectId;
const code = req.query.code;
@@ -135,7 +135,7 @@ router.delete(
'/:projectId/unLink/:teamId',
getUser,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const projectId = req.params.projectId;
const teamId = req.params.teamId;
@@ -160,7 +160,7 @@ router.delete(
);
// req => params => {projectId}
router.get('/:projectId/teams', getUser, async function(req, res) {
router.get('/:projectId/teams', getUser, async function(req:express.Request, res: express.Response) {
const projectId = req.params.projectId;
const integrationType = 'slack';

View File

@@ -10,7 +10,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
import { sendItemResponse } from '../middlewares/response';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const selectSmsCount =
'userId sentTo createdAt projectId parentProjectId deleted deletedAt deletedById content status error';
@@ -32,7 +32,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/', getUser, isUserMasterAdmin, async (req, res) => {
router.post('/', getUser, isUserMasterAdmin, async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -83,7 +83,7 @@ router.post('/', getUser, isUserMasterAdmin, async (req, res) => {
}
});
router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/search', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const filter = req.body.filter;
const skip = req.query.skip;
@@ -100,7 +100,7 @@ router.post('/search', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const query = {};

View File

@@ -9,7 +9,7 @@ const isUserOwner = require('../middlewares/project').isUserOwner;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -43,7 +43,7 @@ router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
}
});
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const populate = [{ path: 'projectId', select: 'name' }];

View File

@@ -15,7 +15,7 @@ const isUserOwner = require('../middlewares/project').isUserOwner;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.post('/:projectId', getUser, isAuthorized, async function(req, res) {
router.post('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -39,7 +39,7 @@ router.get(
'/:projectId/:templateId/reset',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const templateId = req.params.templateId;
@@ -52,7 +52,7 @@ router.get(
}
);
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const templates = await SmsTemplateService.getTemplates(projectId);
@@ -66,7 +66,7 @@ router.get(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const smsTemplateId = req.params.smsTemplateId;
const populate = [{ path: 'projectId', select: 'name' }];
@@ -87,7 +87,7 @@ router.put(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const smsTemplateId = req.params.smsTemplateId;
@@ -104,7 +104,7 @@ router.put(
}
);
router.put('/:projectId', getUser, isAuthorized, async function(req, res) {
router.put('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const data = [];
const { projectId } = req.params;
@@ -146,7 +146,7 @@ router.delete(
'/:projectId/smsTemplate/:smsTemplateId',
getUser,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const smsTemplateId = req.params.smsTemplateId;

View File

@@ -6,7 +6,7 @@ import SslService from '../services/sslService';
const router = express.Router();
// store acme challenge to the db
router.post('/challenge', async (req, res) => {
router.post('/challenge', async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
@@ -18,7 +18,7 @@ router.post('/challenge', async (req, res) => {
});
// fetch an acme challenge
router.get('/challenge/:token', async (req, res) => {
router.get('/challenge/:token', async (req:express.Request, res: express.Response) => {
try {
const { token } = req.params;
const acmeChallenge = await SslService.findOneBy({
@@ -34,7 +34,7 @@ router.get('/challenge/:token', async (req, res) => {
// fetch keyAuthorization for a token
// api to be consumed from the statuspage
router.get('/challenge/authorization/:token', async (req, res) => {
router.get('/challenge/authorization/:token', async (req:express.Request, res: express.Response) => {
try {
const { token } = req.params;
const acmeChallenge = await SslService.findOneBy({
@@ -51,7 +51,7 @@ router.get('/challenge/authorization/:token', async (req, res) => {
});
// delete an acme challenge
router.delete('/challenge/:token', async (req, res) => {
router.delete('/challenge/:token', async (req:express.Request, res: express.Response) => {
try {
const { token } = req.params;

View File

@@ -9,7 +9,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
import SsoService from '../services/ssoService';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
const skip = req.query.skip || 0;
const limit = req.query.limit || 10;
@@ -28,7 +28,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/:id', getUser, async function(req, res) {
router.delete('/:id', getUser, async function(req:express.Request, res: express.Response) {
try {
const sso = await SsoService.deleteBy({ _id: req.params.id });
return sendItemResponse(req, res, sso);
@@ -37,7 +37,7 @@ router.delete('/:id', getUser, async function(req, res) {
}
});
router.post('/', getUser, isScaleOrMasterAdmin, async function(req, res) {
router.post('/', getUser, isScaleOrMasterAdmin, async function(req:express.Request, res: express.Response) {
const data = req.body;
try {
const sso = await SsoService.create(data);
@@ -47,7 +47,7 @@ router.post('/', getUser, isScaleOrMasterAdmin, async function(req, res) {
}
});
router.get('/:id', getUser, async function(req, res) {
router.get('/:id', getUser, async function(req:express.Request, res: express.Response) {
try {
const selectSso =
'_id saml-enabled domain entityId remoteLoginUrl certificateFingerprint remoteLogoutUrl ipRanges createdAt deleted deletedAt deletedById samlSsoUrl projectId';
@@ -62,7 +62,7 @@ router.get('/:id', getUser, async function(req, res) {
}
});
router.put('/:id', getUser, async function(req, res) {
router.put('/:id', getUser, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const sso = await SsoService.updateBy({ _id: req.params.id }, data);

View File

@@ -7,7 +7,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
import SsoDefaultRolesService from '../services/ssoDefaultRolesService';
router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
const skip = req.query.skip || 0;
const limit = req.query.limit || 10;
@@ -36,7 +36,7 @@ router.get('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.delete('/:id', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/:id', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
if (!req.params.id) throw new Error('Id must be defined');
const sso = await SsoDefaultRolesService.deleteBy({
@@ -48,7 +48,7 @@ router.delete('/:id', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.post('/', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
const data = req.body;
try {
const ssoDefaultRole = await SsoDefaultRolesService.create(data);
@@ -58,7 +58,7 @@ router.post('/', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.get('/:id', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/:id', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const populateDefaultRoleSso = [
{ path: 'domain', select: '_id domain' },
@@ -84,7 +84,7 @@ router.get('/:id', getUser, isUserMasterAdmin, async function(req, res) {
}
});
router.put('/:id', getUser, isUserMasterAdmin, async function(req, res) {
router.put('/:id', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const id = req.params.id;
const ssoDefaultRole = await SsoDefaultRolesService.updateById(

View File

@@ -67,7 +67,7 @@ ApiBase({
});
//fetch tweets from user twitter handle
router.post('/:projectId/tweets', checkUser, async (req, res) => {
router.post('/:projectId/tweets', checkUser, async (req:express.Request, res: express.Response) => {
try {
let { handle } = req.body;
@@ -98,7 +98,7 @@ router.put(
'/:projectId/:statusPageId/resetBubbleId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { projectId, statusPageId } = req.params;
const newStatusBubbleId = uuid.v4();
try {
@@ -150,7 +150,7 @@ router.put(
}
);
router.put('/:projectId/theme', getUser, isAuthorized, async (req, res) => {
router.put('/:projectId/theme', getUser, isAuthorized, async (req:express.Request, res: express.Response) => {
const { projectId } = req.params;
const { theme, statusPageId } = req.body;
try {
@@ -207,7 +207,7 @@ router.put(
'/:projectId/:statusPageId/domain',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { projectId, statusPageId } = req.params;
const {
domain: subDomain,
@@ -276,7 +276,7 @@ router.put(
'/:projectId/:statusPageId/resetColors',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { projectId, statusPageId } = req.params;
const defaultBrandColor = defaultStatusPageColors.default;
try {
@@ -305,7 +305,7 @@ router.put(
'/:projectId/:statusPageId/:domainId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { projectId, statusPageId, domainId } = req.params;
const {
domain: newDomain,
@@ -348,7 +348,7 @@ router.put(
}
);
router.post('/:projectId/certFile', async function(req, res) {
router.post('/:projectId/certFile', async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -374,7 +374,7 @@ router.post('/:projectId/certFile', async function(req, res) {
}
});
router.post('/:projectId/privateKeyFile', async function(req, res) {
router.post('/:projectId/privateKeyFile', async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -405,7 +405,7 @@ router.post('/:projectId/privateKeyFile', async function(req, res) {
// fetch details about a custom domain
// to be consumed by the status page
router.get('/tlsCredential', async function(req, res) {
router.get('/tlsCredential', async function(req:express.Request, res: express.Response) {
try {
const { domain } = req.query;
@@ -466,7 +466,7 @@ router.delete(
'/:projectId/:statusPageId/:domainId',
getUser,
isAuthorized,
async (req, res) => {
async (req:express.Request, res: express.Response) => {
const { statusPageId, domainId } = req.params;
try {
@@ -681,7 +681,7 @@ router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
});
});
router.get('/statusBubble', async function(req, res) {
router.get('/statusBubble', async function(req:express.Request, res: express.Response) {
const statusPageId = req.query.statusPageId;
const statusBubbleId = req.query.statusBubbleId;
try {
@@ -945,7 +945,7 @@ router.post(
'/:projectId/:statusPageSlug/duplicateStatusPage',
getUser,
isAuthorized,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, statusPageSlug } = req.params;
const { subProjectId } = req.query;
@@ -979,7 +979,7 @@ router.post(
}
);
router.get('/:statusPageId/rss', checkUser, async function(req, res) {
router.get('/:statusPageId/rss', checkUser, async function(req:express.Request, res: express.Response) {
const statusPageId = req.params.statusPageId;
const url = req.query.url;
@@ -1084,7 +1084,7 @@ router.get(
'/:projectId/:statusPageSlug/notes',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
let result;
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
@@ -1255,7 +1255,7 @@ router.get(
'/:projectId/:statusPageSlug/events',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
const limit = req.query.limit || 5;
@@ -1287,7 +1287,7 @@ router.get(
'/:projectId/:statusPageSlug/futureEvents',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1312,7 +1312,7 @@ router.get(
'/:projectId/:statusPageSlug/pastEvents',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1440,7 +1440,7 @@ router.get('/:projectId/:monitorId/individualevents', checkUser, async function(
router.get(
'/:projectId/scheduledEvent/:scheduledEventId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const { scheduledEventId } = req.params;
try {
@@ -1517,7 +1517,7 @@ router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function(
}
});
router.get('/:projectId/probes', checkUser, async function(req, res) {
router.get('/:projectId/probes', checkUser, async function(req:express.Request, res: express.Response) {
try {
const skip = req.query.skip || 0;
const limit = req.query.limit || 0;
@@ -1543,7 +1543,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const statusPageSlug = req.params.statusPageSlug;
const userId = req.user ? req.user.id : null;
@@ -1601,7 +1601,7 @@ router.get(
'/:projectId/:statusPageSlug/timelines',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -1673,7 +1673,7 @@ router.get('/:projectId/monitor/:statusPageId', checkUser, async function(
router.post(
'/:projectId/createExternalstatus-page/:statusPageId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, statusPageId } = req.params;
const { name, url } = req.body;
@@ -1788,7 +1788,7 @@ router.post(
router.post(
'/:projectId/updateExternalstatus-page/:externalStatusPageId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, externalStatusPageId } = req.params;
const { name, url } = req.body;
@@ -1882,7 +1882,7 @@ router.post(
router.get(
'/:projectId/fetchExternalStatusPages/:statusPageId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, statusPageId } = req.params;
@@ -1916,7 +1916,7 @@ router.get(
router.post(
'/:projectId/deleteExternalstatus-page/:externalStatusPageId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, externalStatusPageId } = req.params;
@@ -2002,7 +2002,7 @@ router.post('/:projectId/announcement/:statusPageId', checkUser, async function(
router.put(
'/:projectId/announcement/:statusPageId/:announcementId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, statusPageId, announcementId } = req.params;
const { data } = req.body;
@@ -2088,7 +2088,7 @@ router.put(
router.get(
'/:projectId/announcementLogs/:statusPageId',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageId } = req.params;
const { skip, limit, theme } = req.query;
@@ -2158,7 +2158,7 @@ router.get('/:projectId/announcement/:statusPageId', checkUser, async function(
router.get(
'/:projectId/announcement/:statusPageSlug/single/:announcementSlug',
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, statusPageSlug, announcementSlug } = req.params;
@@ -2181,7 +2181,7 @@ router.get(
router.delete(
`/:projectId/announcement/:announcementId/delete`,
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId, announcementId } = req.params;
@@ -2203,7 +2203,7 @@ router.delete(
router.delete(
`/:projectId/announcementLog/:announcementLogId/delete`,
checkUser,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { announcementLogId } = req.params;
@@ -2294,7 +2294,7 @@ router.get(
'/resources/:statusPageSlug/ongoing-events',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2322,7 +2322,7 @@ router.get(
'/resources/:statusPageSlug/future-events',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2346,7 +2346,7 @@ router.get(
'/resources/:statusPageSlug/past-events',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2370,7 +2370,7 @@ router.get(
'/resources/:statusPageSlug/probes',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2394,7 +2394,7 @@ router.get(
'/resources/:statusPageSlug/monitor-logs',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2418,7 +2418,7 @@ router.get(
'/resources/:statusPageSlug/announcements',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2448,7 +2448,7 @@ router.get(
'/resources/:statusPageSlug/announcement-logs',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2472,7 +2472,7 @@ router.get(
'/resources/:statusPageSlug/monitor-timelines',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2496,7 +2496,7 @@ router.get(
'/resources/:statusPageSlug/statuspage-notes',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
@@ -2526,7 +2526,7 @@ router.get(
'/resources/:statusPageSlug/monitor-statuses',
checkUser,
ipWhitelist,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageSlug } = req.params;
const { range } = req.query;

View File

@@ -14,7 +14,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageCategoryName } = req.body;
const { statusPageId } = req.params;
@@ -66,7 +66,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageCategoryId } = req.params;
@@ -105,7 +105,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { statusPageCategoryId } = req.params;
const { statusPageCategoryName } = req.body;

View File

@@ -19,7 +19,7 @@ const router = express.Router();
// Params:
// Param 1: webhookURL
// Returns: 200: Event object with various status.
router.post('/events', async function(req, res) {
router.post('/events', async function(req:express.Request, res: express.Response) {
try {
const event = req.body;
const customerId = event.data.object.customer;
@@ -55,13 +55,13 @@ router.post('/events', async function(req, res) {
return sendItemResponse(req, res, response);
}
return sendEmptyResponse(req, res);
return sendEmptyResponse(req:express.Request, res: express.Response);
} catch (error) {
return sendErrorResponse(req, res, error);
}
});
router.get('/:userId/charges', getUser, async function(req, res) {
router.get('/:userId/charges', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user.id;
if (userId) {
@@ -77,7 +77,7 @@ router.get('/:userId/charges', getUser, async function(req, res) {
}
});
router.post('/:userId/creditCard/:token/pi', getUser, async function(req, res) {
router.post('/:userId/creditCard/:token/pi', getUser, async function(req:express.Request, res: express.Response) {
try {
const { token } = req.params;
@@ -95,7 +95,7 @@ router.post('/:userId/creditCard/:token/pi', getUser, async function(req, res) {
}
});
router.put('/:userId/creditCard/:cardId', getUser, async function(req, res) {
router.put('/:userId/creditCard/:cardId', getUser, async function(req:express.Request, res: express.Response) {
try {
const { cardId } = req.params;
@@ -113,7 +113,7 @@ router.put('/:userId/creditCard/:cardId', getUser, async function(req, res) {
}
});
router.delete('/:userId/creditCard/:cardId', getUser, async function(req, res) {
router.delete('/:userId/creditCard/:cardId', getUser, async function(req:express.Request, res: express.Response) {
try {
const { cardId } = req.params;
@@ -131,7 +131,7 @@ router.delete('/:userId/creditCard/:cardId', getUser, async function(req, res) {
}
});
router.get('/:userId/creditCard', getUser, async function(req, res) {
router.get('/:userId/creditCard', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user.id;
if (userId) {
@@ -147,7 +147,7 @@ router.get('/:userId/creditCard', getUser, async function(req, res) {
}
});
router.get('/:userId/creditCard/:cardId', getUser, async function(req, res) {
router.get('/:userId/creditCard/:cardId', getUser, async function(req:express.Request, res: express.Response) {
try {
const { cardId } = req.params;
@@ -170,7 +170,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
const { projectId } = req.params;
@@ -195,7 +195,7 @@ router.post(
}
);
router.post('/checkCard', async function(req, res) {
router.post('/checkCard', async function(req:express.Request, res: express.Response) {
try {
const { tokenId, email, companyName } = req.body;
const paymentIntent = await StripeService.makeTestCharge(
@@ -214,7 +214,7 @@ router.get(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { intentId } = req.params;
@@ -244,7 +244,7 @@ router.post(
getUser,
isAuthorized,
isUserOwner,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const { projectId } = req.params;

View File

@@ -14,7 +14,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
// req.params->{projectId}; req.body -> {monitorIds, alertVia, contactEmail, contactPhone, }
// Returns: response status page, error message
router.post('/:projectId/:statusPageId', async function(req, res) {
router.post('/:projectId/:statusPageId', async function(req:express.Request, res: express.Response) {
try {
const body = req.body;
const data = {};
@@ -154,7 +154,7 @@ router.post('/:projectId/:statusPageId', async function(req, res) {
}
});
router.post('/:projectId/subscribe/:monitorId', async function(req, res) {
router.post('/:projectId/subscribe/:monitorId', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -300,7 +300,7 @@ router.post('/:projectId/subscribe/:monitorId', async function(req, res) {
// get subscribers by projectId
// req.params-> {projectId};
// Returns: response subscriber, error message
router.get('/:projectId', async function(req, res) {
router.get('/:projectId', async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const skip = req.query.skip || 0;
@@ -321,7 +321,7 @@ router.get('/:projectId', async function(req, res) {
//get subscribers by monitorId
// req.params-> {projectId, monitorId};
// Returns: response subscriber, error message
router.get('/:projectId/monitor/:monitorId', async function(req, res) {
router.get('/:projectId/monitor/:monitorId', async function(req:express.Request, res: express.Response) {
try {
const monitorId = req.params.monitorId;
const skip = req.query.skip || 0;
@@ -352,7 +352,7 @@ router.get('/:projectId/monitor/:monitorId', async function(req, res) {
//get monitors by subscriberId
// req.params-> {subscriberId};
// Returns: response subscriber, error message
router.get('/monitorList/:subscriberId', async function(req, res) {
router.get('/monitorList/:subscriberId', async function(req:express.Request, res: express.Response) {
try {
const subscriberId = req.params.subscriberId;
@@ -405,7 +405,7 @@ router.get('/monitorList/:subscriberId', async function(req, res) {
//Get a subscriber.
//req.params-> {projectId, subscriberId}
// Returns: response subscriber, error message
router.get('/:projectId/:subscriberId', async function(req, res) {
router.get('/:projectId/:subscriberId', async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const subscriberId = req.params.subscriberId;
@@ -429,7 +429,7 @@ router.get('/:projectId/:subscriberId', async function(req, res) {
//unsubscribe subscriber.
//req.params-> {monitorId, subscriberId}
// Returns: response subscriber, error message
router.put('/unsubscribe/:monitorId/:email', async function(req, res) {
router.put('/unsubscribe/:monitorId/:email', async function(req:express.Request, res: express.Response) {
try {
const { email, monitorId } = req.params;
const subscriber = await SubscriberService.updateOneBy(
@@ -444,7 +444,7 @@ router.put('/unsubscribe/:monitorId/:email', async function(req, res) {
// delete a subscriber.
// req.params-> {projectId, subscriberId}
// Returns: response subscriber, error message
router.delete('/:projectId/:subscriberId', getUser, async function(req, res) {
router.delete('/:projectId/:subscriberId', getUser, async function(req:express.Request, res: express.Response) {
try {
const subscriberId = req.params.subscriberId;
@@ -459,7 +459,7 @@ router.delete('/:projectId/:subscriberId', getUser, async function(req, res) {
}
});
router.post('/:projectId/:monitorId/csv', async function(req, res) {
router.post('/:projectId/:monitorId/csv', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
data.projectId = req.params.projectId;

View File

@@ -10,7 +10,7 @@ const sendListResponse = require('../middlewares/response').sendListResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
import IncidentService from '../services/incidentService';
router.post('/:projectId/:subscriberId', async (req, res) => {
router.post('/:projectId/:subscriberId', async (req:express.Request, res: express.Response) => {
try {
const data = req.body;
data.projectId = req.params.projectId;
@@ -37,7 +37,7 @@ router.post('/:projectId/:subscriberId', async (req, res) => {
});
// Mark alert as viewed
router.get('/:projectId/:alertId/viewed', async function(req, res) {
router.get('/:projectId/:alertId/viewed', async function(req:express.Request, res: express.Response) {
try {
const alertId = req.params.alertId;
const projectId = req.params.projectId;
@@ -67,7 +67,7 @@ router.get('/:projectId/:alertId/viewed', async function(req, res) {
// get subscribers alerts by projectId
// req.params-> {projectId};
// Returns: response subscriber alerts, error message
router.get('/:projectId', async (req, res) => {
router.get('/:projectId', async (req:express.Request, res: express.Response) => {
try {
const projectId = req.params.projectId;
const skip = req.query.skip || 0;
@@ -104,7 +104,7 @@ router.get('/:projectId', async (req, res) => {
//get subscribers by incidentSlug
// req.params-> {projectId, incidentSlug};
// Returns: response subscriber alerts, error message
router.get('/:projectId/incident/:incidentSlug', async (req, res) => {
router.get('/:projectId/incident/:incidentSlug', async (req:express.Request, res: express.Response) => {
try {
const projectId = req.params.projectId;
const incidentSlug = req.params.incidentSlug;

View File

@@ -18,7 +18,7 @@ import ErrorService from 'common-server/utils/error';
// Params:
// Param 1: req.headers-> {token}; req.params-> {projectId}; req.user-> {id}
// Returns: 200: An array of users belonging to the project.
router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
router.get('/:projectId', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
const projectId = req.params.projectId;
try {
@@ -35,7 +35,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const subProjectIds = req.user.subProjects
? req.user.subProjects.map((project: $TSFixMe) => project._id)
: null;
@@ -210,7 +210,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const userId = req.user ? req.user.id : null;
const teamMemberUserId = req.params.teamMemberId;
const projectId = req.params.projectId;
@@ -255,7 +255,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
const data = req.body;
const projectId = req.params.projectId;
data.teamMemberId = req.params.teamMemberId;

View File

@@ -13,7 +13,7 @@ const sendItemResponse = require('../middlewares/response').sendItemResponse;
// jwtAccessToken: token.accessToken,
// jwtRefreshToken: token.refreshToken,
// }
router.post('/new', async function(req, res) {
router.post('/new', async function(req:express.Request, res: express.Response) {
try {
const jwtRefreshToken = req.body.refreshToken;

View File

@@ -7,7 +7,7 @@ const getUser = require('../middlewares/user').getUser;
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.get('/', getUser, async function(req, res) {
router.get('/', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
const user = await UserService.findOneBy({
@@ -25,7 +25,7 @@ router.get('/', getUser, async function(req, res) {
}
});
router.put('/', getUser, async function(req, res) {
router.put('/', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
let user = await UserService.findOneBy({

View File

@@ -22,7 +22,7 @@ import SmsCountService from '../services/smsCountService';
* @returns Twiml with 'Content-Type', 'text/xml' in headers for twilio to understand.
*/
router.get('/voice/status', async (req, res) => {
router.get('/voice/status', async (req:express.Request, res: express.Response) => {
try {
const {
accessToken,
@@ -130,7 +130,7 @@ router.post('/sms/sendVerificationToken', getUser, isAuthorized, async function(
}
});
router.post('/sms/verify', getUser, isAuthorized, async function(req, res) {
router.post('/sms/verify', getUser, isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { to, code } = req.body;
@@ -180,7 +180,7 @@ router.post('/sms/verify', getUser, isAuthorized, async function(req, res) {
}
});
router.post('/sms/test', getUser, isUserMasterAdmin, async function(req, res) {
router.post('/sms/test', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;

View File

@@ -33,7 +33,7 @@ import SsoDefaultRolesService from '../services/ssoDefaultRolesService';
const isUserMasterAdmin = require('../middlewares/user').isUserMasterAdmin;
import Ip from '../middlewares/ipHandler';
router.post('/signup', async function(req, res) {
router.post('/signup', async function(req:express.Request, res: express.Response) {
try {
if (
typeof process.env.DISABLE_SIGNUP === 'string' &&
@@ -293,7 +293,7 @@ router.post('/signup', async function(req, res) {
}
});
router.get('/masterAdminExists', async function(req, res) {
router.get('/masterAdminExists', async function(req:express.Request, res: express.Response) {
try {
const masterAdmin = await UserService.findBy({
query: { role: 'master-admin' },
@@ -315,7 +315,7 @@ router.get('/masterAdminExists', async function(req, res) {
// Params:
// Param 1: req.query-> {email }
// Returns: 400: Error; 500: Server Error; 200: redirect to login page
router.get('/sso/login', async function(req, res) {
router.get('/sso/login', async function(req:express.Request, res: express.Response) {
const { email } = req.query;
if (!email) {
return sendErrorResponse(req, res, {
@@ -381,7 +381,7 @@ router.get('/sso/login', async function(req, res) {
// Route
// Description: Callback function after SSO authentication page
// param: query->{domain}
router.post('/sso/callback', async function(req, res) {
router.post('/sso/callback', async function(req:express.Request, res: express.Response) {
const options = {
request_body: req.body,
allow_unencrypted_assertion: true,
@@ -534,7 +534,7 @@ router.post('/sso/callback', async function(req, res) {
// Params:
// Param 1: req.body-> {email, password }
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/login', async function(req, res) {
router.post('/login', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const clientIP = Ip.getClientIp(req)[0];
@@ -611,7 +611,7 @@ router.post('/login', async function(req, res) {
// Params:
// Param 1: req.body-> {token}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/totp/verifyToken', async function(req, res) {
router.post('/totp/verifyToken', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
const token = data.token;
@@ -677,7 +677,7 @@ router.post('/totp/verifyToken', async function(req, res) {
// Params:
// Param 1: req.body-> {code}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/verify/backupCode', async function(req, res) {
router.post('/verify/backupCode', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
// Call the UserService
@@ -761,7 +761,7 @@ router.post('/verify/backupCode', async function(req, res) {
// Params:
// None
// Return: return the new list of backup codes.
router.post('/generate/backupCode', getUser, async function(req, res) {
router.post('/generate/backupCode', getUser, async function(req:express.Request, res: express.Response) {
const userId = req.user.id || null;
const user = await UserService.findOneBy({
query: { _id: userId },
@@ -812,7 +812,7 @@ router.post('/generate/backupCode', getUser, async function(req, res) {
// Params:
// Param 1: req.params-> {userId}
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/totp/token/:userId', async function(req, res) {
router.post('/totp/token/:userId', async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
const user = await UserService.findOneBy({
@@ -844,7 +844,7 @@ router.post('/totp/token/:userId', async function(req, res) {
// 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, res) {
router.post('/forgot-password', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -885,7 +885,7 @@ router.post('/forgot-password', async function(req, res) {
// 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, res) {
router.post('/reset-password', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -945,7 +945,7 @@ router.post('/reset-password', async function(req, res) {
// Params:
// Param 1: req.body-> {email, password }
// Returns: 400: Error; 500: Server Error; 200: user
router.post('/isInvited', async function(req, res) {
router.post('/isInvited', async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -971,7 +971,7 @@ router.post('/isInvited', async function(req, res) {
});
// I used to validate token given to redirected urls such as status page
router.post('/isAuthenticated', getUser, async (req, res) => {
router.post('/isAuthenticated', getUser, async (req:express.Request, res: express.Response) => {
// request will get here if user is authenticated.
return sendItemResponse(req, res, { authenticated: true, user: req.user });
@@ -982,7 +982,7 @@ router.post('/isAuthenticated', getUser, async (req, res) => {
// 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, res) {
router.put('/profile', getUser, async function(req:express.Request, res: express.Response) {
try {
const upload = multer({
storage,
@@ -1033,7 +1033,7 @@ router.put('/profile', getUser, async function(req, res) {
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/push-notification', getUser, async function(req, res) {
router.put('/push-notification', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
const data = req.body;
@@ -1049,7 +1049,7 @@ router.put('/push-notification', getUser, async function(req, res) {
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/:userId/2fa', isUserMasterAdmin, async function(req, res) {
router.put('/:userId/2fa', isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const { userId } = req.params;
const data = req.body;
@@ -1115,7 +1115,7 @@ router.put('/profile/:userId', getUser, isUserMasterAdmin, async function(
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id}; req.files-> {profilePic}; req.data- {currentPassword, newPassword, confirmPassword}
// Returns: 200: Success, 400: Error; 500: Server Error.
router.put('/changePassword', getUser, async function(req, res) {
router.put('/changePassword', getUser, async function(req:express.Request, res: express.Response) {
try {
const data = req.body;
@@ -1207,7 +1207,7 @@ router.put('/changePassword', getUser, async function(req, res) {
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 500: Server Error.
router.get('/profile', getUser, async function(req, res) {
router.get('/profile', getUser, async function(req:express.Request, res: express.Response) {
try {
const userId = req.user ? req.user.id : null;
@@ -1264,7 +1264,7 @@ router.get('/profile', getUser, async function(req, res) {
}
});
router.get('/confirmation/:token', async function(req, res) {
router.get('/confirmation/:token', async function(req:express.Request, res: express.Response) {
try {
if (req.params && req.params.token) {
const token = await VerificationTokenModel.findOne({
@@ -1319,7 +1319,7 @@ router.get('/confirmation/:token', async function(req, res) {
}
});
router.post('/resend', async function(req, res) {
router.post('/resend', async function(req:express.Request, res: express.Response) {
if (req.body && req.body.email) {
const { email, userId } = req.body;
let user;
@@ -1367,7 +1367,7 @@ router.post('/resend', async function(req, res) {
}
});
router.get('/users', getUser, isUserMasterAdmin, async function(req, res) {
router.get('/users', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const skip = req.query.skip || 0;
const limit = req.query.limit || 10;
@@ -1403,7 +1403,7 @@ router.get('/users/:userId', getUser, isUserMasterAdmin, async function(
}
});
router.delete('/:userId', getUser, isUserMasterAdmin, async function(req, res) {
router.delete('/:userId', getUser, isUserMasterAdmin, async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
@@ -1512,7 +1512,7 @@ router.post(
'/:userId/switchToAdminMode',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
@@ -1546,7 +1546,7 @@ router.post(
'/:userId/exitAdminMode',
getUser,
isUserMasterAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const userId = req.params.userId;
@@ -1658,7 +1658,7 @@ router.post('/users/search', getUser, isUserMasterAdmin, async function(
// Params:
// Param 1: req.headers-> {authorization}; req.user-> {id};
// Returns: 200: Success, 400: Error; 401: Unauthorized; 500: Server Error.
router.delete('/:userId/delete', getUser, async function(req, res) {
router.delete('/:userId/delete', getUser, async function(req:express.Request, res: express.Response) {
try {
if (req.params.userId !== req.user.id) {
return sendErrorResponse(req, res, {
@@ -1735,7 +1735,7 @@ router.delete('/:userId/delete', getUser, async function(req, res) {
}
});
router.get('/:token/email', async function(req, res) {
router.get('/:token/email', async function(req:express.Request, res: express.Response) {
try {
const token = await VerificationTokenModel.findOne({
token: req.params.token,

View File

@@ -4,7 +4,7 @@ const router = express.Router();
const sendErrorResponse = require('../middlewares/response').sendErrorResponse;
const sendItemResponse = require('../middlewares/response').sendItemResponse;
router.get('/', function(req, res) {
router.get('/', function(req:express.Request, res: express.Response) {
try {
return sendItemResponse(req, res, {
server: process.env.npm_package_version,

View File

@@ -249,7 +249,7 @@ router.delete(
'/:projectId/delete/:integrationId',
getUser,
isUserAdmin,
async function(req, res) {
async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const integrationId = req.params.integrationId;
@@ -267,7 +267,7 @@ router.delete(
);
// req => params => {projectId}
router.get('/:projectId/hooks', getUser, async function(req, res) {
router.get('/:projectId/hooks', getUser, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.params.projectId;
const integrationType = req.query.type || 'webhook';
@@ -300,7 +300,7 @@ router.get('/:projectId/hooks', getUser, async function(req, res) {
});
// req => params => {projectId, monitorId}
router.get('/:projectId/hooks/:monitorId', getUser, async function(req, res) {
router.get('/:projectId/hooks/:monitorId', getUser, async function(req:express.Request, res: express.Response) {
try {
// const projectId = req.params.projectId;
const integrationType = req.query.type || 'webhook';

View File

@@ -10,7 +10,7 @@ const sendEmptyResponse = require('../middlewares/response').sendEmptyResponse;
const router = express.Router();
router.get('/test', isAuthorized, async function(req, res) {
router.get('/test', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const apiKey = req.query.apiKey;
const projectId = req.query.projectId;
@@ -21,7 +21,7 @@ router.get('/test', isAuthorized, async function(req, res) {
}
});
router.get('/monitors', isAuthorized, async function(req, res) {
router.get('/monitors', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const projectId = req.query.projectId;
@@ -51,7 +51,7 @@ router.get('/monitors', isAuthorized, async function(req, res) {
}
});
router.post('/incident/createIncident', isAuthorized, async function(req, res) {
router.post('/incident/createIncident', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const monitors = req.body.monitors || [];
const incident = await ZapierService.createIncident(monitors);
@@ -61,7 +61,7 @@ router.post('/incident/createIncident', isAuthorized, async function(req, res) {
}
});
router.get('/incidents', isAuthorized, async function(req, res) {
router.get('/incidents', isAuthorized, async function(req:express.Request, res: express.Response) {
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.
@@ -73,7 +73,7 @@ router.get('/incidents', isAuthorized, async function(req, res) {
}
});
router.get('/incident-note', isAuthorized, async function(req, res) {
router.get('/incident-note', isAuthorized, async function(req:express.Request, res: express.Response) {
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.
@@ -85,7 +85,7 @@ router.get('/incident-note', isAuthorized, async function(req, res) {
}
});
router.post('/incident/incident-note', isAuthorized, async function(req, res) {
router.post('/incident/incident-note', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const { data } = req.body;
const incidentNote = await ZapierService.createIncidentNote(data);
@@ -95,7 +95,7 @@ router.post('/incident/incident-note', isAuthorized, async function(req, res) {
}
});
router.get('/incident/resolved', isAuthorized, async function(req, res) {
router.get('/incident/resolved', isAuthorized, async function(req:express.Request, res: express.Response) {
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.
@@ -155,7 +155,7 @@ router.post('/incident/resolveIncident', isAuthorized, async function(
}
});
router.get('/incident/acknowledged', isAuthorized, async function(req, res) {
router.get('/incident/acknowledged', isAuthorized, async function(req:express.Request, res: express.Response) {
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.
@@ -220,7 +220,7 @@ router.post('/incident/acknowledgeIncident', isAuthorized, async function(
}
});
router.post('/subscribe', isAuthorized, async function(req, res) {
router.post('/subscribe', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const url = req.body.url;
const type = req.body.type;
@@ -256,11 +256,11 @@ router.post('/subscribe', isAuthorized, async function(req, res) {
}
});
router.delete('/unsubscribe/:id', isAuthorized, async function(req, res) {
router.delete('/unsubscribe/:id', isAuthorized, async function(req:express.Request, res: express.Response) {
try {
const id = req.params.id;
await ZapierService.unsubscribe(id);
return sendEmptyResponse(req, res);
return sendEmptyResponse(req:express.Request, res: express.Response);
} catch (error) {
return sendErrorResponse(req, res, error);
}

View File

@@ -33,7 +33,7 @@ export default {
let userId = req.user && req.user.id ? req.user.id : null;
userId = isValidMongoObjectId(userId) ? userId : null;
let projectId = getProjectId(req, res);
let projectId = getProjectId(req:express.Request, res: express.Response);
projectId = isValidMongoObjectId(projectId) ? projectId : null;
if (shouldStoreLogs === null) {

View File

@@ -20,10 +20,10 @@ export default {
}
if (apiMiddleware.hasAPIKey(req)) {
return apiMiddleware.isValidProjectIdAndApiKey(req, res, next);
return apiMiddleware.isValidProjectIdAndApiKey(req:express.Request, res: express.Response, next: express.RequestHandler);
}
}
doesUserBelongToProject(req, res, next);
doesUserBelongToProject(req:express.Request, res: express.Response, next: express.RequestHandler);
},
};

View File

@@ -34,7 +34,7 @@ export default {
res.status(200).send();
return logResponse(req, res);
return logResponse(req:express.Request, res: express.Response);
},
sendFileResponse(req: $TSFixMe, res: $TSFixMe, file: $TSFixMe) {

View File

@@ -289,7 +289,7 @@ const _this = {
try {
const projectId = apiMiddleware.getProjectId(req);
if (_this.isUserMasterAdmin(req, res)) {
if (_this.isUserMasterAdmin(req:express.Request, res: express.Response)) {
if (next) {
return next();
} else {

View File

@@ -80,7 +80,7 @@ global.io = io;
app.use(cors());
app.use(async function(req, res, next) {
app.use(async function(req:express.Request, res: express.Response, next: express.RequestHandler) {
const method = req.method;
const url = req.url;
const requestStartedAt = Date.now();
@@ -115,7 +115,7 @@ app.use(async function(req, res, next) {
next();
});
app.use(function(req, res, next) {
app.use(function(req:express.Request, res: express.Response, next: express.RequestHandler) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -482,7 +482,7 @@ app.use(
app.use(['/api'], require('./backend/api/apiStatus'));
app.use('/*', function(req, res) {
app.use('/*', function(req:express.Request, res: express.Response) {
res.status(404).send('Endpoint not found.');
});

View File

@@ -0,0 +1,3 @@
export const databaseUrl:string = process.env.MONGO_URL;
export const databaseName:string = process.env.DB_NAME;

View File

@@ -12,6 +12,7 @@
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"mongodb": "^4.4.0",
"winston": "^3.4.0",
"winston-logstash-transport": "^2.0.0",
"winston-slack-webhook-transport": "^2.1.0"
@@ -89,8 +90,7 @@
"node_modules/@types/node": {
"version": "17.0.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==",
"dev": true
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
},
"node_modules/@types/qs": {
"version": "6.9.7",
@@ -114,6 +114,20 @@
"@types/node": "*"
}
},
"node_modules/@types/webidl-conversions": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz",
"integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q=="
},
"node_modules/@types/whatwg-url": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz",
"integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==",
"dependencies": {
"@types/node": "*",
"@types/webidl-conversions": "*"
}
},
"node_modules/@types/winston": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/@types/winston/-/winston-2.4.4.tgz",
@@ -153,6 +167,25 @@
"follow-redirects": "^1.14.4"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz",
@@ -173,6 +206,40 @@
"node": ">= 0.8"
}
},
"node_modules/bson": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/bson/-/bson-4.6.1.tgz",
"integrity": "sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==",
"dependencies": {
"buffer": "^5.6.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@@ -286,6 +353,14 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/denque": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz",
"integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==",
"engines": {
"node": ">=0.10"
}
},
"node_modules/depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -466,11 +541,35 @@
"node": ">=0.10.0"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
@@ -520,6 +619,12 @@
"node": ">= 0.6"
}
},
"node_modules/memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@@ -563,6 +668,32 @@
"node": ">= 0.6"
}
},
"node_modules/mongodb": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.4.0.tgz",
"integrity": "sha512-1hPhutJj6yxxu0ymwsO0uEimTo+QTh3oQP6YHxmLneBFBOGydYFdnmDDuLiGWimAlMdRN9WuDXY+JGp47aeOwA==",
"dependencies": {
"bson": "^4.6.1",
"denque": "^2.0.1",
"mongodb-connection-string-url": "^2.4.1",
"socks": "^2.6.1"
},
"engines": {
"node": ">=12.9.0"
},
"optionalDependencies": {
"saslprep": "^1.0.3"
}
},
"node_modules/mongodb-connection-string-url": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz",
"integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==",
"dependencies": {
"@types/whatwg-url": "^8.2.1",
"whatwg-url": "^11.0.0"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -628,6 +759,14 @@
"node": ">= 0.10"
}
},
"node_modules/punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"engines": {
"node": ">=6"
}
},
"node_modules/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
@@ -703,6 +842,18 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"dependencies": {
"sparse-bitfield": "^3.0.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/send": {
"version": "0.17.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz",
@@ -753,6 +904,37 @@
"is-arrayish": "^0.3.1"
}
},
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
},
"node_modules/socks": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz",
"integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==",
"dependencies": {
"ip": "^1.1.5",
"smart-buffer": "^4.2.0"
},
"engines": {
"node": ">= 10.13.0",
"npm": ">= 3.0.0"
}
},
"node_modules/sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
"optional": true,
"dependencies": {
"memory-pager": "^1.0.2"
}
},
"node_modules/stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
@@ -790,6 +972,17 @@
"node": ">=0.6"
}
},
"node_modules/tr46": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
"dependencies": {
"punycode": "^2.1.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/triple-beam": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
@@ -836,6 +1029,26 @@
"node": ">= 0.8"
}
},
"node_modules/webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
"engines": {
"node": ">=12"
}
},
"node_modules/whatwg-url": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz",
"integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==",
"dependencies": {
"tr46": "^3.0.0",
"webidl-conversions": "^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/winston": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/winston/-/winston-3.4.0.tgz",
@@ -955,8 +1168,7 @@
"@types/node": {
"version": "17.0.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==",
"dev": true
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
},
"@types/qs": {
"version": "6.9.7",
@@ -980,6 +1192,20 @@
"@types/node": "*"
}
},
"@types/webidl-conversions": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz",
"integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q=="
},
"@types/whatwg-url": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz",
"integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==",
"requires": {
"@types/node": "*",
"@types/webidl-conversions": "*"
}
},
"@types/winston": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/@types/winston/-/winston-2.4.4.tgz",
@@ -1015,6 +1241,11 @@
"follow-redirects": "^1.14.4"
}
},
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
},
"body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz",
@@ -1032,6 +1263,23 @@
"type-is": "~1.6.18"
}
},
"bson": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/bson/-/bson-4.6.1.tgz",
"integrity": "sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==",
"requires": {
"buffer": "^5.6.0"
}
},
"buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
},
"bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@@ -1129,6 +1377,11 @@
}
}
},
"denque": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz",
"integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ=="
},
"depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -1265,11 +1518,21 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
},
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
@@ -1307,6 +1570,12 @@
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@@ -1335,6 +1604,27 @@
"mime-db": "1.51.0"
}
},
"mongodb": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.4.0.tgz",
"integrity": "sha512-1hPhutJj6yxxu0ymwsO0uEimTo+QTh3oQP6YHxmLneBFBOGydYFdnmDDuLiGWimAlMdRN9WuDXY+JGp47aeOwA==",
"requires": {
"bson": "^4.6.1",
"denque": "^2.0.1",
"mongodb-connection-string-url": "^2.4.1",
"saslprep": "^1.0.3",
"socks": "^2.6.1"
}
},
"mongodb-connection-string-url": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz",
"integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==",
"requires": {
"@types/whatwg-url": "^8.2.1",
"whatwg-url": "^11.0.0"
}
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -1385,6 +1675,11 @@
"ipaddr.js": "1.9.1"
}
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
@@ -1431,6 +1726,15 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"requires": {
"sparse-bitfield": "^3.0.3"
}
},
"send": {
"version": "0.17.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz",
@@ -1475,6 +1779,29 @@
"is-arrayish": "^0.3.1"
}
},
"smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg=="
},
"socks": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz",
"integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==",
"requires": {
"ip": "^1.1.5",
"smart-buffer": "^4.2.0"
}
},
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
"optional": true,
"requires": {
"memory-pager": "^1.0.2"
}
},
"stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
@@ -1503,6 +1830,14 @@
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="
},
"tr46": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
"requires": {
"punycode": "^2.1.1"
}
},
"triple-beam": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
@@ -1537,6 +1872,20 @@
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g=="
},
"whatwg-url": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz",
"integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==",
"requires": {
"tr46": "^3.0.0",
"webidl-conversions": "^7.0.0"
}
},
"winston": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/winston/-/winston-3.4.0.tgz",

View File

@@ -13,6 +13,7 @@
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"mongodb": "^4.4.0",
"winston": "^3.4.0",
"winston-logstash-transport": "^2.0.0",
"winston-slack-webhook-transport": "^2.1.0"

View File

@@ -1,5 +1,5 @@
import MongoDB from 'mongodb';
import { mongoUrl, databaseName } from './config';
import { databaseUrl, databaseName } from '../config';
export default class Database {
@@ -7,7 +7,7 @@ export default class Database {
static databaseConnected: boolean = false;
static getClient(): MongoDB.MongoClient{
this.databaseClient = new MongoDB.MongoClient(mongoUrl, {
this.databaseClient = new MongoDB.MongoClient(databaseUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
});

View File

@@ -1,17 +1,21 @@
import express from 'express';
import cors from 'cors';
import logger from './logger';
class Express {
static app: express.Application;
static getExpress(): express.Express{
return express;
}
static setupExpress() {
this.app = express();
this.app.set('port', process.env.PORT);
this.app.use(cors());
this.app.use(function (req, res, next) {
this.app.use(function (req:express.Request, res: express.Response, next: express.RequestHandler) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -31,15 +35,8 @@ class Express {
this.app.use(express.urlencoded({ limit: '10mb', extended: true }));
this.app.use(express.json({ limit: '10mb' }));
const getActualRequestDurationInMilliseconds = start => {
const NS_PER_SEC = 1e9; // convert to nanoseconds
const NS_TO_MS = 1e6; // convert to milliseconds
const diff = process.hrtime(start);
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
};
this.app.use(function (req, res, next) {
this.app.use(function (req:express.Request, res: express.Response, next: express.RequestHandler) {
const current_datetime = new Date();
const formatted_date =
current_datetime.getFullYear() +
@@ -57,11 +54,9 @@ class Express {
const url = req.url;
const status = res.statusCode;
const start = process.hrtime();
const durationInMilliseconds = getActualRequestDurationInMilliseconds(
start
);
const log = `[${formatted_date}] ${method}:${url} ${status} ${durationInMilliseconds.toLocaleString()} ms`;
console.log(log);
const log = `[${formatted_date}] ${method}:${url} ${status}`;
logger.info(log);
return next();
});
@@ -76,13 +71,14 @@ class Express {
}
static launchApplication() {
if(!this.app){
this.setupExpress();
}
this.app.listen(this.app.get('port'), function() {
this.app.listen(this.app.get('port'), () => {
// eslint-disable-next-line
console.log('probe-api server started on port ' + this.app.get('port'));
logger.info(`Server started on port: ${this.app.get('port')}`);
});
return this.app;

View File

@@ -42,7 +42,7 @@ const cronContainerSecurityStartTime = Math.floor(Math.random() * 50);
app.use(cors());
app.set('port', process.env.PORT || 3055);
app.get(['/container/status', '/status'], function(req, res) {
app.get(['/container/status', '/status'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({
@@ -55,7 +55,7 @@ app.get(['/container/status', '/status'], function(req, res) {
//App Version
app.get(['/container/version', '/version'], function(req, res) {
app.get(['/container/version', '/version'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send({ containerScannerVersion: process.env.npm_package_version });
});

View File

@@ -138,7 +138,7 @@ app.use(
app.use('/dashboard', express.static(path.join(__dirname, 'build')));
// app.use(
// /^\/dashboard\/static\/js\/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\.(.+)\.chunk\.js$/,
// function(req, res, next) {
// function(req:express.Request, res: express.Response, next: express.RequestHandler) {
// let baseUrls = req.baseUrl;
// baseUrls = baseUrls.split('/');

View File

@@ -660,7 +660,7 @@ router.post('/set-scan-status', isAuthorizedProbe, async function(
const { monitorIds, scanning } = req.body;
await MonitorService.updateScanStatus(monitorIds, scanning);
return sendEmptyResponse(req, res);
return sendEmptyResponse(req:express.Request, res: express.Response);
} catch (error) {
return sendErrorResponse(req, res, error);
}
@@ -674,7 +674,7 @@ router.post('/add-probe-scan', isAuthorizedProbe, async function(
const { monitorIds } = req.body;
await MonitorService.addProbeScanning(monitorIds, req.probe.id);
return sendEmptyResponse(req, res);
return sendEmptyResponse(req:express.Request, res: express.Response);
} catch (error) {
return sendErrorResponse(req, res, error);
}
@@ -688,7 +688,7 @@ router.post('/remove-probe-scan', isAuthorizedProbe, async function(
const { monitorIds } = req.body;
await MonitorService.removeProbeScanning(monitorIds, req.probe.id);
return sendEmptyResponse(req, res);
return sendEmptyResponse(req:express.Request, res: express.Response);
} catch (error) {
return sendErrorResponse(req, res, error);
}

View File

@@ -56,7 +56,7 @@ global.db = client.db(databaseName);
app.use(cors());
app.use(function(req, res, next) {
app.use(function(req:express.Request, res: express.Response, next: express.RequestHandler) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -85,7 +85,7 @@ const getActualRequestDurationInMilliseconds = start => {
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
};
app.use(function(req, res, next) {
app.use(function(req:express.Request, res: express.Response, next: express.RequestHandler) {
const current_datetime = new Date();
const formatted_date =
current_datetime.getFullYear() +
@@ -111,7 +111,7 @@ app.use(function(req, res, next) {
return next();
});
app.get(['/data-ingestor/status', '/status'], function(req, res) {
app.get(['/data-ingestor/status', '/status'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({

View File

@@ -7,7 +7,7 @@ import { clusterKey as CLUSTER_KEY } from '../utils/config';
global.probes = {};
export default {
isAuthorizedProbe: async function(req, res, next) {
isAuthorizedProbe: async function(req:express.Request, res: express.Response, next: express.RequestHandler) {
try {
let probeKey, probeName, clusterKey, probeVersion;

View File

@@ -68,11 +68,11 @@ if (process.env['NODE_ENV'] === 'development') {
});
app.get('/:dbFunction', async function(req: $TSFixMe, res: $TSFixMe) {
return await interactWithDB(req, res);
return await interactWithDB(req:express.Request, res: express.Response);
});
app.post('/:dbFunction', async function(req: $TSFixMe, res: $TSFixMe) {
return await interactWithDB(req, res);
return await interactWithDB(req:express.Request, res: express.Response);
});
}

View File

@@ -33,7 +33,7 @@ import cors from 'cors';
app.use(cors());
app.use(function(req, res, next) {
app.use(function(req:express.Request, res: express.Response, next: express.RequestHandler) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -68,7 +68,7 @@ const server = http.listen(app.get('port'), function() {
console.log('Server Started on port ' + app.get('port'));
});
app.get(['/', '/license'], function(req, res) {
app.get(['/', '/license'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({
@@ -79,7 +79,7 @@ app.get(['/', '/license'], function(req, res) {
);
});
app.use('/*', function(req, res) {
app.use('/*', function(req:express.Request, res: express.Response) {
res.status(404).render('notFound.ejs', {});
});

View File

@@ -42,7 +42,7 @@ const cronMinuteStartTime = Math.floor(Math.random() * 50);
app.use(cors());
app.set('port', process.env.PORT || 3015);
app.get(['/lighthouse/status', '/status'], function(req, res) {
app.get(['/lighthouse/status', '/status'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({
@@ -55,7 +55,7 @@ app.get(['/lighthouse/status', '/status'], function(req, res) {
//App Version
app.get(['/lighthouse/version', '/version'], function(req, res) {
app.get(['/lighthouse/version', '/version'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send({ lighthouseVersion: process.env.npm_package_version });
});

View File

@@ -2,11 +2,10 @@
import 'common-server/utils/env';
import 'common-server/utils/process';
import Express from 'common-server/utils/express';
import Database from 'common-server/utils/database';
const app = Express.launchApplication();
app.get(['/probe-api/status', '/status'], function(req, res) {
app.get(['/probe-api/status', '/status'], function(req:express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
res.send(
JSON.stringify({

View File

@@ -7,7 +7,7 @@ import { clusterKey as CLUSTER_KEY } from '../utils/config';
global.probes = {};
export default {
isAuthorizedProbe: async function(req, res, next) {
isAuthorizedProbe: async function(req:express.Request, res: express.Response, next: express.RequestHandler) {
try {
let probeKey, probeName, clusterKey, probeVersion;

View File

@@ -14,7 +14,6 @@
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",
"dotenv": "^16.0.0",
"express": "^4.17.2",
"lodash": "^4.17.21",
"moment": "^2.29.1",
@@ -34,9 +33,18 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"mongodb": "^4.4.0",
"winston": "^3.4.0",
"winston-logstash-transport": "^2.0.0",
"winston-slack-webhook-transport": "^2.1.0"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/node": "^17.0.21"
}
},
"node_modules/@dabh/diagnostics": {
@@ -495,16 +503,6 @@
"node": ">= 8"
}
},
"node_modules/custom-env": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/custom-env/-/custom-env-2.0.1.tgz",
"integrity": "sha512-gVv19DBDuTQ8MM/WPlf8025Aa46Aqmfrr/kDxyDfXWe5t7C3+OgBsuhrsXTKQ4hGo+z1OuuaOQnhgTWIpvrz+w==",
"license": "ISC",
"dependencies": {
"dotenv": "*",
"dotenv-expand": "^5.0.0"
}
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -551,11 +549,6 @@
"node": ">=12"
}
},
"node_modules/dotenv-expand": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
"integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA=="
},
"node_modules/dynamic-dedupe": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz",
@@ -2124,6 +2117,13 @@
"common-server": {
"version": "file:../common-server",
"requires": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/node": "^17.0.21",
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"mongodb": "^4.4.0",
"winston": "^3.4.0",
"winston-logstash-transport": "^2.0.0",
"winston-slack-webhook-transport": "^2.1.0"
@@ -2191,15 +2191,6 @@
"which": "^2.0.1"
}
},
"custom-env": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/custom-env/-/custom-env-2.0.1.tgz",
"integrity": "sha512-gVv19DBDuTQ8MM/WPlf8025Aa46Aqmfrr/kDxyDfXWe5t7C3+OgBsuhrsXTKQ4hGo+z1OuuaOQnhgTWIpvrz+w==",
"requires": {
"dotenv": "*",
"dotenv-expand": "^5.0.0"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -2234,11 +2225,6 @@
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
"integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q=="
},
"dotenv-expand": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
"integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA=="
},
"dynamic-dedupe": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz",

View File

@@ -1,3 +1,10 @@
import ErrorService from './errorService';
import moment from 'moment';
import Database from 'common-server/utils/database';
const monitorCollection = Database.getDatabase().collection('monitors');
export default {
async getProbeMonitors(probeId: $TSFixMe, limit = 10) {
//get monitors that have not been pinged for the last minute.
@@ -71,7 +78,3 @@ export default {
},
};
import ErrorService from './errorService';
import moment from 'moment';
const monitorCollection = global.db.collection('monitors');

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