This commit is contained in:
Nawaz Dhandala 2022-04-15 12:33:52 +01:00
parent 7ad52dc0a0
commit 55999da87a
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
9 changed files with 433 additions and 324 deletions

View File

@ -90,6 +90,7 @@
"react/no-is-mounted": "error",
"react/no-find-dom-node": "error",
"one-var-declaration-per-line": "error",
"arrow-parens": "error",
"arrow-body-style": ["error", "always"],
"@typescript-eslint/typedef": [
"error",

View File

@ -34,39 +34,50 @@ describe('Project API', function (): void {
before(function (done: $TSFixMe): void {
this.timeout(40000);
GlobalConfig.initTestConfig().then((): void => {
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end((err, res): void => {
token = res.body.tokens.jwtAccessToken;
done();
});
});
}
);
});
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
token =
res.body.tokens
.jwtAccessToken;
done();
}
);
});
}
);
}
);
});
});
@ -97,7 +108,7 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(401);
done();
});
@ -114,7 +125,7 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -130,7 +141,7 @@ describe('Project API', function (): void {
planId: null,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -147,7 +158,7 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
ProjectService.hardDeleteBy({ _id: res.body._id });
done();
@ -160,7 +171,7 @@ describe('Project API', function (): void {
.get('/project/projects')
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@ -180,7 +191,7 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
request
.get(`/project/${res.body._id}/resetToken`)
.set('Authorization', authorization)
@ -206,7 +217,7 @@ describe('Project API', function (): void {
projectName: null,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -223,7 +234,7 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
request
.put(`/project/${res.body._id}/renameProject`)
.set('Authorization', authorization)
@ -231,7 +242,7 @@ describe('Project API', function (): void {
projectName: 'Renamed Project',
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.name).to.not.equal('Old Project');
ProjectService.hardDeleteBy({ _id: res.body._id });
@ -246,7 +257,7 @@ describe('Project API', function (): void {
.get(`/project/${null}/balance`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -259,7 +270,7 @@ describe('Project API', function (): void {
.get(`/project/${projectId}/balance`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.balance).to.be.eql(0);
done();
@ -277,12 +288,12 @@ describe('Project API', function (): void {
planId: plans[0].planId,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
request
.delete(`/project/${res.body._id}/deleteProject`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
ProjectService.hardDeleteBy({ _id: res.body._id });
done();
@ -386,7 +397,7 @@ describe('Project API', function (): void {
.delete(`/project/${projectId}/user/${userId}/exitProject`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
log(res.text);
expect(res).to.have.status(200);
expect(res.text).to.be.equal(
@ -408,7 +419,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationEmail: true,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendCreatedIncidentNotificationEmail).to.be
.false;
@ -428,7 +439,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationEmail: true,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendAcknowledgedIncidentNotificationEmail).to.be
.false;
@ -448,7 +459,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationEmail: false,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendResolvedIncidentNotificationEmail).to.be
.false;
@ -468,7 +479,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationSms: true,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendCreatedIncidentNotificationSms).to.be.false;
done();
@ -487,7 +498,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationSms: true,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendAcknowledgedIncidentNotificationSms).to.be
.false;
@ -507,7 +518,7 @@ describe('Project API', function (): void {
sendResolvedIncidentNotificationSms: false,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.sendResolvedIncidentNotificationSms).to.be
.false;
@ -522,36 +533,48 @@ describe('Projects SubProjects API', function (): void {
before(function (done: $TSFixMe): void {
this.timeout(40000);
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end((err, res): void => {
token = res.body.tokens.jwtAccessToken;
done();
});
});
}
);
});
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
token =
res.body.tokens.jwtAccessToken;
done();
}
);
});
}
);
}
);
});
after(async (): void => {
@ -577,7 +600,7 @@ describe('Projects SubProjects API', function (): void {
.set('Authorization', authorization)
.send({ subProjectName: '' })
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Subproject name must be present.'
@ -594,7 +617,7 @@ describe('Projects SubProjects API', function (): void {
.set('Authorization', authorization)
.send({ subProjectName: 'New SubProject' })
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
subProjectId = res.body[0]._id;
expect(res).to.have.status(200);
done();
@ -602,49 +625,70 @@ describe('Projects SubProjects API', function (): void {
});
it('should not get subprojects for a user not present in the project.', (done: $TSFixMe): void => {
createUser(request, userData.newUser, (err, res): void => {
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
createUser(
request,
userData.newUser,
(err: $TSFixMe, res: $TSFixMe): void => {
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end((err, res): void => {
const authorization: string = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
const authorization: string = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.get(
`/project/${projectId}/subProjects`
)
.set('Authorization', authorization)
.get(
`/project/${projectId}/subProjects`
)
.set(
'Authorization',
authorization
)
.end((err, res): void => {
expect(res).to.have.status(400);
expect(
res.body.message
).to.be.equal(
'You are not present in this project.'
);
done();
});
});
});
}
);
});
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
expect(
res
).to.have.status(400);
expect(
res.body.message
).to.be.equal(
'You are not present in this project.'
);
done();
}
);
}
);
});
}
);
}
);
});
it('should get subprojects for a valid user.', (done: $TSFixMe): void => {
@ -654,7 +698,7 @@ describe('Projects SubProjects API', function (): void {
.get(`/project/${projectId}/subProjects`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('array');
@ -673,7 +717,7 @@ describe('Projects SubProjects API', function (): void {
subProjectName: null,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -689,7 +733,7 @@ describe('Projects SubProjects API', function (): void {
subProjectName: 'Renamed SubProject',
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('Renamed SubProject');
done();
@ -703,7 +747,7 @@ describe('Projects SubProjects API', function (): void {
.delete(`/project/${projectId}/${subProjectId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
done();
});

View File

@ -35,39 +35,50 @@ describe('Resource Category API', function (): void {
before(function (done: $TSFixMe): void {
this.timeout(40000);
GlobalConfig.initTestConfig().then((): void => {
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end((err, res): void => {
token = res.body.tokens.jwtAccessToken;
done();
});
});
}
);
});
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
token =
res.body.tokens
.jwtAccessToken;
done();
}
);
});
}
);
}
);
});
});
@ -97,7 +108,7 @@ describe('Resource Category API', function (): void {
resourceCategoryName: 'unauthenticated user',
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(401);
done();
});
@ -113,7 +124,7 @@ describe('Resource Category API', function (): void {
resourceCategoryName: null,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -127,7 +138,7 @@ describe('Resource Category API', function (): void {
.set('Authorization', authorization)
.send(resourceCategory)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
resourceCategoryId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(
@ -144,7 +155,7 @@ describe('Resource Category API', function (): void {
.get(`/resourceCategory/${projectId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@ -163,7 +174,7 @@ describe('Resource Category API', function (): void {
.delete(`/resourceCategory/${projectId}/${resourceCategoryId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
done();
});
@ -176,42 +187,59 @@ describe('User from other project have access to read / write and delete API.',
before(function (done: $TSFixMe): void {
this.timeout(40000);
GlobalConfig.initTestConfig().then((): void => {
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
createUser(request, userData.newUser, (err, res): void => {
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
createUser(
request,
userData.newUser,
(err: $TSFixMe, res: $TSFixMe): void => {
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
verificationToken
) => {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.newUser
.email,
password:
userData.newUser
.password,
})
.end((err, res): void => {
token =
res.body.tokens.jwtAccessToken;
done();
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
token =
res.body.tokens
.jwtAccessToken;
done();
}
);
});
});
}
);
}
);
});
});
}
);
});
});
@ -240,7 +268,7 @@ describe('User from other project have access to read / write and delete API.',
.set('Authorization', authorization)
.send(resourceCategory)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -253,7 +281,7 @@ describe('User from other project have access to read / write and delete API.',
.delete(`/resourceCategory/${projectId}/${resourceCategoryId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -266,7 +294,7 @@ describe('User from other project have access to read / write and delete API.',
.get(`/resourceCategory/${projectId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -282,131 +310,159 @@ describe('Non-admin user access to create, delete and access resource category.'
before(function (done: $TSFixMe): void {
this.timeout(40000);
GlobalConfig.initTestConfig().then((): void => {
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end((): void => {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end((err, res): void => {
token = res.body.tokens.jwtAccessToken;
const authorization: string = `Basic ${token}`;
request
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
token =
res.body.tokens
.jwtAccessToken;
const authorization: string = `Basic ${token}`;
request
.post(
`/resourceCategory/${projectId}`
)
.set('Authorization', authorization)
.send(resourceCategory)
.post(
`/resourceCategory/${projectId}`
)
.set(
'Authorization',
authorization
)
.send(resourceCategory)
.end((err, res): void => {
resourceCategoryId =
res.body._id;
createUser(
request,
userData.newUser,
.end(
(
err: $TSFixMe,
res: $TSFixMe
): void => {
resourceCategoryId =
res.body._id;
createUser(
request,
userData.newUser,
(err, res): void => {
projectIdSecondUser =
res.body.project
._id;
emailToBeInvited =
userData.newUser
.email;
userId = res.body.id;
VerificationTokenModel.findOne(
{ userId },
(
err,
(
err: $TSFixMe,
res: $TSFixMe
): void => {
projectIdSecondUser =
res.body
.project
._id;
emailToBeInvited =
userData
.newUser
.email;
userId =
res.body
.id;
VerificationTokenModel.findOne(
{
userId,
},
(
err,
verificationToken
) => {
request
.get(
`/user/confirmation/${verificationToken.token}`
)
.redirects(
0
)
.end(
(): void => {
verificationToken
) => {
request
.post(
`/team/${projectId}`
.get(
`/user/confirmation/${verificationToken.token}`
)
.set(
'Authorization',
authorization
)
.send(
{
emails: emailToBeInvited,
role: 'Member',
}
.redirects(
0
)
.end(
(): void => {
request
.post(
'/user/login'
`/team/${projectId}`
)
.set(
'Authorization',
authorization
)
.send(
{
email: userData
.newUser
.email,
password:
userData
.newUser
.password,
emails: emailToBeInvited,
role: 'Member',
}
)
.end(
(
err,
(): void => {
request
.post(
'/user/login'
)
.send(
{
email: userData
.newUser
.email,
password:
userData
.newUser
.password,
}
)
.end(
(
err,
res
) => {
token =
res
.body
.tokens
.jwtAccessToken;
done();
res
) => {
token =
res
.body
.tokens
.jwtAccessToken;
done();
}
);
}
);
}
);
}
);
}
);
}
);
});
});
});
}
);
});
}
);
}
);
}
);
});
}
);
}
);
});
});
@ -436,7 +492,7 @@ describe('Non-admin user access to create, delete and access resource category.'
.set('Authorization', authorization)
.send(resourceCategory)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -449,7 +505,7 @@ describe('Non-admin user access to create, delete and access resource category.'
.delete(`/resourceCategory/${projectId}/${resourceCategoryId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(400);
done();
});
@ -462,7 +518,7 @@ describe('Non-admin user access to create, delete and access resource category.'
.get(`/resourceCategory/${projectId}`)
.set('Authorization', authorization)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@ -481,12 +537,16 @@ describe('Resource Category APIs accesible through API key', function (): void {
before(function (done: $TSFixMe): void {
this.timeout(40000);
GlobalConfig.initTestConfig().then((): void => {
createUser(request, userData.user, (err, res): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
apiKey = project.apiKey;
done();
});
createUser(
request,
userData.user,
(err: $TSFixMe, res: $TSFixMe): void => {
const project: $TSFixMe = res.body.project;
projectId = project._id;
apiKey = project.apiKey;
done();
}
);
});
});
@ -515,7 +575,7 @@ describe('Resource Category APIs accesible through API key', function (): void {
.set('apiKey', apiKey)
.send(resourceCategory)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
resourceCategoryId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(
@ -532,7 +592,7 @@ describe('Resource Category APIs accesible through API key', function (): void {
.set('apiKey', apiKey)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@ -551,7 +611,7 @@ describe('Resource Category APIs accesible through API key', function (): void {
.set('apiKey', apiKey)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
expect(res).to.have.status(200);
done();
});

View File

@ -9,7 +9,7 @@ export default {
companyName: userData.companyName,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
if (err) {
if (callback) {
return callback(err, res);
@ -39,7 +39,7 @@ export default {
...userData,
})
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
if (callback) {
return callback(err, res);
} else {
@ -61,7 +61,7 @@ export default {
.post('/user/signup')
.send(userData)
.end((err, res): void => {
.end((err: $TSFixMe, res: $TSFixMe): void => {
return callback(err, res);
});
},

View File

@ -223,7 +223,7 @@ describe('Zapier API', function (): void {
let authorization:string = `Basic ${token}`;
request.get(`/zapier/test?apiKey=${apiKey}&&projectId=${projectId}`)
.set('Authorization', authorization)
.send().end(function (err, res):void {
.send().end(function (err: $TSFixMe, res: $TSFixMe):void {
expect(res).to.have.status(200);
done();
});

View File

@ -1,8 +1,8 @@
import axios from 'axios';
class Logger {
apiUrl: URL;
applicationLogId: $TSFixMe;
applicationLogKey: $TSFixMe;
private apiUrl: URL;
private applicationLogId: $TSFixMe;
private applicationLogKey: $TSFixMe;
constructor(
apiUrl: URL,
applicationLogId: $TSFixMe,
@ -12,13 +12,13 @@ class Logger {
this._setApiUrl(apiUrl);
this._setApplicationLogKey(applicationLogKey);
}
_setApplicationLogId(applicationLogId: $TSFixMe): void {
private _setApplicationLogId(applicationLogId: $TSFixMe): void {
this.applicationLogId = applicationLogId;
}
_setApplicationLogKey(applicationLogKey: $TSFixMe): void {
private _setApplicationLogKey(applicationLogKey: $TSFixMe): void {
this.applicationLogKey = applicationLogKey;
}
_setApiUrl(apiUrl: URL): void {
private _setApiUrl(apiUrl: URL): void {
this.apiUrl = `${apiUrl}/application-log/${this.applicationLogId}/log`;
}
@ -71,7 +71,11 @@ class Logger {
return await this._makeApiRequest(data, logType, tags);
}
_makeApiRequest(data: $TSFixMe, logType: $TSFixMe, tags = null): void {
private _makeApiRequest(
data: $TSFixMe,
logType: $TSFixMe,
tags = null
): void {
const requestData: $TSFixMe = {
content: data,
applicationLogKey: this.applicationLogKey,

View File

@ -21,12 +21,12 @@ class DataStore {
this.sendingData = false;
this.runCron();
}
runCron(): void {
public runCron(): void {
return cron.schedule('*/5 * * * *', () => {
this.sendData();
});
}
mapValue(
public mapValue(
path: $TSFixMe,
store: $TSFixMe,
time: $TSFixMe,
@ -57,33 +57,33 @@ class DataStore {
};
}
}
destroy(id: $TSFixMe): void {
public destroy(id: $TSFixMe): void {
if (this.store.has(id)) {
this.store.delete(id);
}
}
getValue(id: $TSFixMe): void {
public getValue(id: $TSFixMe): void {
return this.store.get(id);
}
getAllData(): void {
public getAllData(): void {
return {
incoming: this.incoming,
outgoing: this.outgoing,
mongoose: this.mongoose,
};
}
clear(): void {
public clear(): void {
return this.store.clear();
}
clearData(): void {
public clearData(): void {
this.incoming.clear();
this.outgoing.clear();
this.mongoose.clear();
return {};
}
setData(value: $TSFixMe): void {
public setData(value: $TSFixMe): void {
const type: $TSFixMe = value.type;
const path: $TSFixMe = value.path;
const time: $TSFixMe = value.duration;
@ -101,7 +101,7 @@ class DataStore {
return this.mongoose.set(path, val);
}
}
setValue(id: $TSFixMe, value: $TSFixMe): void {
public setValue(id: $TSFixMe, value: $TSFixMe): void {
return this.store.set(id, value);
}
public async sendData(): void {
@ -133,7 +133,7 @@ class DataStore {
process.exit(1);
}
}
_makeApiRequest(data: $TSFixMe): void {
private _makeApiRequest(data: $TSFixMe): void {
return new Promise((resolve: Function, reject: Function) => {
axios
.post(

View File

@ -21,7 +21,7 @@ describe('OneUptimeLogger', function (): void {
this.timeout(timeout + 1000);
let projectId: ObjectID,
token: $TSFixMe,
componentId,
componentId: $TSFixMe,
applicationLog: $TSFixMe;
// create a new user
const component: $TSFixMe = { name: 'Our Component' };

View File

@ -16,7 +16,7 @@ function launchChromeAndRunLighthouse(
});
}
process.on('message', url => {
process.on('message', (url: $TSFixMe) => {
launchChromeAndRunLighthouse(url)
.then((results: $TSFixMe) => {
const issues: $TSFixMe = {};