@fastly/expressly 1.0.0-alpha.5 → 1.0.0-alpha.8
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/dist/lib/routing/response/index.js +4 -2
- package/dist/lib/routing/router.js +1 -1
- package/package.json +8 -8
- package/dist/lib/routing/mixin.d.ts +0 -1
- package/dist/lib/routing/mixin.js +0 -9
- package/dist/lib/routing/request/request-url.d.ts +0 -9
- package/dist/lib/routing/request/request-url.js +0 -37
|
@@ -35,8 +35,10 @@ class EResponseBase {
|
|
|
35
35
|
return;
|
|
36
36
|
if (response instanceof Response) {
|
|
37
37
|
this.body = response.body;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// Append, rather than overwrite headers.
|
|
39
|
+
response.headers.forEach((value, key) => this.headers.append(key, value));
|
|
40
|
+
// Do not overwrite user-defined status.
|
|
41
|
+
this.status = this.status || response.status;
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
this.body = response;
|
|
@@ -14,7 +14,7 @@ const defaultErrorHandler = (auto405) => async (err, req, res) => {
|
|
|
14
14
|
return res.sendStatus(405);
|
|
15
15
|
}
|
|
16
16
|
console.error(err);
|
|
17
|
-
res.withStatus(500).json({ error: err });
|
|
17
|
+
res.withStatus(500).json({ error: err.message });
|
|
18
18
|
};
|
|
19
19
|
export class Router {
|
|
20
20
|
constructor(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/expressly",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"description": "Express-style router for Fastly's Compute@Edge.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"@types/node": "^17.0.40",
|
|
33
33
|
"auto": "^10.37.1",
|
|
34
34
|
"husky": "^8.0.1",
|
|
35
|
-
"nodemon": "^2.0.
|
|
36
|
-
"prettier": "^2.
|
|
35
|
+
"nodemon": "^2.0.18",
|
|
36
|
+
"prettier": "^2.7.1",
|
|
37
37
|
"pretty-quick": "^3.1.3",
|
|
38
|
-
"ts-loader": "^9.3.
|
|
39
|
-
"typescript": "^4.7.
|
|
38
|
+
"ts-loader": "^9.3.1",
|
|
39
|
+
"typescript": "^4.7.4",
|
|
40
40
|
"webpack": "^5.73.0",
|
|
41
|
-
"webpack-cli": "^4.
|
|
41
|
+
"webpack-cli": "^4.10.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@fastly/js-compute": "^0.
|
|
44
|
+
"@fastly/js-compute": "^0.3.0",
|
|
45
45
|
"cookie": "^0.5.0",
|
|
46
|
-
"core-js": "^3.
|
|
46
|
+
"core-js": "^3.23.3",
|
|
47
47
|
"path-to-regexp": "^6.2.1"
|
|
48
48
|
},
|
|
49
49
|
"auto": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function applyMixins(derivedConstructor: any, baseConstructors: any[]): void;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function applyMixins(derivedConstructor, baseConstructors) {
|
|
2
|
-
baseConstructors.forEach(baseConstructor => {
|
|
3
|
-
Object.getOwnPropertyNames(baseConstructor.prototype).forEach(name => {
|
|
4
|
-
if (name !== 'constructor') {
|
|
5
|
-
derivedConstructor.prototype[name] = baseConstructor.prototype[name];
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import cookie from "cookie";
|
|
2
|
-
export class CookieMap extends Map {
|
|
3
|
-
constructor(headers) {
|
|
4
|
-
super();
|
|
5
|
-
this.headers = headers;
|
|
6
|
-
if (Boolean(this.headers.get("Cookie"))) {
|
|
7
|
-
for (const [key, value] of Object.entries(cookie.parse(this.headers.get("Cookie")))) {
|
|
8
|
-
if (typeof value === "string") {
|
|
9
|
-
super.set(key, value);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
clear() {
|
|
15
|
-
this.headers.delete("Cookie");
|
|
16
|
-
super.clear();
|
|
17
|
-
}
|
|
18
|
-
set(key, value) {
|
|
19
|
-
super.set(key, value);
|
|
20
|
-
this.serialize();
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
delete(key) {
|
|
24
|
-
const deleteResult = super.delete(key);
|
|
25
|
-
this.serialize();
|
|
26
|
-
return deleteResult;
|
|
27
|
-
}
|
|
28
|
-
serialize() {
|
|
29
|
-
if (this.size) {
|
|
30
|
-
const cookies = [];
|
|
31
|
-
for (const [key, value] of this.entries()) {
|
|
32
|
-
cookies.push(cookie.serialize(key, value));
|
|
33
|
-
}
|
|
34
|
-
this.headers.set("Cookie", cookies.join("; "));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|