@enonic/nextjs-adapter 1.0.0 → 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/package.json +1 -1
- package/server/index.js +10 -4
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -78,8 +78,14 @@ exports.default = (function (next) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
78
78
|
return [4 /*yield*/, nextHandler(req, res)];
|
|
79
79
|
case 1:
|
|
80
80
|
_a.sent();
|
|
81
|
-
return [3 /*break*/,
|
|
81
|
+
return [3 /*break*/, 5];
|
|
82
82
|
case 2:
|
|
83
|
+
if (!dev) return [3 /*break*/, 3];
|
|
84
|
+
console.warn('\nCache clearing is not available in DEV mode.\n');
|
|
85
|
+
res.setHeader('Content-Type', 'application/json');
|
|
86
|
+
res.end(JSON.stringify({ purged: false }));
|
|
87
|
+
return [3 /*break*/, 5];
|
|
88
|
+
case 3:
|
|
83
89
|
tokenParam = parsedUrl.searchParams.get('token');
|
|
84
90
|
if (tokenParam !== process.env.API_TOKEN) {
|
|
85
91
|
// XP hijacks 401 to show login page, so send 407 instead
|
|
@@ -92,12 +98,12 @@ exports.default = (function (next) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
92
98
|
});
|
|
93
99
|
pathParam = parsedUrl.searchParams.get('path') || undefined;
|
|
94
100
|
return [4 /*yield*/, (0, cache_1.purgeCache)(cache, pathParam)];
|
|
95
|
-
case
|
|
101
|
+
case 4:
|
|
96
102
|
_a.sent();
|
|
97
103
|
res.setHeader('Content-Type', 'application/json');
|
|
98
104
|
res.end(JSON.stringify({ purged: true }));
|
|
99
|
-
_a.label =
|
|
100
|
-
case
|
|
105
|
+
_a.label = 5;
|
|
106
|
+
case 5: return [2 /*return*/];
|
|
101
107
|
}
|
|
102
108
|
});
|
|
103
109
|
}); }).listen(port, host, function () {
|