Skip to content

Commit

Permalink
chore:minor modification
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperMindset123 committed Sep 28, 2024
1 parent 2f8fc16 commit d3a0353
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib/api/auth/auth.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { generateAccessAndRefreshTokens } from '../../utils/jwt';
import { addRefreshTokenToWhiteList } from './auth.services';
import { findUserByEmail, createUserByEmailAndPassword } from '../users/users.services';

const app = express();
//const app = express();
//@see https://expressjs.com/en/guide/routing.html
const authRouter = Router();

// TODO : Test this route using CURL
app.post('/register', async (req, res, next) => {
authRouter.post('/register', async (req, res, next) => {
try {
// object destructuring to help retrieve
// @see https://www.geeksforgeeks.org/how-to-post-json-data-using-curl/
Expand Down
4 changes: 2 additions & 2 deletions src/lib/api/auth/test.rest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

POST http://localhost:4001/register
POST http://localhost:4001/auth/register
content-type: application/json

{
"email" :"asdasda@gmail.com",
"email" :"again@gmail.com",
"password":"123123asdasd"
}

14 changes: 9 additions & 5 deletions src/lib/api/server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
//! use this to add all the relevant main routes here

//import { authRouter } from './auth/auth.routes';
import { authRouter } from './auth/auth.routes';
import express from 'express';

const app = express();
// ** needed to add express.json()
app.use(express.json());
// eslint-disable-next-line @typescript-eslint/no-unused-vars
//@see https://medium.com/@pierrephilip/better-route-registration-with-express-js-740c0f342c10
const router = express.Router();
//router.use('/auth', authRouter);
router.use(express.json());
router.use('/auth', authRouter);
//http://localhost:4001/auth/register

app.use(router);
app.get('/test', (req, res) => {
console.log('hello world');
res.send('Hello from A!').status(200);
Expand All @@ -20,15 +22,16 @@ app.get('/test', (req, res) => {
app.listen('4001', () => {
console.log(`Listening to port 4001`);
});

// ** don't remove, old working changes
/*
import { v4 as uuidv4 } from 'uuid';
import { generateAccessAndRefreshTokens } from '../utils/jwt';
import { addRefreshTokenToWhiteList } from './auth/auth.services';
import { findUserByEmail, createUserByEmailAndPassword } from './users/users.services';
//const app = express();
//@see https://expressjs.com/en/guide/routing.html
const authRouter = express.Router();
//const authRouter = express.Router();
// TODO : Test this route using CURL
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -78,3 +81,4 @@ app.post('/register', async (req, res, next) => {
console.error(err);
}
});
*/
2 changes: 2 additions & 0 deletions src/lib/utils/tokenization.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
//@ts-expect-error
import * as cryptoTS from 'crypto-ts';

function encryptToken(token: any) {
Expand Down

0 comments on commit d3a0353

Please sign in to comment.