@stacksjs/types 0.75.98 → 0.75.100
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/server.d.ts +57 -0
- package/package.json +4 -4
package/dist/server.d.ts
CHANGED
|
@@ -15,10 +15,32 @@ export declare interface ApiProxyOptions {
|
|
|
15
15
|
paths?: string[]
|
|
16
16
|
methods?: string[]
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A domain route that also says where the rest of the site lives.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* domains: {
|
|
23
|
+
* '{username}.example.com': { to: '/{username}', elsewhere: 'https://example.com' },
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The host's root is still the page. Any other page on it redirects to
|
|
28
|
+
* `elsewhere` (`chris.example.com/pricing` → `example.com/pricing`), while
|
|
29
|
+
* its assets, `/api` and `public/` files are answered in place for the page
|
|
30
|
+
* at the root. A browser keeps a session per origin, so without this a
|
|
31
|
+
* visitor who signs in from a profile's own domain is signed in to that
|
|
32
|
+
* domain alone, and goes on using the app under someone else's name.
|
|
33
|
+
* stx >= 0.2.411.
|
|
34
|
+
*/
|
|
35
|
+
export declare interface DomainRouteTarget {
|
|
36
|
+
to: string
|
|
37
|
+
elsewhere?: string
|
|
38
|
+
}
|
|
18
39
|
export declare interface ServerConfig {
|
|
19
40
|
proxy?: ApiProxyOptions
|
|
20
41
|
redirects?: RedirectsOptions
|
|
21
42
|
rewrites?: RewritesOptions
|
|
43
|
+
domains?: DomainRoutes
|
|
22
44
|
cache?: ServerCacheOptions
|
|
23
45
|
security?: ServerSecurityOptions
|
|
24
46
|
}
|
|
@@ -107,3 +129,38 @@ export type RedirectsOptions = Record<string, string | {
|
|
|
107
129
|
* A rewrite whose source is already under `/api/` is ignored.
|
|
108
130
|
*/
|
|
109
131
|
export type RewritesOptions = Record<string, string>;
|
|
132
|
+
/**
|
|
133
|
+
* Hosts whose home page is a page of the site.
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* domains: {
|
|
137
|
+
* '{username}.example.com': '/{username}',
|
|
138
|
+
* 'shop.example.com': '/store',
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* `chris.example.com` then renders exactly what `example.com/chris` renders —
|
|
143
|
+
* the same view, `resources/views/[username].stx`, with the same
|
|
144
|
+
* `route.params.username` — while the address bar keeps the host. It is how a
|
|
145
|
+
* profile, a team or a shop gets a domain of its own on a site that is
|
|
146
|
+
* otherwise one app, the way GitHub Pages or a Substack subdomain does.
|
|
147
|
+
*
|
|
148
|
+
* Only the host's root is routed. Every other path on that host (assets,
|
|
149
|
+
* `/api`, the other pages a navigation bar links to) is the site's own,
|
|
150
|
+
* answered as on the main domain, so one page can be given a domain without
|
|
151
|
+
* the rest of the site breaking under it.
|
|
152
|
+
*
|
|
153
|
+
* A label written `{name}` matches exactly one DNS label, so the pattern
|
|
154
|
+
* above matches `chris.example.com` but neither the bare apex nor
|
|
155
|
+
* `a.b.example.com`. Literal hosts win over parameterised ones. The host is
|
|
156
|
+
* read from `X-Forwarded-Host` first, as a gateway in front sends it.
|
|
157
|
+
*
|
|
158
|
+
* Routing the requests here is half of it: the hostnames must also reach the
|
|
159
|
+
* server. With ts-cloud, list `*.example.com` in the site's `aliases` (see
|
|
160
|
+
* `config/cloud.ts`) and the deploy adds the wildcard DNS record, the gateway
|
|
161
|
+
* route and a wildcard certificate.
|
|
162
|
+
*
|
|
163
|
+
* Answered by stx's own router (`serve({ domains })`, stx >= 0.2.410) under
|
|
164
|
+
* both `buddy dev` and `buddy serve`; `buddy dev` prints the routes at boot.
|
|
165
|
+
*/
|
|
166
|
+
export type DomainRoutes = Record<string, string | DomainRouteTarget>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.75.
|
|
4
|
+
"version": "0.75.100",
|
|
5
5
|
"description": "The Stacks framework types.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@stacksjs/bunpress": "^0.2.15",
|
|
60
60
|
"@stacksjs/clapp": "^0.2.12",
|
|
61
|
-
"@stacksjs/events": "0.75.
|
|
62
|
-
"@stacksjs/strings": "0.75.
|
|
61
|
+
"@stacksjs/events": "0.75.100",
|
|
62
|
+
"@stacksjs/strings": "0.75.100",
|
|
63
63
|
"@stacksjs/stx": "^0.2.408",
|
|
64
64
|
"@stacksjs/ts-validation": "^0.5.6",
|
|
65
65
|
"bun-query-builder": "^0.3.5"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@stacksjs/validation": "0.75.
|
|
76
|
+
"@stacksjs/validation": "0.75.100",
|
|
77
77
|
"better-dx": "^0.2.24",
|
|
78
78
|
"meilisearch": "^0.62.0"
|
|
79
79
|
},
|