Skip to content

Commit

Permalink
Refactor/architecture code review (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
helabenkhalfallah authored Nov 29, 2024
2 parents cbd51fd + cee1c37 commit c5d4338
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 153 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ database/psql/**
**/v6y-logs/**
.vscode/
**/coverage**
**/.DS_Store
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"devDependencies": {
"husky": "=9.1.4",
"nx": "=19.3.0",
"typescript-coverage-report": "^1.0.0"
"typescript-coverage-report": "=1.0.0"
},
"dependencies": {},
"workspaces": [
"src/**"
]
Expand Down
90 changes: 35 additions & 55 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/v6y-bff/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
import { AppLogger, DataBaseManager, ServerUtils, passportInitialize } from '@v6y/commons';
import { AppLogger, DataBaseManager, ServerUtils, configureAuthMiddleware } from '@v6y/commons';
import Express from 'express';
import ExpressStatusMonitor from 'express-status-monitor';

Expand Down Expand Up @@ -35,7 +35,7 @@ app.use(

// *********************************************** Graphql Config & Endpoints ***********************************************

app.use(passportInitialize());
app.use(configureAuthMiddleware());

const httpServer = createServer({
app,
Expand Down
6 changes: 3 additions & 3 deletions src/v6y-bff/src/resolvers/account/AccountQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AppLogger,
PasswordUtils,
SearchQueryType,
passportGenerateToken,
generateAuthenticationToken,
} from '@v6y/commons';

const { validatePassword } = PasswordUtils;
Expand Down Expand Up @@ -76,7 +76,7 @@ const getAccountListByPageAndParams = async (_: unknown, args: SearchQueryType)
/**
* Login account
* @param _
* @param paramsc
* @param params
*/
const loginAccount = async (_: unknown, params: { input: AccountLoginType }) => {
try {
Expand All @@ -103,7 +103,7 @@ const loginAccount = async (_: unknown, params: { input: AccountLoginType }) =>
return null;
}

const token = passportGenerateToken(accountDetails);
const token = generateAuthenticationToken(accountDetails);

AppLogger.info(`[AccountMutations - loginAccount] login success : ${accountDetails._id}`);

Expand Down
4 changes: 2 additions & 2 deletions src/v6y-bff/src/resolvers/manager/AuthenticationManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloServer } from '@apollo/server';
import { expressMiddleware } from '@apollo/server/express4';
import { passportAuthenticate } from '@v6y/commons';
import { validateCredentials } from '@v6y/commons';
import BodyParser from 'body-parser';
import Cors from 'cors';
import { RequestHandler } from 'express';
Expand All @@ -19,7 +19,7 @@ export function buildUserMiddleware(
req.body?.operationName !== 'LoginAccount' &&
req.body?.operationName !== 'IntrospectionQuery'
) {
const user = await passportAuthenticate(req);
const user = await validateCredentials(req);
if (!user) {
throw new Error('Unauthorized');
}
Expand Down
Loading

0 comments on commit c5d4338

Please sign in to comment.