Skip to content

Commit

Permalink
chore: Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
plibither8 committed Nov 10, 2021
1 parent f329d16 commit 10f4f8b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/lib/validators/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export default async function validate(req, res, next) {
return;
}

if(user.banned){
if (user.banned) {
await prisma.session.delete({ where: { sid: req.sessionID } });
req.session.destroy(() => {
respond(res, req, 400, ERROR.ACCOUNT_BANNED, undefined);
});
return;
}

req.session.lastActive = currentTime;
req.user = user;

Expand Down
12 changes: 10 additions & 2 deletions src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ route.post("/register", async (req: any, res, next) => {
verified: false,
},
});
log({ ...req, user }, "UPDATE", `Credentials updated for user ${user.id}`);
log(
{ ...req, user },
"UPDATE",
`Credentials updated for user ${user.id}`
);
} else {
user = await prisma.user.create({
data: {
Expand All @@ -75,7 +79,11 @@ route.post("/register", async (req: any, res, next) => {
password: hashedPassword,
},
});
log({ ...req, user }, "CREATE", `New user ${user.id}, '${user.name}' registered`);
log(
{ ...req, user },
"CREATE",
`New user ${user.id}, '${user.name}' registered`
);
}
} catch (exception) {
console.error(exception);
Expand Down
1 change: 0 additions & 1 deletion src/routes/buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { respond } from "src/lib/request-respond";
import prisma from "src/prisma";
const route = express();


route.get(
"/orders",
isUser,
Expand Down
16 changes: 10 additions & 6 deletions src/routes/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,24 @@ route.post(
try {
const product = await prisma.product.findUnique({
where: { id: productId },
include:{
include: {
seller: {
include: {
user: true
}
}
}
user: true,
},
},
},
});
if (!product) {
respond(res, req, 404, ERROR.PRODUCT_NOT_FOUND);
return;
}

if(product && product.seller.user.banned || product.seller.user.deleted || product.banned){
if (
(product && product.seller.user.banned) ||
product.seller.user.deleted ||
product.banned
) {
respond(res, req, 404, ERROR.PRODUCT_NOT_FOUND);
return;
}
Expand Down
6 changes: 5 additions & 1 deletion src/routes/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ route.post(
},
});

log(req, "CREATE", `New product ${product.id} '${product.name}' added to marketplace`);
log(
req,
"CREATE",
`New product ${product.id} '${product.name}' added to marketplace`
);
respond(res, req, 200, "success", product);
} catch (err) {
console.error(err);
Expand Down
6 changes: 5 additions & 1 deletion src/routes/sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ route.post(
approvalDocument: req.file.filename,
},
});
log(req, "CREATE", `Seller ${req.user.id} '${req.user.name}' profile created with proposal`);
log(
req,
"CREATE",
`Seller ${req.user.id} '${req.user.name}' profile created with proposal`
);
respond(res, req, 200, "success");
} catch (err) {
respond(res, req, 500, INTERNAL_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ route.post(
data: { banned: true },
});

log(req, "UPDATE", `User ${userId} banned`)
log(req, "UPDATE", `User ${userId} banned`);
respond(res, req, 200, "Success");
} catch (error) {
// Record not found
Expand Down

0 comments on commit 10f4f8b

Please sign in to comment.