aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2021-09-19 19:50:25 -0400
committerMax Isom <[email protected]>2021-09-19 19:50:25 -0400
commitefcdeb78c8b690bc544dac1ed0be96a6693bcff6 (patch)
treed4a453f92d928613c2f4209af7475190a093321d /src/index.ts
parent79e7e88fab1ce05cf84abeba2e05300a93b4759c (diff)
downloadmuse-efcdeb78c8b690bc544dac1ed0be96a6693bcff6.tar.xz
muse-efcdeb78c8b690bc544dac1ed0be96a6693bcff6.zip
Reorg third party services & config
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/index.ts b/src/index.ts
index 2cdd6f1..7b1aac4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,31 +1,20 @@
-import Spotify from 'spotify-web-api-node';
import makeDir from 'make-dir';
import path from 'path';
import container from './inversify.config';
import {TYPES} from './types';
import Bot from './bot';
import {sequelize} from './utils/db';
+import Config from './services/config';
-let bot = container.get<Bot>(TYPES.Bot);
-const spotify = container.get<Spotify>(TYPES.Lib.Spotify);
-
-const refreshSpotifyToken = async () => {
- const auth = await spotify.clientCredentialsGrant();
-
- spotify.setAccessToken(auth.body.access_token);
-
- return auth.body.expires_in;
-};
+const bot = container.get<Bot>(TYPES.Bot);
(async () => {
- const spotifyRefreshIntervalSeconds = await refreshSpotifyToken();
-
- setInterval(async () => refreshSpotifyToken(), (spotifyRefreshIntervalSeconds / 2) * 1000);
-
// Create data directories if necessary
- await makeDir(container.get(TYPES.Config.DATA_DIR));
- await makeDir(container.get(TYPES.Config.CACHE_DIR));
- await makeDir(path.join(container.get(TYPES.Config.CACHE_DIR), 'tmp'));
+ const config = container.get<Config>(TYPES.Config);
+
+ await makeDir(config.DATA_DIR);
+ await makeDir(config.CACHE_DIR);
+ await makeDir(path.join(config.CACHE_DIR, 'tmp'));
await sequelize.sync({});