Skip to content

Commit

Permalink
fix(identity): šŸ› do not use http module utility functions, but use zeā€¦
Browse files Browse the repository at this point in the history
ā€¦ncode's one (#270)
  • Loading branch information
matteo-cristino authored Feb 2, 2024
1 parent f083d5a commit b611a0f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/identity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Zencode } from "@restroom-mw/zencode";
import { NextFunction, Request, Response } from "express";
import axios from "axios";
import { Action } from "./actions";
import { chunks } from "@restroom-mw/http/src/utils";

export default (req: Request, res: Response, next: NextFunction) => {
const rr = new Restroom(req, res);
Expand All @@ -22,21 +21,21 @@ export default (req: Request, res: Response, next: NextFunction) => {
content = rr.combineDataKeys(data, keys);

if (zencode.match(Action.RESOLVE_DID)) {
for (let [did, urlName, o] of chunks(zencode.paramsOf(Action.RESOLVE_DID), 3)) {
for (let [did, urlName, o] of zencode.chunkedParamsOf(Action.RESOLVE_DID, 3)) {
let check_url : URL;
let url_resolver : URL;
try {
check_url = new URL(content[urlName]);
check_url = new URL(content[urlName as string]);
} catch (err) {
throw new Error("The string " + content[urlName] + " is an invalid URL");
throw new Error("The string " + content[urlName as string] + " is an invalid URL");
}
try{
url_resolver = new URL(check_url.toString() + "/" + content[did]);
url_resolver = new URL(check_url.toString() + "/" + content[did as string]);
} catch(err){
throw new Error("The string " + content[did] + " is an invalid URL");
throw new Error("The string " + content[did as string] + " is an invalid URL");
}
promises.push(axios.get(url_resolver.toString()));
outputs.push(o);
outputs.push(o as string);
}
}
if(promises.length){
Expand Down

0 comments on commit b611a0f

Please sign in to comment.