Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aef9640b50 | ||
|
|
1dfebaa07a |
No files matched your search
@@ -260,12 +260,6 @@ 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.
|
||||
|
||||
- **The body parser is chosen by the media type** (GitHub #36). It was chosen by a substring of
|
||||
the raw `Content-Type` header, case-sensitively, so `Content-Type: Application/JSON` reached the
|
||||
handler as a string while `text/plain; x=application/json` was parsed as JSON. The same applied
|
||||
|
||||
@@ -789,9 +789,6 @@ 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`);
|
||||
// `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);
|
||||
|
||||
+1
-35
@@ -1,6 +1,6 @@
|
||||
import 'reflect-metadata';
|
||||
import { describe, expect, it, test, vi } from 'vitest';
|
||||
import { Provider, Step, Route, Get, Post, Module, Transformer, getModuleMeta } from '../src/metadata';
|
||||
import { Provider, Step, Route, Get, Post, Module, Transformer } from '../src/metadata';
|
||||
import { JsonTransformer } from '../src/transformers';
|
||||
import { Unauthorized } from '../src/signals';
|
||||
import { createApp } from '../src/app';
|
||||
@@ -40,40 +40,6 @@ test('inspect lists the ordered chain with origins', () => {
|
||||
expect(lines.map((l) => `${l.kind}:${l.name}`)).toEqual(['provider:db', 'step:user', 'handler:getUser']);
|
||||
});
|
||||
|
||||
test('runtime module metadata without mountpoint names module and missing field', () => {
|
||||
@Route('/broken')
|
||||
class BrokenCtl {
|
||||
@Get('/')
|
||||
get() {
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
|
||||
@Module({ mountpoint: '/broken', controllers: [BrokenCtl] })
|
||||
class BrokenModule {}
|
||||
const metadata = getModuleMeta(BrokenModule);
|
||||
if (!metadata) throw new Error('test setup failed');
|
||||
Object.defineProperty(metadata, 'mountpoint', { value: undefined });
|
||||
|
||||
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