mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
refactor(api): log more data
This commit is contained in:
parent
375a901ca0
commit
8b4f752103
|
@ -2,7 +2,7 @@ const strava = require('../shared/strava.js');
|
||||||
const withings = require('../shared/withings.js');
|
const withings = require('../shared/withings.js');
|
||||||
|
|
||||||
module.exports = async function (context, req) {
|
module.exports = async function (context, req) {
|
||||||
context.log('JavaScript HTTP trigger function processed a request.');
|
context.log('Auth function processed a request');
|
||||||
// strava example:
|
// strava example:
|
||||||
// https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read&state=strava
|
// https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read&state=strava
|
||||||
const code = (req.query.code || req.query._code || (req.body && req.body.code));
|
const code = (req.query.code || req.query._code || (req.body && req.body.code));
|
||||||
|
@ -19,6 +19,8 @@ module.exports = async function (context, req) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.log(`Processing the ${segment} code`);
|
||||||
|
|
||||||
switch (segment) {
|
switch (segment) {
|
||||||
case "strava":
|
case "strava":
|
||||||
tokens = await strava.getToken(code);
|
tokens = await strava.getToken(code);
|
||||||
|
|
|
@ -2,7 +2,7 @@ const strava = require('../shared/strava.js');
|
||||||
const withings = require('../shared/withings.js');
|
const withings = require('../shared/withings.js');
|
||||||
|
|
||||||
module.exports = async function (context, req) {
|
module.exports = async function (context, req) {
|
||||||
context.log('JavaScript HTTP trigger function processed a request.');
|
context.log('Refresh function processed a request');
|
||||||
// strava example:
|
// strava example:
|
||||||
// https://ohmyposh.dev/api/refresh?segment=strava&token=<refresh_token>
|
// https://ohmyposh.dev/api/refresh?segment=strava&token=<refresh_token>
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ module.exports = async function (context, req) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.log(`Refreshing the ${segment} token`);
|
||||||
let body = null;
|
let body = null;
|
||||||
switch (segment) {
|
switch (segment) {
|
||||||
case "strava":
|
case "strava":
|
||||||
|
@ -25,8 +26,9 @@ module.exports = async function (context, req) {
|
||||||
body = await withings.refreshToken(refresh_token);
|
body = await withings.refreshToken(refresh_token);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
context.log(`Unknown segment: ${segment}`);
|
||||||
context.res = {
|
context.res = {
|
||||||
body: "unknown segment",
|
body: "Unknown segment",
|
||||||
status: 400
|
status: 400
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue