forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1import chalk from "chalk";
2import { consola } from "consola";
3import { ctx } from "context";
4import { encrypt } from "lib/crypto";
5import { env } from "lib/env";
6import tables from "schema";
7
8const args = process.argv.slice(2);
9const clientId = args[0];
10const clientSecret = args[1];
11
12if (!clientId || !clientSecret) {
13 consola.error(
14 "Please provide Spotify Client ID and Client Secret as command line arguments",
15 );
16 consola.info(
17 chalk.greenBright("Usage: ts-node spotify.ts <client_id> <client_secret>"),
18 );
19 process.exit(1);
20}
21
22await ctx.db
23 .insert(tables.spotifyApps)
24 .values([
25 {
26 spotifyAppId: clientId,
27 spotifySecret: encrypt(clientSecret, env.SPOTIFY_ENCRYPTION_KEY),
28 },
29 ])
30 .onConflictDoNothing()
31 .execute();
32
33process.exit(0);