Skip to content

Commit 465830e

Browse files
committed
fixes as per eslint
1 parent 09f35aa commit 465830e

File tree

31 files changed

+116
-117
lines changed

31 files changed

+116
-117
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"plugins": ["react-hooks"],
32
"rules": {
43
"semi": ["error", "always"],
54
"@typescript-eslint/ban-ts-ignore": "off",

src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ app.use('/v1', routesV1);
2424
app.use((req, res, next) => next(new NotFoundError()));
2525

2626
// Middleware Error Handler
27+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2728
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
2829
if (err instanceof ApiError) {
2930
ApiError.handle(err, res);

src/auth/authUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export const createTokens = async (
5555

5656
if (!refreshToken) throw new InternalError();
5757

58-
return <Tokens>{
58+
return {
5959
accessToken: accessToken,
6060
refreshToken: refreshToken,
61-
};
61+
} as Tokens;
6262
};

src/auth/authentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import express from 'express';
2-
import { ProtectedRequest, Tokens } from 'app-request';
2+
import { ProtectedRequest } from 'app-request';
33
import UserRepo from '../database/repository/UserRepo';
44
import { AuthFailureError, AccessTokenError, TokenExpiredError } from '../core/ApiError';
55
import JWT from '../core/JWT';

src/core/ApiError.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,61 +56,61 @@ export abstract class ApiError extends Error {
5656
}
5757

5858
export class AuthFailureError extends ApiError {
59-
constructor(message: string = 'Invalid Credentials') {
59+
constructor(message = 'Invalid Credentials') {
6060
super(ErrorType.UNAUTHORIZED, message);
6161
}
6262
}
6363

6464
export class InternalError extends ApiError {
65-
constructor(message: string = 'Internal error') {
65+
constructor(message = 'Internal error') {
6666
super(ErrorType.INTERNAL, message);
6767
}
6868
}
6969

7070
export class BadRequestError extends ApiError {
71-
constructor(message: string = 'Bad Request') {
71+
constructor(message = 'Bad Request') {
7272
super(ErrorType.BAD_REQUEST, message);
7373
}
7474
}
7575

7676
export class NotFoundError extends ApiError {
77-
constructor(message: string = 'Not Found') {
77+
constructor(message = 'Not Found') {
7878
super(ErrorType.NOT_FOUND, message);
7979
}
8080
}
8181

8282
export class ForbiddenError extends ApiError {
83-
constructor(message: string = 'Permission denied') {
83+
constructor(message = 'Permission denied') {
8484
super(ErrorType.FORBIDDEN, message);
8585
}
8686
}
8787

8888
export class NoEntryError extends ApiError {
89-
constructor(message: string = "Entry don't exists") {
89+
constructor(message = "Entry don't exists") {
9090
super(ErrorType.NO_ENTRY, message);
9191
}
9292
}
9393

9494
export class BadTokenError extends ApiError {
95-
constructor(message: string = 'Token is not valid') {
95+
constructor(message = 'Token is not valid') {
9696
super(ErrorType.BAD_TOKEN, message);
9797
}
9898
}
9999

100100
export class TokenExpiredError extends ApiError {
101-
constructor(message: string = 'Token is expired') {
101+
constructor(message = 'Token is expired') {
102102
super(ErrorType.TOKEN_EXPIRED, message);
103103
}
104104
}
105105

106106
export class NoDataError extends ApiError {
107-
constructor(message: string = 'No data available') {
107+
constructor(message = 'No data available') {
108108
super(ErrorType.NO_DATA, message);
109109
}
110110
}
111111

112112
export class AccessTokenError extends ApiError {
113-
constructor(message: string = 'Invalid access token') {
113+
constructor(message = 'Invalid access token') {
114114
super(ErrorType.ACCESS_TOKEN, message);
115115
}
116116
}

src/core/ApiResponse.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class ApiResponse {
3333
}
3434

3535
private static sanitize<T extends ApiResponse>(response: T): T {
36-
const clone: T = <T>{};
36+
const clone: T = {} as T;
3737
Object.assign(clone, response);
3838
// delete {some_field};
3939
delete clone.status;
@@ -43,15 +43,15 @@ abstract class ApiResponse {
4343
}
4444

4545
export class AuthFailureResponse extends ApiResponse {
46-
constructor(message: string = 'Authentication Failure') {
46+
constructor(message = 'Authentication Failure') {
4747
super(StatusCode.FAILURE, ResponseStatus.UNAUTHORIZED, message);
4848
}
4949
}
5050

5151
export class NotFoundResponse extends ApiResponse {
5252
private url: string;
5353

54-
constructor(message: string = 'Not Found') {
54+
constructor(message = 'Not Found') {
5555
super(StatusCode.FAILURE, ResponseStatus.NOT_FOUND, message);
5656
}
5757

@@ -62,19 +62,19 @@ export class NotFoundResponse extends ApiResponse {
6262
}
6363

6464
export class ForbiddenResponse extends ApiResponse {
65-
constructor(message: string = 'Forbidden') {
65+
constructor(message = 'Forbidden') {
6666
super(StatusCode.FAILURE, ResponseStatus.FORBIDDEN, message);
6767
}
6868
}
6969

7070
export class BadRequestResponse extends ApiResponse {
71-
constructor(message: string = 'Bad Parameters') {
71+
constructor(message = 'Bad Parameters') {
7272
super(StatusCode.FAILURE, ResponseStatus.BAD_REQUEST, message);
7373
}
7474
}
7575

7676
export class InternalErrorResponse extends ApiResponse {
77-
constructor(message: string = 'Internal Error') {
77+
constructor(message = 'Internal Error') {
7878
super(StatusCode.FAILURE, ResponseStatus.INTERNAL_ERROR, message);
7979
}
8080
}
@@ -104,7 +104,7 @@ export class SuccessResponse<T> extends ApiResponse {
104104
export class AccessTokenErrorResponse extends ApiResponse {
105105
private instruction = 'refresh_token';
106106

107-
constructor(message: string = 'Access token invalid') {
107+
constructor(message = 'Access token invalid') {
108108
super(StatusCode.INVALID_ACCESS_TOKEN, ResponseStatus.UNAUTHORIZED, message);
109109
}
110110

src/core/JWT.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import { readFile } from 'fs';
33
import { promisify } from 'util';
4-
import { sign, verify, decode } from 'jsonwebtoken';
4+
import { sign, verify } from 'jsonwebtoken';
55
import { InternalError, BadTokenError, TokenExpiredError } from './ApiError';
66
import Logger from './Logger';
77

@@ -36,7 +36,7 @@ export default class JWT {
3636
const cert = await this.readPublicKey();
3737
try {
3838
// @ts-ignore
39-
return <JwtPayload>await promisify(verify)(token, cert);
39+
return (await promisify(verify)(token, cert)) as JwtPayload;
4040
} catch (e) {
4141
Logger.debug(e);
4242
if (e && e.name === 'TokenExpiredError') throw new TokenExpiredError();
@@ -52,7 +52,7 @@ export default class JWT {
5252
const cert = await this.readPublicKey();
5353
try {
5454
// @ts-ignore
55-
return <JwtPayload>await promisify(verify)(token, cert, { ignoreExpiration: true });
55+
return (await promisify(verify)(token, cert, { ignoreExpiration: true })) as JwtPayload;
5656
} catch (e) {
5757
Logger.debug(e);
5858
throw new BadTokenError();

src/database/model/ApiKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, model, Document, Types } from 'mongoose';
1+
import { Schema, model, Document } from 'mongoose';
22

33
export const DOCUMENT_NAME = 'ApiKey';
44
export const COLLECTION_NAME = 'api_keys';

src/database/model/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { model, Schema, Document, Types } from 'mongoose';
1+
import { model, Schema, Document } from 'mongoose';
22
import Role from './Role';
33

44
export const DOCUMENT_NAME = 'User';

src/database/repository/BlogRepo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class BlogRepo {
112112
return this.findDetailedBlogs({ author: user, status: true, isDraft: true });
113113
}
114114

115-
private static findDetailedBlogs(query: Object): Promise<Blog[]> {
115+
private static findDetailedBlogs(query: object): Promise<Blog[]> {
116116
return BlogModel.find(query)
117117
.select(this.BLOG_INFO_ADDITIONAL)
118118
.populate('author', this.AUTHOR_DETAIL)

0 commit comments

Comments
 (0)