UNPKG

spotify-now

Version:
28 lines 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getToken = void 0; const tslib_1 = require("tslib"); const express_1 = (0, tslib_1.__importDefault)(require("express")); const db_1 = require("../db"); const getSpotifyApi_1 = require("./getSpotifyApi"); const app = (0, express_1.default)(); function getToken(clientId, clientSecret) { return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const spotifyApi = yield (0, getSpotifyApi_1.getSpotifyApi)(clientId, clientSecret); app .get("/", (req, res) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const code = req.query.code; spotifyApi.authorizationCodeGrant(code, (error, result) => { if (error) return console.error(error); const { access_token, refresh_token } = result.body; (0, db_1.saveUser)({ access_token, refresh_token, clientId, clientSecret }); res.send("You can close this window now."); process.exit(0); }); })) .listen(6969); }); } exports.getToken = getToken; //# sourceMappingURL=getToken.js.map