@feardread/fear 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FEAR.js +459 -0
- package/FEARServer.js +280 -0
- package/controllers/agent.js +438 -0
- package/controllers/auth/index.js +345 -0
- package/controllers/auth/token.js +50 -0
- package/controllers/blog.js +105 -0
- package/controllers/brand.js +10 -0
- package/controllers/cart.js +425 -0
- package/controllers/category.js +9 -0
- package/controllers/coupon.js +63 -0
- package/controllers/crud/crud.js +508 -0
- package/controllers/crud/index.js +36 -0
- package/controllers/email.js +34 -0
- package/controllers/enquiry.js +65 -0
- package/controllers/events.js +9 -0
- package/controllers/order.js +125 -0
- package/controllers/payment.js +31 -0
- package/controllers/product.js +147 -0
- package/controllers/review.js +247 -0
- package/controllers/tag.js +10 -0
- package/controllers/task.js +10 -0
- package/controllers/upload.js +41 -0
- package/controllers/user.js +401 -0
- package/index.js +7 -0
- package/libs/agent/index.js +561 -0
- package/libs/agent/modules/ai/ai.js +285 -0
- package/libs/agent/modules/ai/chat.js +518 -0
- package/libs/agent/modules/ai/config.js +688 -0
- package/libs/agent/modules/ai/operations.js +787 -0
- package/libs/agent/modules/analyze/api.js +546 -0
- package/libs/agent/modules/analyze/dorks.js +395 -0
- package/libs/agent/modules/ccard/README.md +454 -0
- package/libs/agent/modules/ccard/audit.js +479 -0
- package/libs/agent/modules/ccard/checker.js +674 -0
- package/libs/agent/modules/ccard/payment-processors.json +16 -0
- package/libs/agent/modules/ccard/validator.js +629 -0
- package/libs/agent/modules/code/analyzer.js +303 -0
- package/libs/agent/modules/code/jquery.js +1093 -0
- package/libs/agent/modules/code/react.js +1536 -0
- package/libs/agent/modules/code/refactor.js +499 -0
- package/libs/agent/modules/crypto/exchange.js +564 -0
- package/libs/agent/modules/net/proxy.js +409 -0
- package/libs/agent/modules/security/cve.js +442 -0
- package/libs/agent/modules/security/monitor.js +360 -0
- package/libs/agent/modules/security/scanner.js +300 -0
- package/libs/agent/modules/security/vulnerability.js +506 -0
- package/libs/agent/modules/security/web.js +465 -0
- package/libs/agent/modules/utils/browser.js +492 -0
- package/libs/agent/modules/utils/colorizer.js +285 -0
- package/libs/agent/modules/utils/manager.js +478 -0
- package/libs/cloud/index.js +228 -0
- package/libs/config/db.js +21 -0
- package/libs/config/validator.js +82 -0
- package/libs/db/index.js +318 -0
- package/libs/emailer/imap.js +126 -0
- package/libs/emailer/info.js +41 -0
- package/libs/emailer/smtp.js +77 -0
- package/libs/handler/async.js +3 -0
- package/libs/handler/error.js +66 -0
- package/libs/handler/index.js +161 -0
- package/libs/logger/index.js +49 -0
- package/libs/logger/morgan.js +24 -0
- package/libs/passport/passport.js +109 -0
- package/libs/search/api.js +384 -0
- package/libs/search/features.js +219 -0
- package/libs/search/service.js +64 -0
- package/libs/swagger/config.js +18 -0
- package/libs/swagger/index.js +35 -0
- package/libs/validator/index.js +254 -0
- package/models/blog.js +31 -0
- package/models/brand.js +12 -0
- package/models/cart.js +14 -0
- package/models/category.js +11 -0
- package/models/coupon.js +9 -0
- package/models/customer.js +0 -0
- package/models/enquiry.js +29 -0
- package/models/events.js +13 -0
- package/models/order.js +94 -0
- package/models/product.js +32 -0
- package/models/review.js +14 -0
- package/models/tag.js +10 -0
- package/models/task.js +11 -0
- package/models/user.js +68 -0
- package/package.json +12 -0
- package/routes/agent.js +615 -0
- package/routes/auth.js +13 -0
- package/routes/blog.js +19 -0
- package/routes/brand.js +15 -0
- package/routes/cart.js +105 -0
- package/routes/category.js +16 -0
- package/routes/coupon.js +15 -0
- package/routes/enquiry.js +14 -0
- package/routes/events.js +16 -0
- package/routes/mail.js +170 -0
- package/routes/order.js +19 -0
- package/routes/product.js +22 -0
- package/routes/review.js +11 -0
- package/routes/task.js +12 -0
- package/routes/user.js +17 -0
package/routes/cart.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const Cart = require("../controllers/cart");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const validator = fear.getValidator();
|
|
6
|
+
const handler = fear.getHandler();
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
router.post("/new", validator.request, handler.async(Cart.createCartItem));
|
|
10
|
+
router.post("/user", validator.request, handler.async(Cart.getUserCart));
|
|
11
|
+
router.delete("/empty", validator.request, handler.async(Cart.emptyUserCart));
|
|
12
|
+
router.patch("/quantity/:id", validator.request, handler.async(Cart.updateQuantity))
|
|
13
|
+
|
|
14
|
+
return router;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* GET /api/cart
|
|
19
|
+
* Get current user's cart
|
|
20
|
+
* Query params: userId (optional, for admin/different user)
|
|
21
|
+
|
|
22
|
+
router.get('/',
|
|
23
|
+
validator.request,
|
|
24
|
+
handler.async(Cart.getUserCart)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* POST /api/cart/items
|
|
29
|
+
* Add item to cart
|
|
30
|
+
|
|
31
|
+
router.post('/items',
|
|
32
|
+
validate.item,
|
|
33
|
+
validator.request,
|
|
34
|
+
handler.async(Cart.addCartItem)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* PUT /api/cart/items/:itemId
|
|
39
|
+
* Update cart item quantity (or replace item)
|
|
40
|
+
|
|
41
|
+
router.put('/items/:itemId',
|
|
42
|
+
validate.quantity,
|
|
43
|
+
validator.request,
|
|
44
|
+
handler.async(Cart.updateCartItem)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* PATCH /api/cart/items/:itemId/quantity
|
|
49
|
+
* Update only the quantity of a cart item
|
|
50
|
+
|
|
51
|
+
router.patch('/items/:itemId/quantity',
|
|
52
|
+
[
|
|
53
|
+
param('itemId')
|
|
54
|
+
.isMongoId()
|
|
55
|
+
.withMessage('Valid cart item ID is required'),
|
|
56
|
+
body('quantity')
|
|
57
|
+
.isInt({ min: 0, max: 100 })
|
|
58
|
+
.withMessage('Quantity must be between 0 and 100')
|
|
59
|
+
],
|
|
60
|
+
validateRequest,
|
|
61
|
+
asyncHandler(cartController.updateItemQuantity)
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* DELETE /api/cart/items/:itemId
|
|
66
|
+
* Remove specific item from cart
|
|
67
|
+
|
|
68
|
+
router.delete('/items/:itemId',
|
|
69
|
+
[
|
|
70
|
+
param('itemId')
|
|
71
|
+
.isMongoId()
|
|
72
|
+
.withMessage('Valid cart item ID is required')
|
|
73
|
+
],
|
|
74
|
+
validateRequest,
|
|
75
|
+
asyncHandler(cartController.removeCartItem)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* DELETE /api/cart
|
|
80
|
+
* Empty entire cart
|
|
81
|
+
|
|
82
|
+
router.delete('/',
|
|
83
|
+
userIdValidation,
|
|
84
|
+
validateRequest,
|
|
85
|
+
asyncHandler(cartController.emptyCart)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* GET /api/cart/summary
|
|
90
|
+
* Get cart summary (total items, total price, etc.)
|
|
91
|
+
|
|
92
|
+
router.get('/summary',
|
|
93
|
+
[
|
|
94
|
+
query('userId')
|
|
95
|
+
.optional()
|
|
96
|
+
.isMongoId()
|
|
97
|
+
.withMessage('Valid user ID is required')
|
|
98
|
+
],
|
|
99
|
+
validateRequest,
|
|
100
|
+
asyncHandler(cartController.getCartSummary)
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
module.exports = router;
|
|
105
|
+
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Category = require("../controllers/category");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const validator = fear.getValidator();
|
|
6
|
+
const handler = fear.getHandler();
|
|
7
|
+
|
|
8
|
+
router.get("/all", Category.all);
|
|
9
|
+
router.post("/new", Category.create);
|
|
10
|
+
router.route("/:id")
|
|
11
|
+
.get(Category.read)
|
|
12
|
+
.put(Category.update)
|
|
13
|
+
.delete(Category.delete);
|
|
14
|
+
|
|
15
|
+
return router;
|
|
16
|
+
};
|
package/routes/coupon.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const Coupon = require("../controllers/coupon");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const validator = fear.getValidator();
|
|
6
|
+
const handler = fear.getHandler();
|
|
7
|
+
/*
|
|
8
|
+
router.post("/", Coupon.createCoupon);
|
|
9
|
+
router.get("/", Coupon.getAllCoupons);
|
|
10
|
+
router.get("/:id", Coupon.getCoupon);
|
|
11
|
+
router.put("/:id", Coupon.updateCoupon);
|
|
12
|
+
router.delete("/:id", Coupon.deleteCoupon);
|
|
13
|
+
*/
|
|
14
|
+
return router;
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const Enquiry = require("../controllers/enquiry");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
router.post("/", createEnquiry);
|
|
8
|
+
router.put("/:id", authMiddleware, isAdmin, updateEnquiry);
|
|
9
|
+
router.delete("/:id", authMiddleware, isAdmin, deleteEnquiry);
|
|
10
|
+
router.get("/:id", getEnquiry);
|
|
11
|
+
router.get("/", getallEnquiry);
|
|
12
|
+
*/
|
|
13
|
+
return router;
|
|
14
|
+
}
|
package/routes/events.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Events = require('../controllers/events');
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const handler = fear.getHandler();
|
|
6
|
+
const validator = fear.getValidator();
|
|
7
|
+
|
|
8
|
+
router.get("/all", Events.all);
|
|
9
|
+
router.post("/new", Events.create);
|
|
10
|
+
router.route("/:id")
|
|
11
|
+
.put(Events.update)
|
|
12
|
+
.get(Events.read)
|
|
13
|
+
.delete(Events.delete);
|
|
14
|
+
|
|
15
|
+
return router;
|
|
16
|
+
};
|
package/routes/mail.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const smtp = require("../libs/emailer/smtp");
|
|
2
|
+
const mailinfo = require("../libs/emailer/info");
|
|
3
|
+
const Mail = new smtp(mailinfo);
|
|
4
|
+
|
|
5
|
+
module.exports = ( fear ) => {
|
|
6
|
+
const router = fear.createRouter();
|
|
7
|
+
|
|
8
|
+
router.get('/', (req, res) => {
|
|
9
|
+
Mail.sendEmail()
|
|
10
|
+
.then((response) => res.send(response.message))
|
|
11
|
+
.catch((error) => res.status(500).send(error.message));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
router.post('/contact', (req, res) => {
|
|
15
|
+
Mail.sendContactEmail(req.body)
|
|
16
|
+
.then((response) => res.json({ success: true, message: response.message }))
|
|
17
|
+
.catch((error) => res.status(500).json({ success: false, message: error.message }))
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
router.post("/project", (req, res) => {
|
|
21
|
+
Mail.sendProjectEmail(req.body)
|
|
22
|
+
.then((response) => res.json({ success: true, message: response.message }))
|
|
23
|
+
.catch((error) => res.status(500).json({ success: false, message: error.message }))
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return router;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
router.get("/mailboxes", async (req, res) => {
|
|
31
|
+
const imapWorker = new imap.Worker(ServerInfo);
|
|
32
|
+
|
|
33
|
+
await imapWorker.listMailboxes()
|
|
34
|
+
.then((response) => { return res.status(200).json(response); })
|
|
35
|
+
.catch((error) => { throw new Error(error); })
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// REST Endpoint: List Messages
|
|
39
|
+
router.get("/mailboxes/:mailbox", // specify the name of the mailbox to get messages for
|
|
40
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
41
|
+
try {
|
|
42
|
+
const imapWorker: IMAP.Worker = new IMAP.Worker(serverInfo);
|
|
43
|
+
const messages: IMAP.IMessage[] = await imapWorker.listMessages({
|
|
44
|
+
mailbox: inRequest.params.mailbox // access dynamic value after /mailboxes/
|
|
45
|
+
});
|
|
46
|
+
inResponse.status(200);
|
|
47
|
+
inResponse.json(messages);
|
|
48
|
+
} catch (inError) {
|
|
49
|
+
inResponse.status(400);
|
|
50
|
+
inResponse.send("error");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// REST Endpoint: Get a Message
|
|
56
|
+
router.get("/messages/:mailbox/:id",
|
|
57
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
58
|
+
try {
|
|
59
|
+
const imapWorker: IMAP.Worker = new IMAP.Worker(serverInfo);
|
|
60
|
+
const messageBody: string = await imapWorker.getMessageBody({
|
|
61
|
+
mailbox: inRequest.params.mailbox, // the name of the mailbox
|
|
62
|
+
id: parseInt(inRequest.params.id, 10) // the ID of the message (str -> int)
|
|
63
|
+
});
|
|
64
|
+
inResponse.status(200);
|
|
65
|
+
inResponse.send(messageBody); // returned as plain text
|
|
66
|
+
} catch (inError) {
|
|
67
|
+
inResponse.status(400);
|
|
68
|
+
inResponse.send("error");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// REST Endpoint: Delete a Message
|
|
74
|
+
// the app.delete() method is used to register this endpoint.
|
|
75
|
+
router.delete("/messages/:mailbox/:id",
|
|
76
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
77
|
+
try {
|
|
78
|
+
const imapWorker: IMAP.Worker = new IMAP.Worker(serverInfo);
|
|
79
|
+
await imapWorker.deleteMessage({
|
|
80
|
+
mailbox: inRequest.params.mailbox,
|
|
81
|
+
id: parseInt(inRequest.params.id, 10)
|
|
82
|
+
});
|
|
83
|
+
inResponse.status(200);
|
|
84
|
+
inResponse.send("ok");
|
|
85
|
+
} catch (inError) {
|
|
86
|
+
inResponse.status(400);
|
|
87
|
+
inResponse.send("error");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// REST Endpoint: Send a Message
|
|
93
|
+
// app.post() is used to send a message
|
|
94
|
+
// IMAP protocol: retrieving mailboxes and messages
|
|
95
|
+
// SMTP protocol: send messages
|
|
96
|
+
router.post("/messages",
|
|
97
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
98
|
+
try {
|
|
99
|
+
const smtpWorker: SMTP.Worker = new SMTP.Worker(serverInfo);
|
|
100
|
+
await smtpWorker.sendMessage(inRequest.body);
|
|
101
|
+
inResponse.status(201);
|
|
102
|
+
inResponse.send("ok");
|
|
103
|
+
} catch (inError) {
|
|
104
|
+
inResponse.status(400);
|
|
105
|
+
inResponse.send("error");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// REST Endpoint: List Contacts
|
|
111
|
+
router.get("/contacts",
|
|
112
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
113
|
+
try {
|
|
114
|
+
const contactsWorker: Contacts.Worker = new Contacts.Worker();
|
|
115
|
+
const contacts: IContact[] = await contactsWorker.listContacts();
|
|
116
|
+
inResponse.status(200);
|
|
117
|
+
inResponse.json(contacts);
|
|
118
|
+
} catch (inError) {
|
|
119
|
+
inResponse.status(400);
|
|
120
|
+
inResponse.send("error");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// REST Endpoint: Add Contact
|
|
126
|
+
router.post("/contacts",
|
|
127
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
128
|
+
try {
|
|
129
|
+
const contactsWorker: Contacts.Worker = new Contacts.Worker();
|
|
130
|
+
const contact: IContact = await contactsWorker.addContact(inRequest.body); // contain a unique identifier
|
|
131
|
+
inResponse.status(201);
|
|
132
|
+
inResponse.json(contact);
|
|
133
|
+
} catch (inError) {
|
|
134
|
+
inResponse.status(400);
|
|
135
|
+
inResponse.send("error");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// REST Endpoint: Update Contacts
|
|
141
|
+
router.put("/contacts",
|
|
142
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
143
|
+
try {
|
|
144
|
+
const contactsWorker: Contacts.Worker = new Contacts.Worker();
|
|
145
|
+
const contact: IContact = await contactsWorker.updateContact(inRequest.body);
|
|
146
|
+
inResponse.status(202);
|
|
147
|
+
inResponse.json(contact);
|
|
148
|
+
} catch (inError) {
|
|
149
|
+
inResponse.status(400);
|
|
150
|
+
inResponse.send("error");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// REST Endpoint: Delete Contact
|
|
156
|
+
router.delete("/contacts/:id",
|
|
157
|
+
async (inRequest: Request, inResponse: Response) => {
|
|
158
|
+
try {
|
|
159
|
+
const contactsWorker: Contacts.Worker = new Contacts.Worker();
|
|
160
|
+
await contactsWorker.deleteContact(inRequest.params.id); // includes the ID of the contact to delete
|
|
161
|
+
inResponse.status(200);
|
|
162
|
+
inResponse.send("ok");
|
|
163
|
+
} catch (inError) {
|
|
164
|
+
inResponse.status(400);
|
|
165
|
+
inResponse.send("error");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
*/
|
|
170
|
+
|
package/routes/order.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const Order = require("../controllers/order");
|
|
2
|
+
|
|
3
|
+
module.exports = ( fear ) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const handler = fear.getHandler();
|
|
6
|
+
const validator = fear.getValidator();
|
|
7
|
+
|
|
8
|
+
router.get("/all", Order.list);
|
|
9
|
+
router.post("/new", Order.create);
|
|
10
|
+
router.route('/:id')
|
|
11
|
+
.get(Order.read)
|
|
12
|
+
.put(Order.update);
|
|
13
|
+
|
|
14
|
+
router.get("/myOrders", Order.getMyOrders);
|
|
15
|
+
router.get("/monthly", Order.getMonthWiseOrderIncome);
|
|
16
|
+
router.get("/yearly", Order.getYearlyTotalOrder);
|
|
17
|
+
|
|
18
|
+
return router;
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const Product = require("../controllers/product");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const validator = fear.getValidator();
|
|
6
|
+
const handler = fear.getHandler();
|
|
7
|
+
|
|
8
|
+
router.get("/", Product.list)
|
|
9
|
+
.get("/all", Product.all)
|
|
10
|
+
.post("/new", Product.create)
|
|
11
|
+
.get("/edit/:id", Product.read);
|
|
12
|
+
|
|
13
|
+
router.route("/search").post(Product.search);
|
|
14
|
+
router.route('/search/all').get(Product.productSearch);
|
|
15
|
+
router.route("/one").get(handler.async(Product.read));
|
|
16
|
+
router.route("/:id")
|
|
17
|
+
.get(handler.async(Product.read))
|
|
18
|
+
.put(handler.async(Product.update))
|
|
19
|
+
.delete(handler.async(Product.delete));
|
|
20
|
+
|
|
21
|
+
return router;
|
|
22
|
+
};
|
package/routes/review.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Review = require("../controllers/review");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
|
|
6
|
+
router.post("/new", Review.review)
|
|
7
|
+
.get("/rating", Review.rating)
|
|
8
|
+
.get("/product/:id", Review.getProductReviews);
|
|
9
|
+
|
|
10
|
+
return router;
|
|
11
|
+
};
|
package/routes/task.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const Task = require('../controllers/task');
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
|
|
6
|
+
router.post("/new", Task.create)
|
|
7
|
+
.put("/:id", Task.update)
|
|
8
|
+
.delete("/:id", Task.delete)
|
|
9
|
+
.get("/all", Task.all);
|
|
10
|
+
|
|
11
|
+
return router;
|
|
12
|
+
};
|
package/routes/user.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
const User = require("../controllers/user");
|
|
3
|
+
|
|
4
|
+
module.exports = (fear) => {
|
|
5
|
+
const router = fear.createRouter();
|
|
6
|
+
const validator = fear.getValidator();
|
|
7
|
+
const handler = fear.getHandler();
|
|
8
|
+
|
|
9
|
+
router.get("/all", User.all);
|
|
10
|
+
router.route("/:id", validator.isAuthorized)
|
|
11
|
+
.get(User.read)
|
|
12
|
+
.post(User.create)
|
|
13
|
+
.put(User.update)
|
|
14
|
+
.delete(User.delete);
|
|
15
|
+
|
|
16
|
+
return router;
|
|
17
|
+
};
|