Skip to content

Commit

Permalink
dev domain redir
Browse files Browse the repository at this point in the history
  • Loading branch information
hubsmoke committed Mar 19, 2024
1 parent ca8cb79 commit 760e9d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/dpid-reader/DpidReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface DpidRequest {
prefix: string;
raw?: boolean;
jsonld?: boolean;
domain?: string;
}

// export const encodeBase64UrlSafe = (bytes: Buffer) => {
Expand Down Expand Up @@ -137,7 +138,7 @@ export class DpidReader {
};

private static transformWeb = async (result: DpidResult, request: DpidRequest) => {
const { prefix, suffix, version } = request;
const { prefix, suffix, version, domain } = request;
const uuid = result.id64;
const output = { msg: `beta.dpid.org resolver`, params: request, uuid };

Expand All @@ -147,13 +148,9 @@ export class DpidReader {
: version?.substring(0, 1) == "v"
? version
: `v${parseInt(version || "0") + 1}`;
const redir = `https://nodes${prefix === "beta-dev" ? "-dev" : ""}.desci.com/dpid/${[
request.dpid,
cleanVersion,
suffix,
]
.filter(Boolean)
.join("/")}`;
const redir = `https://nodes${
prefix === "beta-dev" || domain === "dev-beta.dpid.org" ? "-dev" : ""
}.desci.com/dpid/${[request.dpid, cleanVersion, suffix].filter(Boolean).join("/")}`;
logger.info({ output }, "[dpid:resolve]");
return redir;
};
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ app.get("/*", async (req: Request, res: Response) => {
prefix,
raw: isRaw,
jsonld: isJsonld,
domain: hostname,
};

analytics.log({
Expand Down

0 comments on commit 760e9d8

Please sign in to comment.