mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-24 20:28:06 +02:00
[pitboss] sweep after phase 14: 2 deferred items resolved
This commit is contained in:
parent
78023ccf38
commit
3d3fdc21b7
1 changed files with 46 additions and 19 deletions
|
|
@ -1364,11 +1364,7 @@ fn emit_fastify(spec: &HarnessSpec) -> String {
|
||||||
let (method, payload_key, body_kind) = resolve_http_payload(&spec.payload_slot);
|
let (method, payload_key, body_kind) = resolve_http_payload(&spec.payload_slot);
|
||||||
format!(
|
format!(
|
||||||
r#"// Shape: Fastify route — boot via app.inject() (light-my-request equivalent).
|
r#"// Shape: Fastify route — boot via app.inject() (light-my-request equivalent).
|
||||||
const _app = _entry.app || _entry.default || _entry;
|
let _app = _entry.app || _entry.default || _entry;
|
||||||
if (!_app || typeof _app.inject !== 'function') {{
|
|
||||||
process.stderr.write('NYX_FASTIFY_APP_NOT_FOUND\n');
|
|
||||||
process.exit(78);
|
|
||||||
}}
|
|
||||||
const _kind = {body_kind:?};
|
const _kind = {body_kind:?};
|
||||||
const _payload_key = {payload_key:?};
|
const _payload_key = {payload_key:?};
|
||||||
const _method = {method:?};
|
const _method = {method:?};
|
||||||
|
|
@ -1389,6 +1385,20 @@ if (_kind === 'query') {{
|
||||||
}}
|
}}
|
||||||
(async () => {{
|
(async () => {{
|
||||||
try {{
|
try {{
|
||||||
|
// Fastify plugin route table: entry exports `async (instance, opts) => ...`
|
||||||
|
// rather than an already-built instance. Wrap the plugin in a fresh
|
||||||
|
// Fastify instance via `.register()` so `.inject()` is available.
|
||||||
|
if (typeof _app === 'function' && typeof _app.inject !== 'function') {{
|
||||||
|
const _fastifyModule = require('fastify');
|
||||||
|
const _fastifyFactory = _fastifyModule.default || _fastifyModule;
|
||||||
|
const _wrapped = _fastifyFactory();
|
||||||
|
await _wrapped.register(_app);
|
||||||
|
_app = _wrapped;
|
||||||
|
}}
|
||||||
|
if (!_app || typeof _app.inject !== 'function') {{
|
||||||
|
process.stderr.write('NYX_FASTIFY_APP_NOT_FOUND\n');
|
||||||
|
process.exit(78);
|
||||||
|
}}
|
||||||
if (typeof _app.ready === 'function') await _app.ready();
|
if (typeof _app.ready === 'function') await _app.ready();
|
||||||
const _injectOpts = {{ method: _method, url: _path, headers: _headers }};
|
const _injectOpts = {{ method: _method, url: _path, headers: _headers }};
|
||||||
if (_query) _injectOpts.query = _query;
|
if (_query) _injectOpts.query = _query;
|
||||||
|
|
@ -1447,21 +1457,38 @@ if (_kind === 'env') {{
|
||||||
try {{
|
try {{
|
||||||
let _app = _entry.app || (_entry.default && _entry.default.app);
|
let _app = _entry.app || (_entry.default && _entry.default.app);
|
||||||
if (!_app) {{
|
if (!_app) {{
|
||||||
// Locate a controller class — first @Controller / class export.
|
// Prefer an exported @Module class — real Nest projects
|
||||||
const _candidate = _entry[_entry_name]
|
// mount controllers via their enclosing module's
|
||||||
|| _entry.default
|
// `imports:[...]`, not by passing the controller class
|
||||||
|| _entry.AppController
|
// directly. Match any export whose name ends in `Module`
|
||||||
|| _entry.Controller
|
// (the canonical Nest convention).
|
||||||
|| Object.values(_entry).find((v) => typeof v === 'function');
|
const _moduleEntry = Object.entries(_entry).find(([k, v]) =>
|
||||||
if (typeof _candidate !== 'function') {{
|
typeof v === 'function' && /Module$/.test(k)
|
||||||
process.stderr.write('NYX_NEST_CONTROLLER_NOT_FOUND\n');
|
);
|
||||||
process.exit(78);
|
if (_moduleEntry) {{
|
||||||
|
const _moduleClass = _moduleEntry[1];
|
||||||
|
const _module = await _NestTesting.Test
|
||||||
|
.createTestingModule({{ imports: [_moduleClass] }})
|
||||||
|
.compile();
|
||||||
|
_app = _module.createNestApplication();
|
||||||
|
await _app.init();
|
||||||
|
}} else {{
|
||||||
|
// Locate a controller class — first @Controller / class export.
|
||||||
|
const _candidate = _entry[_entry_name]
|
||||||
|
|| _entry.default
|
||||||
|
|| _entry.AppController
|
||||||
|
|| _entry.Controller
|
||||||
|
|| Object.values(_entry).find((v) => typeof v === 'function');
|
||||||
|
if (typeof _candidate !== 'function') {{
|
||||||
|
process.stderr.write('NYX_NEST_CONTROLLER_NOT_FOUND\n');
|
||||||
|
process.exit(78);
|
||||||
|
}}
|
||||||
|
const _module = await _NestTesting.Test
|
||||||
|
.createTestingModule({{ controllers: [_candidate] }})
|
||||||
|
.compile();
|
||||||
|
_app = _module.createNestApplication();
|
||||||
|
await _app.init();
|
||||||
}}
|
}}
|
||||||
const _module = await _NestTesting.Test
|
|
||||||
.createTestingModule({{ controllers: [_candidate] }})
|
|
||||||
.compile();
|
|
||||||
_app = _module.createNestApplication();
|
|
||||||
await _app.init();
|
|
||||||
}}
|
}}
|
||||||
const _server = (typeof _app.getHttpServer === 'function')
|
const _server = (typeof _app.getHttpServer === 'function')
|
||||||
? _app.getHttpServer()
|
? _app.getHttpServer()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue