remove second middle ware

This commit is contained in:
Kfir Dayan 2023-06-15 11:34:43 +03:00
parent 574905f9f8
commit 62fbfb97b2
11 changed files with 12 additions and 14 deletions

View file

@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import { Cart, ICart } from '../models/cartModel';
import { Product } from '../models/productModel';
import { Order } from '../models/orderModel';
import { Cart, ICart } from '../schemas/cartModel';
import { Product } from '../schemas/productModel';
import { Order } from '../schemas/orderModel';
import { sendEmailasync } from '../services/sendGrid';
import { config } from 'dotenv';

View file

@ -1,5 +1,5 @@
import { Request, Response } from 'express';
import { Product, IProduct } from '../models/productModel';
import { Product, IProduct } from '../schemas/productModel';
export async function createProduct(req: Request, res: Response) {
try {

View file

@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import bcrypt from 'bcryptjs';
import jwt from 'jsonwebtoken';
import { User, IUser } from '../models/userModel';
import { User, IUser } from '../schemas/userModel';
import { clearJwtCookie, setJwtCookie } from '../middlewares/checkAuth';
import validate from 'deep-email-validator';

View file

@ -4,7 +4,7 @@ import cookieParser from 'cookie-parser';
import userRouter from './routes/userRouter';
import productRouter from './routes/productRouter';
import cartRouter from './routes/cartRoute';
import cartRouter from './routes/cartRouter';
const env = require('dotenv').config().parsed;

View file

@ -1,14 +1,14 @@
import express from 'express';
import { authenticateToken } from '../middlewares/checkAuth';
import { addToCart, listCart, checkout, clearCart } from '../controllers/cartController';
import { checkUuid } from '../middlewares/checkUuid';
import { checkUuid } from '../middlewares/checkUuid';
const cartRouter = express.Router();
cartRouter.post('/', [authenticateToken, checkUuid], addToCart);
cartRouter.get('/', [authenticateToken, checkUuid], listCart);
cartRouter.post('/', [authenticateToken], addToCart);
cartRouter.get('/', [authenticateToken], listCart);
cartRouter.post('/checkout', authenticateToken, checkout);
cartRouter.delete('/', authenticateToken, clearCart)

View file

@ -4,9 +4,9 @@ import { createUser, login, logout, getAllUsers, deleteUser } from '../controlle
const userRouter = express.Router();
userRouter.post('/', createUser);
userRouter.get('/', getAllUsers);
userRouter.post('/login', login);
userRouter.post('/logout', logout);
userRouter.get('/all', getAllUsers);
userRouter.delete('/:id', deleteUser)
export default userRouter;

View file

@ -1,5 +1,3 @@
// src/models/userModel.ts
import mongoose, { Schema, Document } from 'mongoose';
interface IUser extends Document {

View file

@ -1,6 +1,6 @@
import { config } from "dotenv";
import { Order } from "../models/orderModel";
import { User } from "../models/userModel";
import { Order } from "../schemas/orderModel";
import { User } from "../schemas/userModel";
import client from '@sendgrid/mail';
config();