@fastly/expressly 1.0.0-alpha.1 → 1.0.0-alpha.2
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/README.md
CHANGED
|
@@ -17,11 +17,11 @@ First, head over to [developer.fastly.com](https://developer.fastly.com) to get
|
|
|
17
17
|
Install expressly from the [npm registry](https://www.npmjs.com/package/@fastly/expressly):
|
|
18
18
|
|
|
19
19
|
```shell
|
|
20
|
-
npm i @fastly/expressly
|
|
20
|
+
npm i @fastly/expressly@1.0.0-alpha.2
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
|
-
yarn add @fastly/expressly
|
|
24
|
+
yarn add @fastly/expressly@1.0.0-alpha.2
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### Your first expressly app
|
|
@@ -8,13 +8,14 @@ export declare class ERequest extends ECommonObject {
|
|
|
8
8
|
readonly clientInfo: ClientInfo;
|
|
9
9
|
readonly method: string;
|
|
10
10
|
headers: Headers;
|
|
11
|
-
|
|
11
|
+
urlObj: URL;
|
|
12
12
|
query: URLSearchParams;
|
|
13
13
|
params: {
|
|
14
14
|
[key: string]: string;
|
|
15
15
|
};
|
|
16
16
|
cookies: CookieMap;
|
|
17
17
|
constructor(config: EConfig, event: FetchEvent);
|
|
18
|
+
get url(): string;
|
|
18
19
|
get path(): string;
|
|
19
20
|
get ip(): string;
|
|
20
21
|
get protocol(): string;
|
|
@@ -8,8 +8,8 @@ export class ERequest extends ECommonObject {
|
|
|
8
8
|
this.params = {};
|
|
9
9
|
this.clientInfo = event.client;
|
|
10
10
|
this.method = event.request.method;
|
|
11
|
-
this.
|
|
12
|
-
this.query = this.
|
|
11
|
+
this.urlObj = new URL(event.request.url);
|
|
12
|
+
this.query = this.urlObj.searchParams;
|
|
13
13
|
this.headers = event.request.headers;
|
|
14
14
|
// Parse cookies.
|
|
15
15
|
if (this.config.parseCookie) {
|
|
@@ -17,23 +17,26 @@ export class ERequest extends ECommonObject {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
// Express-like URL helpers.
|
|
20
|
+
get url() {
|
|
21
|
+
return this.urlObj.toString();
|
|
22
|
+
}
|
|
20
23
|
get path() {
|
|
21
|
-
return this.
|
|
24
|
+
return this.urlObj.pathname;
|
|
22
25
|
}
|
|
23
26
|
get ip() {
|
|
24
27
|
return this.clientInfo.address;
|
|
25
28
|
}
|
|
26
29
|
get protocol() {
|
|
27
|
-
return this.
|
|
30
|
+
return this.urlObj.protocol;
|
|
28
31
|
}
|
|
29
32
|
get secure() {
|
|
30
|
-
return this.
|
|
33
|
+
return this.urlObj.protocol === "https";
|
|
31
34
|
}
|
|
32
35
|
get subdomains() {
|
|
33
|
-
return this.
|
|
36
|
+
return this.urlObj.hostname.split(".").slice(0, -2);
|
|
34
37
|
}
|
|
35
38
|
get hostname() {
|
|
36
|
-
return this.
|
|
39
|
+
return this.urlObj.hostname;
|
|
37
40
|
}
|
|
38
41
|
async json() {
|
|
39
42
|
return await this.event.request.json();
|
|
@@ -140,7 +140,7 @@ export class Router {
|
|
|
140
140
|
pathMatcherCache.set(pattern, match(pattern, { decode: decodeURIComponent }));
|
|
141
141
|
}
|
|
142
142
|
// Match on pathname.
|
|
143
|
-
let { path, params } = pathMatcherCache.get(pattern)(req.
|
|
143
|
+
let { path, params } = pathMatcherCache.get(pattern)(req.urlObj.pathname) || {};
|
|
144
144
|
if (path) {
|
|
145
145
|
if (this.config.extractRequestParameters) {
|
|
146
146
|
req.params = params;
|