Compare commits

..

No commits in common. "989b582cf4043ea1cec2fd2b4da1633c9905a4df" and "26f5382fce48ebeab552c0a34ee60750370ab0ad" have entirely different histories.

3 changed files with 40 additions and 52 deletions

1
.gitignore vendored
View file

@ -14,6 +14,5 @@ sent # all sent mail is there
.cache/* .cache/*
.env .env
.env.* .env.*
!.env.example
.uptime-url .uptime-url
main.cron main.cron

View file

@ -1,6 +0,0 @@
SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
SLACK_TOKEN=
SPOTIFY_CLIENT_ID=
SPOTIFY_CLIENT_SECRET=
SPOTIFY_REDIRECT_URI=

View file

@ -1,45 +1,40 @@
const path = require("path"); require('dotenv').config();
require("dotenv").config({ path: path.join(__dirname, ".env") }); const express = require('express');
console.debug(process.env); const session = require('express-session');
const express = require("express"); const { WebClient } = require('@slack/web-api');
const session = require("express-session"); const { Client } = require('@slack/oauth');
const { WebClient } = require("@slack/web-api"); const { getLoginUrl, refreshToken } = require('./spotify');
const { InstallProvider } = require("@slack/oauth"); const path = require('path');
const { getLoginUrl, refreshToken } = require("./spotify");
const app = express(); const app = express();
// Initialize // Initialize
const web = new WebClient(process.env.SLACK_TOKEN); const web = new WebClient(process.env.SLACK_TOKEN);
const oauth = new InstallProvider({ const oauth = new Client({
clientId: process.env.SLACK_CLIENT_ID, clientId: process.env.SLACK_CLIENT_ID,
clientSecret: process.env.SLACK_CLIENT_SECRET, clientSecret: process.env.SLACK_CLIENT_SECRET,
stateSecret: Math.random().toString(36).substring(2), state: Math.random().toString(36).substring(2),
}); });
app.use(express.json()); app.use(express.json());
app.use(express.static(path.join(__dirname, "public"))); app.use(express.static(path.join(__dirname, 'public')));
app.set("view engine", "ejs"); app.set('view engine', 'ejs');
app.set("views", "src/views"); app.set('views', 'src/views');
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use( app.use(session({
session({
secret: Math.random().toString(36).substring(2), secret: Math.random().toString(36).substring(2),
resave: false, resave: false,
saveUninitialized: true, saveUninitialized: true,
cookie: { secure: true }, cookie: { secure: true }
}), }));
);
app.get("/", (req, res) => { app.get('/', (req, res) => {
res.render("index", { res.render('index', { title: 'Hack Club Spotify Bot', description: "Contribute to the hackclub spotify playlist!" });
title: "Hack Club Spotify Bot",
description: "Contribute to the hackclub spotify playlist!",
});
}); });
app.get("/login", async (req, res) => { app.get('/login', async (req, res) => {
if (req.session.token) { if(req.session.token) {
} }
}); })
app.listen(process.env.PORT || 3000, () => { app.listen(process.env.PORT || 3000, () => {
console.log("Example app listening on port 3000!"); console.log('Example app listening on port 3000!');
}); });