mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-14 00:40:30 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -12,21 +12,25 @@ const logger = createLogger(proxyName);
|
|||
|
||||
async function login(widget, service) {
|
||||
const endpoint = "accounts/ClientLogin";
|
||||
const api = widgets?.[widget.type]?.api
|
||||
const api = widgets?.[widget.type]?.api;
|
||||
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
||||
|
||||
const [, , data,] = await httpProxy(loginUrl, {
|
||||
const [, , data] = await httpProxy(loginUrl, {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({
|
||||
Email: widget.username,
|
||||
Passwd: widget.password
|
||||
Passwd: widget.password,
|
||||
}).toString(),
|
||||
headers,
|
||||
});
|
||||
|
||||
try {
|
||||
const [, token] = data.toString().split("\n").find(line => line.startsWith("Auth=")).split("=")
|
||||
const [, token] = data
|
||||
.toString()
|
||||
.split("\n")
|
||||
.find((line) => line.startsWith("Auth="))
|
||||
.split("=");
|
||||
cache.put(`${sessionTokenCacheKey}.${service}`, token);
|
||||
return { token };
|
||||
} catch (e) {
|
||||
|
@ -39,8 +43,8 @@ async function login(widget, service) {
|
|||
async function apiCall(widget, endpoint, service) {
|
||||
const key = `${sessionTokenCacheKey}.${service}`;
|
||||
const headers = {
|
||||
"Authorization": `GoogleLogin auth=${cache.get(key)}`,
|
||||
}
|
||||
Authorization: `GoogleLogin auth=${cache.get(key)}`,
|
||||
};
|
||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||
const method = "GET";
|
||||
|
||||
|
@ -92,6 +96,6 @@ export default async function freshrssProxyHandler(req, res) {
|
|||
|
||||
return res.status(200).send({
|
||||
subscriptions: subscriptionData?.subscriptions.length,
|
||||
unread: unreadCountData?.max
|
||||
unread: unreadCountData?.max,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ const widget = {
|
|||
proxyHandler: freshrssProxyHandler,
|
||||
mappings: {
|
||||
info: {
|
||||
endpoint: "/"
|
||||
}
|
||||
}
|
||||
endpoint: "/",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue