@ixon-cdk/core 1.24.0 → 1.25.0-next.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/api/base.service.js +10 -3
- package/package.json +1 -1
- package/server/index.js +4 -0
package/api/base.service.js
CHANGED
|
@@ -11,13 +11,20 @@ export class ApiBaseService {
|
|
|
11
11
|
* to now, or `-1` when the file doesn't exist.
|
|
12
12
|
* */
|
|
13
13
|
_getAccessTokenFileModifiedRelativeToNow() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return Math.floor((new Date().getTime() -
|
|
14
|
+
const lastModified = this._getAccessTokenFileLastModified();
|
|
15
|
+
if (lastModified) {
|
|
16
|
+
return Math.floor((new Date().getTime() - lastModified.getTime()) / 1000);
|
|
17
17
|
}
|
|
18
18
|
return -1;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
_getAccessTokenFileLastModified() {
|
|
22
|
+
if (fs.existsSync(this._getAccessTokenFilePath())) {
|
|
23
|
+
return new Date(fs.statSync(this._getAccessTokenFilePath()).mtimeMs);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
/** Returns an absolute path to the `.accesstoken` file. */
|
|
22
29
|
_getAccessTokenFilePath() {
|
|
23
30
|
return path.join(getRootDir(), '.accesstoken');
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -96,6 +96,10 @@ export class Server {
|
|
|
96
96
|
cors({ origin: `http://localhost:${this._opts.port}` }),
|
|
97
97
|
(req, res) => {
|
|
98
98
|
res.type('text/plain');
|
|
99
|
+
const lastModified = this._apiSrv._getAccessTokenFileLastModified();
|
|
100
|
+
if (lastModified) {
|
|
101
|
+
res.append('Last-Modified', lastModified);
|
|
102
|
+
}
|
|
99
103
|
res.send(this._apiSrv._getSecretId() || '');
|
|
100
104
|
},
|
|
101
105
|
);
|