Skip to content

Commit 3b2f2ba

Browse files
committed
Fix yarn lint
1 parent e5f0c6f commit 3b2f2ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+173
-383
lines changed

scripts/fake-loader.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import chalk from 'chalk';
22

3-
import * as fake from '../src/utils/fake';
43
import { bindModel } from '../src/config/db';
54
import factories, { FactoryType } from '../src/database/factories';
5+
import * as fake from '../src/utils/fake';
66

77
const { info } = console;
88

9+
/**
10+
* Print the data in JSON format.
11+
*
12+
* @param data - Data to print.
13+
* @returns {void}
14+
*/
915
function print<T>(data: T): void {
1016
const jsonData = JSON.stringify(data, null, ' ');
1117

src/app.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import cors from 'cors';
2-
import helmet from 'helmet';
32
import express from 'express';
3+
import helmet from 'helmet';
44

5-
import routes from './routes';
65
import { bindModel } from './config/db';
7-
import logHandler from './middlewares/logHandler';
6+
import genericErrorHandler from './middlewares/genericErrorHandler';
87
import notFoundHandler from './middlewares/notFoundHandler';
98
import transactionHandler from './middlewares/transactionHandler';
10-
import genericErrorHandler from './middlewares/genericErrorHandler';
9+
import routes from './routes';
1110

1211
const app: express.Application = express();
1312

@@ -16,7 +15,6 @@ bindModel();
1615
app.use(cors());
1716
app.use(helmet());
1817
app.use(transactionHandler);
19-
app.use(logHandler);
2018
app.use(express.json({ limit: '300kb' }));
2119
app.use(express.urlencoded({ extended: true }));
2220

src/config/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Knex from 'knex';
2-
import { Model, knexSnakeCaseMappers } from 'objection';
2+
import { knexSnakeCaseMappers, Model } from 'objection';
33

44
import config from './config';
55

src/controllers/auth.ts

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1+
import { NextFunction, Request, Response } from 'express';
12
import { StatusCodes } from 'http-status-codes';
2-
import { Request, Response, NextFunction } from 'express';
33

44
import config from '../config/config';
55
import JWTPayload from '../domain/misc/JWTPayload';
66
import * as authService from '../services/authService';
77

88
const { messages } = config;
99

10-
/**
11-
* Handle /login request.
12-
*
13-
* @param {Request} req
14-
* @param {Response} res
15-
* @param {NextFunction} next
16-
*/
17-
export async function login(
18-
req: Request,
19-
res: Response,
20-
next: NextFunction
21-
): Promise<void> {
10+
export const login = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
2211
try {
2312
const data = await authService.login(req.body);
2413

@@ -30,20 +19,9 @@ export async function login(
3019
} catch (error) {
3120
next(error);
3221
}
33-
}
22+
};
3423

35-
/**
36-
* Handle /refresh request.
37-
*
38-
* @param {Request} req
39-
* @param {Response} res
40-
* @param {NextFunction} next
41-
*/
42-
export async function refresh(
43-
_: Request,
44-
res: Response,
45-
next: NextFunction
46-
): Promise<void> {
24+
export const refresh = async (_: Request, res: Response, next: NextFunction): Promise<void> => {
4725
try {
4826
const token = String(res.locals.refreshToken);
4927
const jwtPayload = res.locals.jwtPayload as JWTPayload;
@@ -57,20 +35,9 @@ export async function refresh(
5735
} catch (error) {
5836
next(error);
5937
}
60-
}
38+
};
6139

62-
/**
63-
* Handle /logout request.
64-
*
65-
* @param {Request} req
66-
* @param {Response} res
67-
* @param {NextFunction} next
68-
*/
69-
export async function logout(
70-
_: Request,
71-
res: Response,
72-
next: NextFunction
73-
): Promise<void> {
40+
export const logout = async (_: Request, res: Response, next: NextFunction): Promise<void> => {
7441
try {
7542
const token = String(res.locals.refreshToken);
7643
await authService.logout(token);
@@ -82,4 +49,4 @@ export async function logout(
8249
} catch (error) {
8350
next(error);
8451
}
85-
}
52+
};

src/controllers/home.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { name, version } = config;
99
* Handle / GET request, responds API information.
1010
*
1111
* @param {Request} req
12+
* @param _
1213
* @param {Response} res
1314
* @returns {void}
1415
*/

src/controllers/user.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1+
import { NextFunction, Request, Response } from 'express';
12
import { StatusCodes } from 'http-status-codes';
2-
import { Request, Response, NextFunction } from 'express';
33

44
import config from '../config/config';
5-
import * as userService from '../services/userService';
65
import UserPayload from '../domain/requests/UserPayload';
6+
import * as userService from '../services/userService';
77

88
const { messages } = config;
99

1010
/**
1111
* Handle /users GET request.
1212
*
1313
* @param {Request} req
14+
* @param _
1415
* @param {Response} res
1516
* @param {NextFunction} next
1617
*/
17-
export async function index(
18-
_: Request,
19-
res: Response,
20-
next: NextFunction
21-
): Promise<void> {
18+
export async function index(_: Request, res: Response, next: NextFunction): Promise<void> {
2219
try {
2320
const response = await userService.fetchAll();
2421

@@ -39,11 +36,7 @@ export async function index(
3936
* @param {Response} res
4037
* @param {NextFunction} next
4138
*/
42-
export async function store(
43-
req: Request,
44-
res: Response,
45-
next: NextFunction
46-
): Promise<void> {
39+
export async function store(req: Request, res: Response, next: NextFunction): Promise<void> {
4740
try {
4841
const userPayload = req.body as UserPayload;
4942

src/database/factories/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as userFactory from './userFactory';
21
import UserDetail from '../../domain/entities/UserDetail';
2+
import * as userFactory from './userFactory';
33

44
interface Callback<T> {
55
run: () => Promise<T>;

src/database/migrations/20180130005620_create_users_table.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@ import { Knex } from 'knex';
22

33
import Table from '../../resources/enums/Table';
44

5+
/**
6+
*
7+
* @param knex
8+
*/
59
export function up(knex: Knex): Knex.SchemaBuilder {
610
return knex.schema.createTable(Table.USERS, (table) => {
711
table.increments('id').primary();
812
table.string('name').notNullable();
913
table.string('email').notNullable().unique();
1014
table.string('password').notNullable();
11-
table
12-
.integer('role_id')
13-
.unsigned()
14-
.notNullable()
15-
.references('id')
16-
.inTable(Table.USER_ROLES);
15+
table.integer('role_id').unsigned().notNullable().references('id').inTable(Table.USER_ROLES);
1716

1817
table.timestamps(true, true);
1918
});
2019
}
2120

21+
/**
22+
*
23+
* @param knex
24+
*/
2225
export function down(knex: Knex): Knex.SchemaBuilder {
2326
return knex.schema.dropTable(Table.USERS);
2427
}

src/database/migrations/20180517164647_create_user_sessions_table.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@ import { Knex } from 'knex';
22

33
import Table from '../../resources/enums/Table';
44

5+
/**
6+
*
7+
* @param knex
8+
*/
59
export function up(knex: Knex): Knex.SchemaBuilder {
610
return knex.schema.createTable(Table.USER_SESSIONS, (table) => {
711
table.increments('id').primary();
812

913
table.text('token').notNullable();
10-
table
11-
.integer('user_id')
12-
.unsigned()
13-
.notNullable()
14-
.references('id')
15-
.inTable(Table.USERS);
14+
table.integer('user_id').unsigned().notNullable().references('id').inTable(Table.USERS);
1615
table.boolean('is_active').notNullable().defaultTo(true);
1716

1817
table.timestamps(true, true);
1918
});
2019
}
2120

21+
/**
22+
*
23+
* @param knex
24+
*/
2225
export function down(knex: Knex): Knex.SchemaBuilder {
2326
return knex.schema.dropTable(Table.USER_SESSIONS);
2427
}

src/database/seeds/user_table_seeder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { Knex } from 'knex';
22

3-
import * as bcrypt from '../../utils/bcrypt';
43
import Role from '../../resources/enums/Role';
54
import Table from '../../resources/enums/Table';
5+
import * as bcrypt from '../../utils/bcrypt';
66

7+
/**
8+
*
9+
* @param knex
10+
*/
711
export function seed(knex: Knex): Promise<any> {
812
return knex(Table.USERS).then(async () => {
913
return Promise.all([

0 commit comments

Comments
 (0)