Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(identity): 🐛 do not use http module utility functions, but use zencode's one #270

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading