Skip to content

Commit

Permalink
Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sarithapillai8 committed Aug 26, 2024
1 parent 4b279e9 commit 4f0c163
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 103 deletions.
108 changes: 99 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cors": "^2.8.5",
"express": "^4.17.1",
"ioredis": "^4.22.0",
"jose": "^5.6.3",
"jsonwebtoken": "^9.0.2",
"mongodb": "^6.8.0",
"morgan": "^1.9.1",
"nano": "^10.1.3",
Expand All @@ -26,6 +26,7 @@
"@types/fs-extra": "^5.1.0",
"@types/ioredis": "^4.22.0",
"@types/jest": "^27.5.1",
"@types/jsonwebtoken": "^9.0.6",
"@types/morgan": "^1.9.2",
"@types/nano": "^7.0.0",
"@types/node": "^13.1.2",
Expand Down
6 changes: 3 additions & 3 deletions src/service/ActivityEventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ActivityEventService.Router.post("/participant/:participant_id/activity_event",
),
})
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -126,8 +126,8 @@ ActivityEventService.Router.get("/participant/:participant_id/activity_event", a
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
// TODO: activity/* and sensor/* entry
// TODO: activity/* and sensor/* entry
14 changes: 7 additions & 7 deletions src/service/ActivityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ActivityService.Router.post("/study/:study_id/activity", authenticateToken, asyn
try {
res.json({ data: await ActivityService.create(req.get("Authorization"), req.params.study_id, req.body) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -129,7 +129,7 @@ ActivityService.Router.put("/activity/:activity_id", authenticateToken, async (r
try {
res.json({ data: await ActivityService.set(req.get("Authorization"), req.params.activity_id, req.body) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -138,7 +138,7 @@ ActivityService.Router.delete("/activity/:activity_id", authenticateToken, async
try {
res.json({ data: await ActivityService.set(req.get("Authorization"), req.params.activity_id, null) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -149,7 +149,7 @@ ActivityService.Router.get("/activity/:activity_id", authenticateToken, async (r
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -167,7 +167,7 @@ ActivityService.Router.get("/participant/:participant_id/activity", authenticate
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -184,7 +184,7 @@ ActivityService.Router.get("/study/:study_id/activity", authenticateToken, async
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
})
12 changes: 6 additions & 6 deletions src/service/ActivitySpecService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ActivitySpecService.Router.post("/activity_spec", authenticateToken, async (req:
try {
res.json({ data: await ActivitySpecService.create(req.get("Authorization"), null, req.body) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -51,7 +51,7 @@ ActivitySpecService.Router.put("/activity_spec/:activity_spec_name", authenticat
try {
res.json({ data: await ActivitySpecService.set(req.get("Authorization"), req.params.activity_spec_name, req.body) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -60,7 +60,7 @@ ActivitySpecService.Router.delete("/activity_spec/:activity_spec_name", authenti
try {
res.json({ data: await ActivitySpecService.set(req.get("Authorization"), req.params.activity_spec_name, null) })
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -71,7 +71,7 @@ ActivitySpecService.Router.get("/activity_spec/:activity_spec_name", authenticat
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
Expand All @@ -82,7 +82,7 @@ ActivitySpecService.Router.get("/activity_spec", authenticateToken, async (req:
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
})
})
8 changes: 4 additions & 4 deletions src/service/CredentialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CredentialService.Router.get(
output = typeof req.query.transform === "string" ? jsonata(req.query.transform).evaluate(output) : output
res.json(output)
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
}
Expand All @@ -76,7 +76,7 @@ CredentialService.Router.post(
),
})
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
}
Expand All @@ -97,7 +97,7 @@ CredentialService.Router.put(
),
})
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
}
Expand All @@ -118,7 +118,7 @@ CredentialService.Router.delete(
),
})
} catch (e:any) {
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Bearer realm="LAMP" charset="UTF-8"`)
if (e.message === "401.missing-credentials") res.set("WWW-Authenticate", `Basic realm="LAMP" charset="UTF-8"`)
res.status(parseInt(e.message.split(".")[0]) || 500).json({ error: e.message })
}
}
Expand Down
Loading

0 comments on commit 4f0c163

Please sign in to comment.