Skip to content
Open
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
29 changes: 29 additions & 0 deletions bruno/MVEP/address/Create Address.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
meta {
name: Create Address
type: http
seq: 2
}

post {
url: {{url}}address
body: json
auth: none
}

body:json {
{
"createdBy":"668ff65c49d6d8547222578b",
"name":"Home",
"doorNo":"4-176/1",
"email":"test@gmail.com",
"phone":"76599645868",
"street":"4th street",
"city":"Malikipuram",
"state":"Andhra Pradhes",
"zip":"533253",
"isDefault":true,
"additionalInstructions":"PLease be fast enough",
"coordinates":["-127.256","124.256"]

}
}
11 changes: 11 additions & 0 deletions bruno/MVEP/address/Delete Address.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Delete Address
type: http
seq: 5
}

delete {
url: {{url}}address/6690e093df3fbfdb92fedf72
body: none
auth: none
}
11 changes: 11 additions & 0 deletions bruno/MVEP/address/Get Users Address.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Get Users Address
type: http
seq: 6
}

get {
url: {{url}}address/user/668ff65c49d6d8547222578b
body: none
auth: none
}
11 changes: 11 additions & 0 deletions bruno/MVEP/address/Get address by Id.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Get address by Id
type: http
seq: 3
}

get {
url: {{url}}address/6690e26784b3e646dae86bb9
body: none
auth: none
}
11 changes: 11 additions & 0 deletions bruno/MVEP/address/Get all address.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Get all address
type: http
seq: 1
}

get {
url: {{url}}address
body: none
auth: none
}
11 changes: 11 additions & 0 deletions bruno/MVEP/address/Get user Default Address.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Get user Default Address
type: http
seq: 7
}

get {
url: {{url}}address/default/668ff65c49d6d8547222578b
body: none
auth: none
}
19 changes: 19 additions & 0 deletions bruno/MVEP/address/Update Address By Id.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: Update Address By Id
type: http
seq: 4
}

put {
url: {{url}}address/6690d45f8102ba5718734c86
body: json
auth: none
}

body:json {
{
"state":"Andhra Pradesh",
"zip":"533453",
"isDefault":true
}
}
4 changes: 2 additions & 2 deletions bruno/MVEP/sudo-users/login.bru
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ post {

body:json {
{
"email" : "eswarmamidi19@gmail.com",
"password" : "eswar@4321"
"email" : "root@gmail.com",
"password" : "password"
}
}
11 changes: 11 additions & 0 deletions bruno/MVEP/users/deleteUserById.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: deleteUserById
type: http
seq: 6
}

delete {
url: {{url}}user/66758b9891f947ae7f4f5f34
body: none
auth: none
}
17 changes: 17 additions & 0 deletions bruno/MVEP/users/forgot-password.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta {
name: forgot-password
type: http
seq: 7
}

post {
url: {{url}}user/forgot-password
body: json
auth: none
}

body:json {
{
"email":"testingclass@gmail.com"
}
}
11 changes: 11 additions & 0 deletions bruno/MVEP/users/get all users.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: get all users
type: http
seq: 2
}

get {
url: {{url}}user
body: none
auth: none
}
11 changes: 11 additions & 0 deletions bruno/MVEP/users/getUserById.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: getUserById
type: http
seq: 4
}

get {
url: {{url}}user/668ff65c49d6d8547222578b
body: none
auth: none
}
18 changes: 18 additions & 0 deletions bruno/MVEP/users/login.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
meta {
name: login
type: http
seq: 1
}

post {
url: {{url}}user/login
body: json
auth: none
}

body:json {
{
"email":"testingclass@gmail.com",
"password":"123"
}
}
11 changes: 11 additions & 0 deletions bruno/MVEP/users/logout.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: logout
type: http
seq: 3
}

post {
url: {{url}}user/logout
body: none
auth: none
}
19 changes: 19 additions & 0 deletions bruno/MVEP/users/reset-password.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: reset-password
type: http
seq: 8
}

post {
url: {{url}}user/reset-password
body: json
auth: none
}

body:json {
{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NjhmZjY1YzQ5ZDZkODU0NzIyMjU3OGIiLCJpYXQiOjE3MjA3NjU5MTUsImV4cCI6MTcyMDc2NjUxNX0.2vG4IRRW6df3WhdMksu92CSqAWgiBE2UpG3cNQuM7Eg",
"password":"123",
"verify_password":"123"
}
}
22 changes: 22 additions & 0 deletions bruno/MVEP/users/updateUserById.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
meta {
name: updateUserById
type: http
seq: 5
}

put {
url: {{url}}user/66758b9891f947ae7f4f5f34
body: json
auth: none
}

body:json {
{
"cart":[
{
"itemName":"IphoneX",
"price":"20000"
}
]
}
}
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import App from "./app";
import UserAddressController from "./resources/Address/address-controller";
import RegionController from "./resources/Regions/region-controller";
import SudouserController from "./resources/Sudouser/sudouser-controller";
import UserController from "./resources/User/user-controller";
import { Controller } from "./utils/interfaces/controller-interface";
import {config} from "dotenv";
import { config } from "dotenv";

config();
config();

const controllers :Controller[] =[new SudouserController() , new RegionController(),new UserController];
const app = new App(controllers , Number(process.env.PORT));
const controllers: Controller[] = [new SudouserController(), new RegionController(), new UserController, new UserAddressController];
const app = new App(controllers, Number(process.env.PORT));
app.listen();
8 changes: 4 additions & 4 deletions src/middleware/forgot-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import jwt from "jsonwebtoken"
import { Request, Response, NextFunction } from "express-serve-static-core"
import { NextFunction, Request, Response } from "express-serve-static-core";
import jwt from "jsonwebtoken";

export const verifyPasswordReset = async (req: Request, res: Response, next: NextFunction) => {
try {
const { token } = req.params;
const { token } = req.body;

if (!token) {
return res.status(401).json({ message: "UnAuthorized" });
}
await jwt.verify(token, process.env.JWT_SECRET!, (err, decoded) => {
jwt.verify(token, process.env.JWT_SECRET!, (err:any, decoded:any) => {
if (err) {
if (err.name === 'TokenExpiredError') {
return res.status(401).send({ error: "Token has expired" });
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/permissions-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const verifySuperAdmin = expressAsyncHandler(
async (req: Request, res: Response, next: NextFunction) => {
const loggedInSudoUser = await SudoUser.findById(req.loggedInSudoUserId);
if (!loggedInSudoUser) {
res.json(400);
res.status(400);
throw new Error("Sudo user is not logged in");
}
if (loggedInSudoUser?.role !== 1) {
Expand Down
Loading