@dunx/create-app 2.0.1 → 2.1.0
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
|
@@ -6,7 +6,7 @@ Scaffolds a new [dunx](https://github.com/petarzarkov/dunx) application.
|
|
|
6
6
|
bunx @dunx/create-app my-api
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
> `bun create dunx-app` does **not** work
|
|
9
|
+
> `bun create dunx-app` does **not** work and is not advertised:
|
|
10
10
|
> `bun create <template>` resolves the unscoped npm package
|
|
11
11
|
> `create-<template>`, which this package - being scoped - is not.
|
|
12
12
|
|
|
@@ -44,7 +44,7 @@ and overwriting your copy of either is what `--force` is there to ask about.
|
|
|
44
44
|
|
|
45
45
|
## What it generates
|
|
46
46
|
|
|
47
|
-
The `minimal` template,
|
|
47
|
+
The `minimal` template, the same app as
|
|
48
48
|
[`examples/minimal`](https://github.com/petarzarkov/dunx/tree/main/examples/minimal) a service, a controller, a module, `HttpFactory.create`, one test against a real
|
|
49
49
|
server, and the `bunfig.toml` preload line that makes constructor injection work.
|
|
50
50
|
|
|
@@ -52,14 +52,15 @@ Its `src/` is a **byte-for-byte copy** of that example, and a test in this packa
|
|
|
52
52
|
fails if the two ever drift. The example is the one CI boots, so keeping them
|
|
53
53
|
identical is what makes the template trustworthy rather than merely plausible.
|
|
54
54
|
|
|
55
|
-
## Two details
|
|
55
|
+
## Two details
|
|
56
56
|
|
|
57
|
-
**Versions are resolved at run time
|
|
57
|
+
**Versions are resolved at run time rather than written into the template.** Every
|
|
58
58
|
`@dunx/*` range in the template manifest is `__DUNX_VERSION__`, replaced with a
|
|
59
59
|
caret range on this package's own version. dunx versions in lockstep - every
|
|
60
60
|
package shares one number and ships together - so the version doing the
|
|
61
|
-
scaffolding is by definition a set that works together.
|
|
62
|
-
|
|
61
|
+
scaffolding is by definition a set that works together.
|
|
62
|
+
|
|
63
|
+
Writing versions into the template would go stale on the next release.
|
|
63
64
|
|
|
64
65
|
Keep it that way when you add a package later. The packages peer-depend on each
|
|
65
66
|
other by caret range, so mixing minors warns on install - and can leave two copies
|
package/package.json
CHANGED
|
@@ -34,6 +34,11 @@ const postNote = (url: string, text: unknown): Promise<Response> =>
|
|
|
34
34
|
body: JSON.stringify({ text }),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* `203.0.113.7` stands in for whatever the caller put in the header itself, and
|
|
39
|
+
* `10.0.0.1` for the entry the one proxy in front of this app appended. With
|
|
40
|
+
* `trust proxy` set to one hop, only the second is worth anything.
|
|
41
|
+
*/
|
|
37
42
|
const whoami = async (url: string, forwarded: boolean): Promise<string> => {
|
|
38
43
|
const response = await fetch(new URL('api/notes/whoami', url), {
|
|
39
44
|
headers: forwarded ? { 'x-forwarded-for': '203.0.113.7, 10.0.0.1' } : {},
|
|
@@ -89,6 +94,8 @@ export class HttpDemo {
|
|
|
89
94
|
`OPTIONS from https://evil.test -> ${denied.status} ${describeCors(denied)}`,
|
|
90
95
|
);
|
|
91
96
|
|
|
97
|
+
// One trusted hop, so the last entry wins and the caller's own leftmost
|
|
98
|
+
// entry is ignored. Reaching past the proxy takes set('trust proxy', 2).
|
|
92
99
|
logger.info(
|
|
93
100
|
`set("trust proxy", true): X-Forwarded-For sent -> ${await whoami(url, true)}`,
|
|
94
101
|
);
|