@modular-rest/server 1.10.1 → 1.10.3
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/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -24,6 +24,7 @@ const { config, setConfig } = require("./config");
|
|
|
24
24
|
* @param {{
|
|
25
25
|
* cors?: Cors; // CORS options.
|
|
26
26
|
* modulesPath?: string; // Root directory of your router.js/db.js files.
|
|
27
|
+
* uploadDirectory?: string; // Root directory of your uploaded files.
|
|
27
28
|
* staticPath?: {
|
|
28
29
|
* rootDir?: string; // Root directory of your static files.
|
|
29
30
|
* rootPath?: string; // Root path of your static files.
|
|
@@ -35,7 +35,6 @@ function connectToDatabaseByCollectionDefinitionList(
|
|
|
35
35
|
colog.info(`- Connecting to database ${connectionString}`);
|
|
36
36
|
|
|
37
37
|
let connection = Mongoose.createConnection(connectionString, {
|
|
38
|
-
...mongoOption,
|
|
39
38
|
useUnifiedTopology: true,
|
|
40
39
|
useNewUrlParser: true,
|
|
41
40
|
});
|
|
@@ -1,45 +1,37 @@
|
|
|
1
|
-
const jwt = require(
|
|
1
|
+
const jwt = require("jsonwebtoken");
|
|
2
2
|
|
|
3
|
-
class JWT
|
|
4
|
-
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.publicKey = publicKey;
|
|
9
|
-
}
|
|
3
|
+
class JWT {
|
|
4
|
+
setKies(privateKey, publicKey) {
|
|
5
|
+
this.privateKey = privateKey;
|
|
6
|
+
this.publicKey = publicKey;
|
|
7
|
+
}
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
let option = { algorithm: 'RS256'};
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
let token = jwt.sign(payload, this.privateKey, option);
|
|
19
|
-
done(token);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
reject(error.message);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
9
|
+
sign(payload) {
|
|
10
|
+
return new Promise((done, reject) => {
|
|
11
|
+
let option = { algorithm: "RS256" };
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
try {
|
|
14
|
+
let token = jwt.sign(payload, this.privateKey, option);
|
|
15
|
+
done(token);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error.message);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
verify(token) {
|
|
23
|
+
return new Promise((done, reject) => {
|
|
24
|
+
let option = { algorithm: "RS256" };
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
let decoded = jwt.verify(token, this.publicKey, option);
|
|
28
|
+
done(decoded);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
reject(error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
module.exports.name =
|
|
45
|
-
module.exports.main = new JWT();
|
|
36
|
+
module.exports.name = "jwt";
|
|
37
|
+
module.exports.main = new JWT();
|