Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add simple auth/validate-token route #68

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ export const register = async (req, res: CustomResponse) => {
errorHandler(res, err);
}
}

export const validateToken = async (req, res: CustomResponse) => {
try {
return res.status(200).json({ status: RESPONSE_STATUS.success });
} catch (err) {
errorHandler(res, err);
}
}
4 changes: 2 additions & 2 deletions src/routes/accounts.route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Router } from 'express';
import { authenticateJwt } from '../middlewares/passport';
import { authenticateJwt } from '@middlewares/passport';
import {
getAccounts,
getAccountById,
createAccount,
updateAccount,
deleteAccount,
} from '../controllers/accounts.controller';
} from '@controllers/accounts.controller';

const router = Router({});

Expand Down
7 changes: 5 additions & 2 deletions src/routes/auth.route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Router } from 'express';
import { authenticateJwt } from '@middlewares/passport';
import {
login,
register,
} from '../controllers/auth.controller';
import validation from '../middlewares/validations';
validateToken,
} from '@controllers/auth.controller';
import validation from '@middlewares/validations';

const router = Router({});

router.get('/validate-token', authenticateJwt, validateToken)
router.post('/login', [], validation, login);
router.post('/register', [], validation, register);

Expand Down
2 changes: 0 additions & 2 deletions src/services/transactions/create-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export interface CreateTransferTransactionParams {
}: CreateTransactionParams & CreateTransferTransactionParams) => {
let transaction: Transaction = null;

console.log('categoryId', categoryId)

transaction = await connection.sequelize.transaction();

try {
Expand Down