Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ff9776

Browse files
committed
final changes
1 parent9de660c commit2ff9776

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

‎Dockerfile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:10.19.0
2+
3+
WORKDIR /app
4+
5+
6+
COPY package*.json ./
7+
8+
RUN npm install
9+
10+
COPY . .
11+
12+
EXPOSE 9000
13+
14+
CMD ["node","server.js" ]

‎controllers/adminController.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports.addAgent = async (req, res) => {
3535
try{
3636
constuser=awaitUser.create({ email, password,name,role:"AGENT"});
3737

38-
res.status(201).json({user:user});
38+
res.status(201).json({user:user,message:"Added Succesfully"});
3939
}
4040
catch(err){
4141
leterror=err.message
@@ -58,4 +58,7 @@ module.exports.updateLoanStatus = async (req, res) => {
5858
res.status(400).json({error:error});
5959
}
6060
}
61+
62+
63+
6164

‎controllers/agentController.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,18 @@ module.exports.getLoans = async (req, res) => {
5454
res.status(400).json({error:error});
5555
}
5656
}
57+
58+
59+
module.exports.updateLoan=async(req,res)=>{
60+
const{ loan_id,interestRate, duration,amount}=req.body;
61+
try{
62+
constuser=awaitLoan.updateOne({_id:loan_id},{interestRate, duration,amount});
63+
res.status(201).json({message:"Done successfully"});
64+
}
65+
catch(err){
66+
leterror=err.message
67+
res.status(400).json({error:error});
68+
}
69+
}
5770

5871

‎middleware/checkPermission.js‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ const {getUser} = require("../util/getUser");
33
module.exports.checkPermission=(permission)=>{
44
returnasync(req,res,next)=>{
55
consttoken=req.headers.authorization;
6-
awaitgetUser(token,(user)=>{
7-
if(user&&user.user.role==permission){
8-
next();
9-
}else{
10-
res.status(403).json({message:"Forbidden: you don't have enough access to this content"});
11-
}
12-
})
6+
if(token){
7+
awaitgetUser(token,(user)=>{
8+
if(user&&user.user.role==permission){
9+
next();
10+
}else{
11+
res.status(403).json({message:"Forbidden: you don't have enough access to this content"});
12+
}
13+
})
14+
}else{
15+
res.status(401).json({message:"Unauthorised Request"})
16+
}
1317
}
1418
}

‎routes/agentRoute.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ const router = Router();
66
router.post("/create-loan",agentController.createLoan);
77
router.get("/get-users",agentController.getUsers)
88
router.get("/get-loans",agentController.getLoans)
9+
router.put("/update-loan",agentController.updateLoan)
910

1011
module.exports=router;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp