diff --git a/Dockerfile b/Dockerfile index 262bc7b..360c391 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Here we are getting our node as Base image -FROM node:18.12.1 +FROM node:20.10.0 # create user in the docker image USER node diff --git a/README.md b/README.md index c8d2a54..ee3c73d 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ The repository [**React.js Isomorphic Web Application Architecture**] has a comp * Install Docker and Docker Compose. [Find Instructions Here](https://docs.docker.com/install/). * Execute `docker-compose up -d` in terminal from the repo directory. * You will be able to access the api from http://localhost:3000 + * Run Tests: `docker exec -t app npm test` * *If having any issue* then make sure 3000 port is not occupied else provide a different port in **.env** file. * *If having any issue* then make sure 27017 port is not occupied else provide a different port in **.env** file. * Run The Tests @@ -346,7 +347,7 @@ The repository [**React.js Isomorphic Web Application Architecture**] has a comp ### License ``` - Copyright (C) 2023 JANISHAR ALI ANWAR + Copyright (C) 2024 JANISHAR ALI ANWAR Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docker-compose.yml b/docker-compose.yml index 88c6e2d..0fc5393 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: mongo: # To create this service, Compose will pull the mongo - image: mongo:6.0.3 + image: mongo:7.0.4 container_name: mongo restart: unless-stopped # This tells Compose that we would like to add environment variables @@ -50,7 +50,7 @@ services: - dbdata:/data/db redis: - image: redis:7.0.5 + image: redis:7.2.3 container_name: redis restart: unless-stopped env_file: .env diff --git a/src/auth/apikey.ts b/src/auth/apikey.ts index 3ee2708..4fe49ef 100755 --- a/src/auth/apikey.ts +++ b/src/auth/apikey.ts @@ -1,7 +1,6 @@ import express from 'express'; import ApiKeyRepo from '../database/repository/ApiKeyRepo'; import { ForbiddenError } from '../core/ApiError'; -import Logger from '../core/Logger'; import { PublicRequest } from 'app-request'; import schema from './schema'; import validator, { ValidationSource } from '../helpers/validator'; @@ -18,7 +17,6 @@ export default router.use( const apiKey = await ApiKeyRepo.findByKey(key); if (!apiKey) throw new ForbiddenError(); - Logger.info(apiKey); req.apiKey = apiKey; return next(); diff --git a/src/core/JWT.ts b/src/core/JWT.ts index e3c8f79..251d37f 100755 --- a/src/core/JWT.ts +++ b/src/core/JWT.ts @@ -3,7 +3,6 @@ import { readFile } from 'fs'; import { promisify } from 'util'; import { sign, verify } from 'jsonwebtoken'; import { InternalError, BadTokenError, TokenExpiredError } from './ApiError'; -import Logger from './Logger'; /* * issuer  — Software organization who issues the token. @@ -67,7 +66,6 @@ async function validate(token: string): Promise { // @ts-ignore return (await promisify(verify)(token, cert)) as JwtPayload; } catch (e: any) { - Logger.debug(e); if (e && e.name === 'TokenExpiredError') throw new TokenExpiredError(); // throws error if the token has not been encrypted by the private key throw new BadTokenError(); @@ -85,7 +83,6 @@ async function decode(token: string): Promise { ignoreExpiration: true, })) as JwtPayload; } catch (e) { - Logger.debug(e); throw new BadTokenError(); } } diff --git a/src/helpers/validator.ts b/src/helpers/validator.ts index d99a22e..4bba1e0 100644 --- a/src/helpers/validator.ts +++ b/src/helpers/validator.ts @@ -1,6 +1,5 @@ import Joi from 'joi'; import { Request, Response, NextFunction } from 'express'; -import Logger from '../core/Logger'; import { BadRequestError } from '../core/ApiError'; import { Types } from 'mongoose'; @@ -44,7 +43,6 @@ export default ( const message = details .map((i) => i.message.replace(/['"]+/g, '')) .join(','); - Logger.info(message); next(new BadRequestError(message)); } catch (error) { diff --git a/tests/.env.test.example b/tests/.env.test.example index fe528c2..c7a34be 100644 --- a/tests/.env.test.example +++ b/tests/.env.test.example @@ -18,10 +18,11 @@ DB_NAME=blogs-test-db DB_MIN_POOL_SIZE=2 DB_MAX_POOL_SIZE=5 -#localhost or IP of the server -# YOUR_TEST_MONGO_DB_HOST_NAME -DB_HOST=localhost -# DB_HOST=mongo +# localhost or IP of the server +# If using the docker installation then use 'mongo' for host name else localhost or ip or db server +# YOUR_MONGO_DB_HOST_NAME +# DB_HOST=localhost +DB_HOST=mongo DB_PORT=27017