Merge pull request 'fix(app): an empty mountpoint mounts at the root again (GitHub #31)' (#161) from fix/mountpoint-empty-string into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 19s
CI / build (push) Successful in 28s
CI / runtimes (edge) (push) Successful in 19s
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (deno) (push) Successful in 33s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 19s
CI / build (push) Successful in 28s
CI / runtimes (edge) (push) Successful in 19s
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (deno) (push) Successful in 33s
This commit was merged in pull request #161.
This commit is contained in:
commit
6fc6e9e3c5
3 files changed
+25
-1
No files matched your search
@@ -260,6 +260,12 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A `@Module` without a `mountpoint` names itself at boot** (GitHub #31). The type
|
||||
requires it, but JavaScript or transpile-only code could still omit it, and `createApp` failed
|
||||
with `Cannot read properties of undefined (reading 'replace')` from inside the path helper. It now
|
||||
fails with `<Module> @Module metadata is missing mountpoint`. `mountpoint: ''` still mounts at the
|
||||
root.
|
||||
|
||||
- **`listen()` rejects when the port is taken** (#138). A bind failure such as `EADDRINUSE` or
|
||||
`EACCES` arrives as the server's `error` event, which `listen()` did not handle: the promise
|
||||
never settled, and the error surfaced as an unhandled one. It now rejects with that error. The
|
||||
|
||||
+3
-1
@@ -789,7 +789,9 @@ function collectModules(modules: Ctor[], viewsCtx: ViewsContext): Registry {
|
||||
for (const mod of modules) {
|
||||
const moduleMeta = getModuleMeta(mod);
|
||||
if (!moduleMeta) throw new Error(`${mod.name} is not a @Module`);
|
||||
if (!moduleMeta.mountpoint) throw new Error(`${mod.name} @Module metadata is missing mountpoint`);
|
||||
// `typeof`, not falsiness: `mountpoint: ''` mounts at the root, as it always has.
|
||||
if (typeof moduleMeta.mountpoint !== 'string')
|
||||
throw new Error(`${mod.name} @Module metadata is missing mountpoint`);
|
||||
const origin = `module:${mod.name}`;
|
||||
collectProviders(moduleMeta.providers ?? [], origin, registry);
|
||||
collectSteps(moduleMeta.steps ?? [], origin, registry);
|
||||
|
||||
@@ -58,6 +58,22 @@ test('runtime module metadata without mountpoint names module and missing field'
|
||||
expect(() => createApp({ modules: [BrokenModule] })).toThrow(/BrokenModule.*mountpoint/);
|
||||
});
|
||||
|
||||
test("an empty mountpoint still mounts at the root, as it did before the missing-mountpoint check", async () => {
|
||||
@Route('/')
|
||||
class RootCtl {
|
||||
@Get('/hi')
|
||||
hi() {
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
|
||||
@Module({ mountpoint: '', controllers: [RootCtl] })
|
||||
class RootModule {}
|
||||
|
||||
const res = await createApp({ modules: [RootModule] }).fetch(new Request('http://x/hi'));
|
||||
expect(res.status).toBe(200);
|
||||
});
|
||||
|
||||
test('ready() is a no-op on a non-mesh app, so one protocol works for both', async () => {
|
||||
// The point: code holding an `App` should not have to know whether it is a mesh app.
|
||||
// `await app.ready(); app.graph()` is uniform — here it changes nothing and boots nothing.
|
||||
|
||||
Reference in new issue
Block a user