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 { Request, Response } from 'express';
import { Cart, ICart } from '../models/cartModel'; import { Cart, ICart } from '../schemas/cartModel';
import { Product } from '../models/productModel'; import { Product } from '../schemas/productModel';
import { Order } from '../models/orderModel'; import { Order } from '../schemas/orderModel';
import { sendEmailasync } from '../services/sendGrid'; import { sendEmailasync } from '../services/sendGrid';
import { config } from 'dotenv'; import { config } from 'dotenv';

View file

@ -1,5 +1,5 @@
import { Request, Response } from 'express'; 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) { export async function createProduct(req: Request, res: Response) {
try { try {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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