mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-10 03:27:59 +00:00
fix(ingestion): treat server/plugins and server/tasks as Nitro runtime
isNitroServerRuntimeFile only matched server/api, server/routes, and server/middleware. Nitro also auto-imports server/utils into server/plugins and (since Nitro 2.6) server/tasks, so callers there were misrouted to the client composable map. Extend the prefix set (now a named constant) to cover them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T4W25WLfYD1JNy8icxeLPU
This commit is contained in:
parent
7d8743327a
commit
585d497283
2 changed files with 16 additions and 5 deletions
|
|
@ -132,13 +132,22 @@ export function getNuxtAutoImportEntry(
|
|||
return config.clientByLocalName.get(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Directories whose files run in the Nitro server context and so receive
|
||||
* `server/utils` auto-imports without an explicit import: API routes, server
|
||||
* routes, middleware, plugins, and (Nitro 2.6+) tasks.
|
||||
*/
|
||||
const NITRO_RUNTIME_DIR_PREFIXES = [
|
||||
'server/api/',
|
||||
'server/routes/',
|
||||
'server/middleware/',
|
||||
'server/plugins/',
|
||||
'server/tasks/',
|
||||
] as const;
|
||||
|
||||
export function isNitroServerRuntimeFile(filePath: string): boolean {
|
||||
const normalized = filePath.replace(/\\/g, '/');
|
||||
return (
|
||||
normalized.startsWith('server/api/') ||
|
||||
normalized.startsWith('server/routes/') ||
|
||||
normalized.startsWith('server/middleware/')
|
||||
);
|
||||
return NITRO_RUNTIME_DIR_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
||||
}
|
||||
|
||||
// ---- .nuxt/imports.d.ts -----------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -157,6 +157,8 @@ describe('isNitroServerRuntimeFile', () => {
|
|||
expect(isNitroServerRuntimeFile('server/api/users.ts')).toBe(true);
|
||||
expect(isNitroServerRuntimeFile('server/routes/feed.ts')).toBe(true);
|
||||
expect(isNitroServerRuntimeFile('server/middleware/auth.ts')).toBe(true);
|
||||
expect(isNitroServerRuntimeFile('server/plugins/init.ts')).toBe(true);
|
||||
expect(isNitroServerRuntimeFile('server/tasks/cleanup.ts')).toBe(true);
|
||||
expect(isNitroServerRuntimeFile('server/utils/auth.ts')).toBe(false);
|
||||
expect(isNitroServerRuntimeFile('pages/index.ts')).toBe(false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue