From fc0dc7cf16587047e1e1c4c1ec0bae8013798d0d Mon Sep 17 00:00:00 2001 From: Saahil Date: Fri, 11 Oct 2024 19:27:28 +0000 Subject: [PATCH 1/4] update: .env stuff --- hackclub-spotify-bot/src/.env.example | 6 +++ hackclub-spotify-bot/src/index.js | 59 +++++++++++++++------------ 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 hackclub-spotify-bot/src/.env.example diff --git a/hackclub-spotify-bot/src/.env.example b/hackclub-spotify-bot/src/.env.example new file mode 100644 index 0000000..0b5bff2 --- /dev/null +++ b/hackclub-spotify-bot/src/.env.example @@ -0,0 +1,6 @@ +SLACK_CLIENT_ID= +SLACK_CLIENT_SECRET= +SLACK_TOKEN= +SPOTIFY_CLIENT_ID= +SPOTIFY_CLIENT_SECRET= +SPOTIFY_REDIRECT_URI= \ No newline at end of file diff --git a/hackclub-spotify-bot/src/index.js b/hackclub-spotify-bot/src/index.js index ce9cfc7..3d732ad 100644 --- a/hackclub-spotify-bot/src/index.js +++ b/hackclub-spotify-bot/src/index.js @@ -1,40 +1,45 @@ -require('dotenv').config(); -const express = require('express'); -const session = require('express-session'); -const { WebClient } = require('@slack/web-api'); -const { Client } = require('@slack/oauth'); -const { getLoginUrl, refreshToken } = require('./spotify'); -const path = require('path'); +const path = require("path"); +require("dotenv").config({ path: path.join(__dirname, ".env") }); +console.debug(process.env); +const express = require("express"); +const session = require("express-session"); +const { WebClient } = require("@slack/web-api"); +const { InstallProvider } = require("@slack/oauth"); +const { getLoginUrl, refreshToken } = require("./spotify"); const app = express(); // Initialize const web = new WebClient(process.env.SLACK_TOKEN); -const oauth = new Client({ +const oauth = new InstallProvider({ clientId: process.env.SLACK_CLIENT_ID, clientSecret: process.env.SLACK_CLIENT_SECRET, - state: Math.random().toString(36).substring(2), + stateSecret: Math.random().toString(36).substring(2), }); app.use(express.json()); -app.use(express.static(path.join(__dirname, 'public'))); -app.set('view engine', 'ejs'); -app.set('views', 'src/views'); +app.use(express.static(path.join(__dirname, "public"))); +app.set("view engine", "ejs"); +app.set("views", "src/views"); app.use(express.urlencoded({ extended: true })); -app.use(session({ - secret: Math.random().toString(36).substring(2), - resave: false, - saveUninitialized: true, - cookie: { secure: true } -})); +app.use( + session({ + secret: Math.random().toString(36).substring(2), + resave: false, + saveUninitialized: true, + cookie: { secure: true }, + }) +); -app.get('/', (req, res) => { -res.render('index', { title: 'Hack Club Spotify Bot', description: "Contribute to the hackclub spotify playlist!" }); +app.get("/", (req, res) => { + res.render("index", { + title: "Hack Club Spotify Bot", + description: "Contribute to the hackclub spotify playlist!", + }); +}); +app.get("/login", async (req, res) => { + if (req.session.token) { + } }); -app.get('/login', async (req, res) => { - if(req.session.token) { - - } -}) app.listen(process.env.PORT || 3000, () => { - console.log('Example app listening on port 3000!'); -}); \ No newline at end of file + console.log("Example app listening on port 3000!"); +}); From 0b6212d2403c9bc9500a39013b9008165817e75e Mon Sep 17 00:00:00 2001 From: "zeon-neon[bot]" <136533918+zeon-neon[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:27:38 +0000 Subject: [PATCH 2/4] enhancement(lint): Fix lint errors for hackclub-spotify-bot/src/index.js Co-authored-by: NeonGamerBot-QK Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com> --- hackclub-spotify-bot/src/index.js | 90 +++++++++++++++---------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/hackclub-spotify-bot/src/index.js b/hackclub-spotify-bot/src/index.js index 3d732ad..81b86bd 100644 --- a/hackclub-spotify-bot/src/index.js +++ b/hackclub-spotify-bot/src/index.js @@ -1,45 +1,45 @@ -const path = require("path"); -require("dotenv").config({ path: path.join(__dirname, ".env") }); -console.debug(process.env); -const express = require("express"); -const session = require("express-session"); -const { WebClient } = require("@slack/web-api"); -const { InstallProvider } = require("@slack/oauth"); -const { getLoginUrl, refreshToken } = require("./spotify"); - -const app = express(); -// Initialize -const web = new WebClient(process.env.SLACK_TOKEN); -const oauth = new InstallProvider({ - clientId: process.env.SLACK_CLIENT_ID, - clientSecret: process.env.SLACK_CLIENT_SECRET, - stateSecret: Math.random().toString(36).substring(2), -}); -app.use(express.json()); -app.use(express.static(path.join(__dirname, "public"))); -app.set("view engine", "ejs"); -app.set("views", "src/views"); -app.use(express.urlencoded({ extended: true })); -app.use( - session({ - secret: Math.random().toString(36).substring(2), - resave: false, - saveUninitialized: true, - cookie: { secure: true }, - }) -); - -app.get("/", (req, res) => { - res.render("index", { - title: "Hack Club Spotify Bot", - description: "Contribute to the hackclub spotify playlist!", - }); -}); -app.get("/login", async (req, res) => { - if (req.session.token) { - } -}); - -app.listen(process.env.PORT || 3000, () => { - console.log("Example app listening on port 3000!"); -}); +const path = require("path"); +require("dotenv").config({ path: path.join(__dirname, ".env") }); +console.debug(process.env); +const express = require("express"); +const session = require("express-session"); +const { WebClient } = require("@slack/web-api"); +const { InstallProvider } = require("@slack/oauth"); +const { getLoginUrl, refreshToken } = require("./spotify"); + +const app = express(); +// Initialize +const web = new WebClient(process.env.SLACK_TOKEN); +const oauth = new InstallProvider({ + clientId: process.env.SLACK_CLIENT_ID, + clientSecret: process.env.SLACK_CLIENT_SECRET, + stateSecret: Math.random().toString(36).substring(2), +}); +app.use(express.json()); +app.use(express.static(path.join(__dirname, "public"))); +app.set("view engine", "ejs"); +app.set("views", "src/views"); +app.use(express.urlencoded({ extended: true })); +app.use( + session({ + secret: Math.random().toString(36).substring(2), + resave: false, + saveUninitialized: true, + cookie: { secure: true }, + }), +); + +app.get("/", (req, res) => { + res.render("index", { + title: "Hack Club Spotify Bot", + description: "Contribute to the hackclub spotify playlist!", + }); +}); +app.get("/login", async (req, res) => { + if (req.session.token) { + } +}); + +app.listen(process.env.PORT || 3000, () => { + console.log("Example app listening on port 3000!"); +}); From 8fb5236dc7ee099293755960009b68bfd545cedf Mon Sep 17 00:00:00 2001 From: Saahil Date: Fri, 11 Oct 2024 19:27:52 +0000 Subject: [PATCH 3/4] update: .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c17c45f..14bac7d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ sent # all sent mail is there .cache/* .env .env.* +!.env.example .uptime-url main.cron From 989b582cf4043ea1cec2fd2b4da1633c9905a4df Mon Sep 17 00:00:00 2001 From: "zeon-neon[bot]" <136533918+zeon-neon[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:28:09 +0000 Subject: [PATCH 4/4] enhancement(lint): Fix lint errors for .gitignore Co-authored-by: NeonGamerBot-QK Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com>