Skip to content

Commit

Permalink
implement envname as query and dnpname as route
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Nov 27, 2024
1 parent 4cce7ce commit af763e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/dappmanager/src/api/routes/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ interface Params {
* Query env from a package
*/
export const env = wrapHandler<Params>(async (req, res) => {
const { dnpName, envName } = req.params;
const { dnpName } = req.params;
const { envName } = req.query;

if (!dnpName || !envName) {
if (!dnpName) {
res.status(400).send();
return;
}

const compose = new ComposeFileEditor(dnpName, false);

// return all envs if no envName is provided
if (!envName) {
res.json(compose.getUserSettings().environment);
return;
}

if (typeof envName !== "string") {
res.status(400).send("envName must be a string");
return;
}

const environment = compose.getUserSettings().environment;
for (const serviceName in environment) {
if (environment[serviceName][envName]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/startHttpApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function startHttpApi({

// Open endpoints (no auth)
app.get("/global-envs/:name?", routes.globalEnvs);
app.get("/env", routes.env);
app.get("/env/:dnpName", routes.env);
app.get("/public-packages/:containerName?", routes.publicPackagesData);
app.get("/package-manifest/:dnpName", routes.packageManifest);
app.get("/metrics", routes.metrics);
Expand Down

0 comments on commit af763e4

Please sign in to comment.