feat(core,storage,oci,registry-config): add streaming response support and configurable registry URLs across protocols
This commit is contained in:
@@ -79,16 +79,10 @@ async function createHttpServer(
|
||||
res.setHeader(key, value);
|
||||
}
|
||||
|
||||
// Send body
|
||||
// Send body (response.body is always ReadableStream<Uint8Array> or undefined)
|
||||
if (response.body) {
|
||||
if (Buffer.isBuffer(response.body)) {
|
||||
res.end(response.body);
|
||||
} else if (typeof response.body === 'string') {
|
||||
res.end(response.body);
|
||||
} else {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(response.body));
|
||||
}
|
||||
const { Readable } = await import('stream');
|
||||
Readable.fromWeb(response.body).pipe(res);
|
||||
} else {
|
||||
res.end();
|
||||
}
|
||||
@@ -224,16 +218,16 @@ function cleanupTestDir(dir: string): void {
|
||||
// ========================================================================
|
||||
|
||||
tap.test('NPM CLI: should setup registry and HTTP server', async () => {
|
||||
// Create registry
|
||||
registry = await createTestRegistry();
|
||||
// Find available port
|
||||
registryPort = 35000;
|
||||
|
||||
// Create registry with correct registryUrl for CLI tests
|
||||
registry = await createTestRegistry({ registryUrl: `http://localhost:${registryPort}` });
|
||||
const tokens = await createTestTokens(registry);
|
||||
npmToken = tokens.npmToken;
|
||||
|
||||
expect(registry).toBeInstanceOf(SmartRegistry);
|
||||
expect(npmToken).toBeTypeOf('string');
|
||||
|
||||
// Find available port
|
||||
registryPort = 35000;
|
||||
const serverSetup = await createHttpServer(registry, registryPort);
|
||||
server = serverSetup.server;
|
||||
registryUrl = serverSetup.url;
|
||||
|
||||
Reference in New Issue
Block a user