fix(app): an empty mountpoint mounts at the root again (GitHub #31)
GitHub #32 (merged from contrib) made `createApp` fail with a message naming the module when its `@Module` metadata has no `mountpoint`, instead of a TypeError from `joinPath`. The check tested falsiness, so it also refused `mountpoint: ''`, which the type allows and which has always mounted at the root (`joinPath('', '/hi')` is `/hi`). Test for `typeof … !== 'string'` instead: a missing or non-string mountpoint still fails with the new message, and `''` boots as before. The CHANGELOG entry for #31 that #32 did not add is included. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
3 files changed
+25
-1
No files matched your search
@@ -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