nodejs-backpack 0.0.1-security → 2.0.22
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.
Potentially problematic release.
This version of nodejs-backpack might be problematic. Click here for more details.
- package/.sample-env +3 -0
- package/helper.js +76 -0
- package/index.js +131 -0
- package/package.json +53 -6
- package/readme.md +155 -0
- package/sample-app.js +41 -0
- package/sample-auth-controller.js +217 -0
- package/sample-auth-middleware.js +44 -0
- package/sample-auth-route.js +19 -0
- package/sample-config-mailer.js +10 -0
- package/sample-controller.js +174 -0
- package/sample-env +4 -0
- package/sample-file-uploader.js +27 -0
- package/sample-form-parser.js +5 -0
- package/sample-helper.js +138 -0
- package/sample-index-route.js +7 -0
- package/sample-package.json +29 -0
- package/sample-route.js +20 -0
- package/sample-schema-ResetToken.js +26 -0
- package/sample-schema-User.js +51 -0
- package/sample-schema.js +49 -0
- package/sample-validation.js +4 -0
- package/typing.gif +0 -0
- package/README.md +0 -5
package/sample-route.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
const express = require('express');
|
2
|
+
const router = express.Router();
|
3
|
+
const ${fileName}Controller = require('../controllers/${fileName}Controller');
|
4
|
+
const ListValidationRequest = require('./validationRequest/${fileName}/ListValidationRequest');
|
5
|
+
const GetDetailValidationRequest = require('./validationRequest/${fileName}/GetDetailValidationRequest');
|
6
|
+
const StoreValidationRequest = require('./validationRequest/${fileName}/StoreValidationRequest');
|
7
|
+
const UpdateValidationRequest = require('./validationRequest/${fileName}/UpdateValidationRequest');
|
8
|
+
const DestroyValidationRequest = require('./validationRequest/${fileName}/DestroyValidationRequest');
|
9
|
+
const upload = require('../helpers/fileUploader');
|
10
|
+
const formParser = require('../helpers/formParser');
|
11
|
+
|
12
|
+
const prefix = '${apiUrl}';
|
13
|
+
|
14
|
+
router.get(`/${prefix}/`,formParser,ListValidationRequest, ${fileName}Controller.list);
|
15
|
+
router.get(`/${prefix}/:id`,formParser,GetDetailValidationRequest, ${fileName}Controller.getDetail);
|
16
|
+
router.post(`/${prefix}/`,upload(prefix).any(),StoreValidationRequest, ${fileName}Controller.store);
|
17
|
+
router.put(`/${prefix}/:id`,upload(prefix).any(),UpdateValidationRequest, ${fileName}Controller.update);
|
18
|
+
router.delete(`/${prefix}/:id`,formParser,DestroyValidationRequest, ${fileName}Controller.destroy);
|
19
|
+
|
20
|
+
module.exports = router;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const mongoose = require("mongoose");
|
2
|
+
const Schema = mongoose.Schema;
|
3
|
+
const { appendParams } = require("mongoose-backpack");
|
4
|
+
|
5
|
+
const ResetToken = new Schema(
|
6
|
+
{
|
7
|
+
email: {
|
8
|
+
type: String,
|
9
|
+
required: true,
|
10
|
+
},
|
11
|
+
reset_token: {
|
12
|
+
type: String,
|
13
|
+
required: false,
|
14
|
+
},
|
15
|
+
},
|
16
|
+
{ timestamps: true }
|
17
|
+
);
|
18
|
+
|
19
|
+
appendData = {
|
20
|
+
id: function () {
|
21
|
+
return this._id;
|
22
|
+
},
|
23
|
+
};
|
24
|
+
appendParams(ResetToken, appendData);
|
25
|
+
|
26
|
+
module.exports = mongoose.model("ResetToken", ResetToken);
|
@@ -0,0 +1,51 @@
|
|
1
|
+
const mongoose = require("mongoose");
|
2
|
+
const Schema = mongoose.Schema;
|
3
|
+
const { appendParams } = require("mongoose-backpack");
|
4
|
+
|
5
|
+
const User = new Schema(
|
6
|
+
{
|
7
|
+
first_name: {
|
8
|
+
type: String,
|
9
|
+
required: true,
|
10
|
+
},
|
11
|
+
last_name: {
|
12
|
+
type: String,
|
13
|
+
required: true,
|
14
|
+
},
|
15
|
+
email: {
|
16
|
+
type: String,
|
17
|
+
required: true,
|
18
|
+
},
|
19
|
+
phone_no: {
|
20
|
+
type: String,
|
21
|
+
required: false,
|
22
|
+
},
|
23
|
+
password: {
|
24
|
+
type: String,
|
25
|
+
required: true,
|
26
|
+
},
|
27
|
+
image: {
|
28
|
+
type: String,
|
29
|
+
required: false,
|
30
|
+
},
|
31
|
+
token: {
|
32
|
+
type: String,
|
33
|
+
required: false,
|
34
|
+
},
|
35
|
+
},
|
36
|
+
{ timestamps: true }
|
37
|
+
);
|
38
|
+
|
39
|
+
appendData = {
|
40
|
+
id: function () {
|
41
|
+
return this._id;
|
42
|
+
},
|
43
|
+
full_name: function () {
|
44
|
+
const firstName = this?.first_name ? this.first_name + " " : "";
|
45
|
+
const lastName = this?.last_name ? this.last_name : "";
|
46
|
+
return `${firstName}${lastName}`;
|
47
|
+
},
|
48
|
+
};
|
49
|
+
appendParams(User, appendData);
|
50
|
+
|
51
|
+
module.exports = mongoose.model("User", User);
|
package/sample-schema.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
const mongoose = require("mongoose");
|
2
|
+
const Schema = mongoose.Schema;
|
3
|
+
const { appendParams } = require("mongoose-backpack");
|
4
|
+
|
5
|
+
const ${fileContent} = new Schema(
|
6
|
+
{
|
7
|
+
name: {
|
8
|
+
type: String,
|
9
|
+
required: true,
|
10
|
+
},
|
11
|
+
},
|
12
|
+
{ timestamps: true }
|
13
|
+
);
|
14
|
+
|
15
|
+
const appendData = {
|
16
|
+
id: function () {
|
17
|
+
return this._id;
|
18
|
+
},
|
19
|
+
};
|
20
|
+
appendParams(${fileContent}, appendData);
|
21
|
+
|
22
|
+
const ${fileContent}Model = mongoose.model("${fileContent}", ${fileContent});
|
23
|
+
|
24
|
+
// Created a change stream. The 'change' event gets emitted when there's a change in the database
|
25
|
+
/*
|
26
|
+
${fileContent}Model.watch().on("change", (data) => {
|
27
|
+
const timestamp = new Date();
|
28
|
+
const operationType = data.operationType;
|
29
|
+
|
30
|
+
switch (operationType) {
|
31
|
+
case "insert":
|
32
|
+
// TODO Logic Code...
|
33
|
+
console.log(timestamp, "Document created:", data.fullDocument);
|
34
|
+
break;
|
35
|
+
case "update":
|
36
|
+
// TODO Logic Code...
|
37
|
+
console.log(timestamp, "Document updated:", data.updateDescription);
|
38
|
+
break;
|
39
|
+
case "delete":
|
40
|
+
// TODO Logic Code...
|
41
|
+
console.log(timestamp, "Document deleted:", data.documentKey);
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
console.log(timestamp, "Unknown operation type:", operationType);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
*/
|
48
|
+
|
49
|
+
module.exports = ${fileContent}Model;
|
package/typing.gif
ADDED
Binary file
|
package/README.md
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
# Security holding package
|
2
|
-
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
4
|
-
|
5
|
-
Please refer to www.npmjs.com/advisories?search=nodejs-backpack for more information.
|