remove second middle ware
This commit is contained in:
parent
574905f9f8
commit
62fbfb97b2
11 changed files with 12 additions and 14 deletions
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { authenticateToken } from '../middlewares/checkAuth';
|
import { authenticateToken } from '../middlewares/checkAuth';
|
||||||
import { addToCart, listCart, checkout, clearCart } from '../controllers/cartController';
|
import { addToCart, listCart, checkout, clearCart } from '../controllers/cartController';
|
||||||
import { checkUuid } from '../middlewares/checkUuid';
|
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)
|
||||||
|
|
|
@ -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;
|
|
@ -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 {
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue