Skip to content

Commit

Permalink
feat: add lint task
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu committed Feb 16, 2024
1 parent 41c9d7d commit e3ae4ec
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -38,19 +38,20 @@
},
"scripts": {
"init": "npm-run-all -s init:*",
"init:install": "npm i typescript@5.3.3 -g && npm i typeorm@0.2.41 -g && npm i rsgen -g && npm i ",
"init:install": "npm i typescript@5.3.3 -g && npm i typeorm@0.3.20 -g && npm i rsgen -g && npm i ",
"init:copy": "mkdir -p ./dist/env && cp ./src/env/template.env ./dist/env/development.env && cp ./src/env/template.env ./dist/env/test.env && cp ./src/env/template.env ./dist/env/staging.env && cp ./src/env/template.env ./dist/env/production.env",
"init:compile": "tsc",
"init:version": "rm -rf ./.git && git init && git add . --all && git commit -m \"First commit\"",
"ci:test": "nyc --reporter=lcov --report-dir=./reports/coverage npm-run-all -s test:*",
"doc": "apidoc -i src/ -o docs/apidoc/",
"lint": "eslint . --ext .ts",
"schema:drop": "npm run typeorm schema:drop -- -d dist/api/config/datasource.config.js",
"schema:sync": "npm run typeorm schema:drop -- -d dist/api/config/datasource.config.js",
"start": "nodemon .",
"test": "nyc --reporter=html --report-dir=./reports/nyc-coverage npm-run-all -s test:*",
"test:unit": "./node_modules/.bin/mocha ./test/units/00-application.unit.test.js --exit --reporter spec --timeout 10000 --env test",
"test:e2e": "npm run schema:drop && npm run schema:sync && ./node_modules/.bin/mocha ./test/e2e/00-api.e2e.test.js --exit --reporter spec --timeout 10000 --env test",
"typeorm": "npx typeorm ",
"schema:drop": "npm run typeorm schema:drop -- -d dist/api/config/datasource.config.js",
"schema:sync": "npm run typeorm schema:drop -- -d dist/api/config/datasource.config.js",
"version": "git add package.json && git add README.md && auto-changelog -p && git add CHANGELOG.md && git commit -m \"Update changelog\" --no-verify"
},
"_moduleAliases": {
Expand Down
4 changes: 2 additions & 2 deletions src/api/config/cache.config.ts
Expand Up @@ -24,6 +24,8 @@ class CacheConfiguration {
*/
private engine: ICache;

private constructor() {}

/**
* @description
*/
Expand All @@ -41,8 +43,6 @@ class CacheConfiguration {
return this.engine;
}

private constructor() {}

static get(): CacheConfiguration {
if (!CacheConfiguration.instance) {
CacheConfiguration.instance = new CacheConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion src/api/config/logger.config.ts
Expand Up @@ -124,7 +124,7 @@ class LoggerConfiguration {
* @description
*/
writeStream(): ReadableStream {
return Morgan(LOGS.TOKEN, { stream: ( ENV === ENVIRONMENT.production ? createWriteStream(`${LOGS.PATH}/access.log`, { flags: 'a+' }) : this.stream ) as ReadableStream } ) as ReadableStream
return Morgan(LOGS.TOKEN, { stream: ( ENV as ENVIRONMENT === ENVIRONMENT.production ? createWriteStream(`${LOGS.PATH}/access.log`, { flags: 'a+' }) : this.stream ) as ReadableStream } ) as ReadableStream
}

}
Expand Down
8 changes: 4 additions & 4 deletions src/api/core/controllers/auth.controller.ts
Expand Up @@ -64,7 +64,7 @@ class AuthController {
@Safe()
async login(req: Request, res: IResponse): Promise<void> {
const { user, accessToken } = await UserRepository.findAndGenerateToken(req.body as ITokenOptions);
const token = await AuthService.generateTokenResponse(user as User, accessToken as string);
const token = await AuthService.generateTokenResponse(user, accessToken);
res.locals.data = { token, user };
}

Expand Down Expand Up @@ -118,7 +118,7 @@ class AuthController {

// Get owner user of the token
const { user, accessToken } = await UserRepository.findAndGenerateToken({ email: refreshToken.user.email , refreshToken });
const response = await AuthService.generateTokenResponse(user as User, accessToken as string);
const response = await AuthService.generateTokenResponse(user, accessToken);

res.locals.data = { token: response };
}
Expand All @@ -141,7 +141,7 @@ class AuthController {
throw badRequest('User token cannot be read');
}

const user = await repository.findOneOrFail(decoded.sub) as User;
const user = await repository.findOneOrFail({ where: { id: decoded.sub } });

if ( user.status !== STATUS.REGISTERED && user.status !== STATUS.REVIEWED ) {
throw badRequest('User status cannot be confirmed');
Expand All @@ -166,7 +166,7 @@ class AuthController {

const repository = ApplicationDataSource.getRepository(User);

const user = await repository.findOne( { where: { email: req.query.email } }) as User;
const user = await repository.findOne( { where: { email: req.query.email } });

if ( user && user.status === STATUS.CONFIRMED ) {
void AuthService.revokeRefreshToken(user);
Expand Down
4 changes: 2 additions & 2 deletions src/api/core/controllers/media.controller.ts
Expand Up @@ -41,7 +41,7 @@ class MediaController {
@Safe()
async get(req: IMediaRequest, res: IResponse): Promise<void> {
const repository = ApplicationDataSource.getRepository(Media);
const media = await repository.findOneOrFail({ where: { id: req.params.mediaId }, relations: ['owner'] }) as Media;
const media = await repository.findOneOrFail({ where: { id: req.params.mediaId }, relations: ['owner'] });
res.locals.data = media;
}

Expand All @@ -57,7 +57,7 @@ class MediaController {
res.locals.data = response.result;
res.locals.meta = {
total: response.total,
pagination: paginate( parseInt(req.query.page, 10), parseInt(req.query.perPage, 10), response.total as number )
pagination: paginate( parseInt(req.query.page, 10), parseInt(req.query.perPage, 10), response.total )
}
}

Expand Down

0 comments on commit e3ae4ec

Please sign in to comment.