Skip to content

Commit 89264d6

Browse files
authored
Merge pull request #1134 from goldants/private-npm-repositories
fix parsePackageInfoPath, api payload format
2 parents 45064cf + 7d37020 commit 89264d6

File tree

1 file changed

+5
-5
lines changed
  • server/node-service/src/controllers

1 file changed

+5
-5
lines changed

server/node-service/src/controllers/npm.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NpmRegistryService, NpmRegistryConfigEntry, NpmRegistryConfig } from ".
77

88
type RequestConfig = {
99
workspaceId: string;
10-
npmRegistryConfig: NpmRegistryConfig;
10+
npmRegistries: NpmRegistryConfig;
1111
}
1212

1313
type InnerRequestConfig = {
@@ -92,15 +92,15 @@ export async function fetchRegistryWithConfig(request: ServerRequest, response:
9292
return response.status(400).send("Missing workspaceId and/or npmRegistryConfig");
9393
}
9494

95-
const {npmRegistryConfig}: RequestConfig = request.body;
95+
const {npmRegistries: npmRegistryConfig}: RequestConfig = request.body;
9696

9797
const registry = NpmRegistryService.getRegistryEntryForPackageWithConfig(pathPackageInfo.packageId, npmRegistryConfig);
9898

9999
const registryResponse = await fetchFromRegistry(path, registry);
100100
if (!registryResponse.ok) {
101101
return response.status(registryResponse.status).send(await registryResponse.text());
102102
}
103-
response.json(await registryResponse.json());
103+
response.send(await registryResponse.text());
104104
} catch (error) {
105105
logger.error("Error fetching registry", error);
106106
response.status(500).send("Internal server error");
@@ -149,7 +149,7 @@ export async function fetchPackageFileWithConfig(request: ServerRequest, respons
149149
return response.status(400).send("Missing workspaceId and/or npmRegistryConfig");
150150
}
151151

152-
const {workspaceId, npmRegistryConfig}: RequestConfig = request.body;
152+
const {workspaceId, npmRegistries: npmRegistryConfig}: RequestConfig = request.body;
153153
const registryConfig: NpmRegistryConfig = npmRegistryConfig;
154154
const registry = NpmRegistryService.getRegistryEntryForPackageWithConfig(pathPackageInfo.packageId, registryConfig);
155155

@@ -246,7 +246,7 @@ async function fetchPackageFileInner(request: ServerRequest, response: ServerRes
246246

247247
function parsePackageInfoFromPath(path: string): {packageId: string, organization: string, name: string, version: string, file: string} | undefined {
248248
//@ts-ignore - regex groups
249-
const packageInfoRegex = /^\/?(?<packageId>(?:@(?<organization>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<name>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<version>[-a-z0-9><=_.^~]+))?\/(?<file>[^\r\n]*)?$/;
249+
const packageInfoRegex = /^\/?(?<packageId>(?:@(?<organization>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<name>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<version>[-a-z0-9><=_.^~]+))?(\/(?<file>[^\r\n]*))?$/;
250250
const matches = path.match(packageInfoRegex);
251251
if (!matches?.groups) {
252252
return;

0 commit comments

Comments
 (0)