@modular-rest/server 1.10.2 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-rest/server",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "a nodejs module based on KOAJS for developing Rest-APIs in a modular solution.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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.
@@ -1,45 +1,37 @@
1
- const jwt = require('jsonwebtoken');
1
+ const jwt = require("jsonwebtoken");
2
2
 
3
- class JWT
4
- {
5
- setKies(privateKey, publicKey)
6
- {
7
- this.privateKey = privateKey;
8
- this.publicKey = publicKey;
9
- }
3
+ class JWT {
4
+ setKies(privateKey, publicKey) {
5
+ this.privateKey = privateKey;
6
+ this.publicKey = publicKey;
7
+ }
10
8
 
11
- sign(payload)
12
- {
13
- return new Promise((done, reject) =>
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
- verify(token)
28
- {
29
- return new Promise((done, reject) =>
30
- {
31
- let option = { algorithm: 'RS256' };
32
-
33
- try {
34
- let decoded = jwt.verify(token, this.publicKey, option);
35
- done(decoded);
36
- }
37
- catch (error) {
38
- reject(error);
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 = 'jwt';
45
- module.exports.main = new JWT();
36
+ module.exports.name = "jwt";
37
+ module.exports.main = new JWT();