mirror of
https://github.com/feeddeck/feeddeck.git
synced 2026-04-28 01:48:28 -05:00
The log level is now configurable, via the `FEEDDECK_LOG_LEVEL` environment variable. The environment variable can have the following values: `debug`, `info`, `warning` or `error`. With this change we also only log the response when getting and parsing the feed fails when the log level is set to `debug`, also when the actual message is still an error. This should reduce the noice in the logs a lot and allows us to specially turn this on while debugging.
82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import { createClient } from '@supabase/supabase-js';
|
|
|
|
import { generateKey } from '../../_shared/utils/encrypt.ts';
|
|
import { log } from '../../_shared/utils/log.ts';
|
|
import { generateAppleSecretKey } from './apple-secret-key.ts';
|
|
import { getFeed } from '../../_shared/feed/feed.ts';
|
|
|
|
export const runTools = async (args: string[]): Promise<void> => {
|
|
/**
|
|
* The "tools generate-key" command can be invoked via the following command:
|
|
* deno run --no-lock --allow-net --allow-env --import-map=./supabase/functions/import_map.json ./supabase/functions/_cmd/cmd.ts tools generate-key
|
|
*/
|
|
if (
|
|
args.length === 2 && args[0] === 'tools' &&
|
|
args[1] === 'generate-key'
|
|
) {
|
|
const data = await generateKey();
|
|
log('info', 'Encryption key was generated', {
|
|
key: data.rawKey,
|
|
iv: data.iv,
|
|
});
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* The "tools generate-apple-secret-key" command can be invoked via the
|
|
* following command:
|
|
* deno run --no-lock --allow-env --allow-read --import-map=./supabase/functions/import_map.json ./supabase/functions/_cmd/cmd.ts tools generate-apple-secret-key <KEY-ID> <TEAM-ID> <SERVICE-ID> <FILE>
|
|
*/
|
|
if (
|
|
args.length === 6 && args[0] === 'tools' &&
|
|
args[1] === 'generate-apple-secret-key'
|
|
) {
|
|
const data = await generateAppleSecretKey(
|
|
args[2],
|
|
args[3],
|
|
args[4],
|
|
args[5],
|
|
);
|
|
log('info', 'Encryption key was generated', {
|
|
kid: data.kid,
|
|
exp: new Date(data.exp * 1000).toString(),
|
|
jwt: data.jwt,
|
|
});
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* The "tools get-feed" command can be invoked via the following command:
|
|
* deno run --no-lock --allow-env --allow-read --allow-net --import-map=./supabase/functions/import_map.json ./supabase/functions/_cmd/cmd.ts tools get-feed <SOURCE>
|
|
*
|
|
* The command gets a source and the items for a provided source. The provided
|
|
* source must contain the type and options to get a feed. All other required
|
|
* properties for a source are added by the function.
|
|
*
|
|
* Example:
|
|
* deno run --no-lock --allow-env --allow-read --allow-net --import-map=./supabase/functions/import_map.json ./supabase/functions/_cmd/cmd.ts tools get-feed '{"type": "reddit", "options": {"reddit": "/r/kubernetes"}}'
|
|
*/
|
|
if (
|
|
args.length === 3 && args[0] === 'tools' &&
|
|
args[1] === 'get-feed'
|
|
) {
|
|
const { source, items } = await getFeed(
|
|
createClient('http://localhost:54321', 'test123'),
|
|
undefined,
|
|
{ id: '', tier: 'free', createdAt: 0, updatedAt: 0 },
|
|
{
|
|
...JSON.parse(args[2]),
|
|
id: '',
|
|
columnId: 'mycolumn',
|
|
userId: 'myuser',
|
|
},
|
|
undefined,
|
|
);
|
|
log('info', 'Add source', {
|
|
source: source,
|
|
items: items,
|
|
});
|
|
return;
|
|
}
|
|
};
|