diff --git a/routes/api.js b/routes/api.js index d1c038c..6fba983 100644 --- a/routes/api.js +++ b/routes/api.js @@ -1,20 +1,9 @@ const routes = require('express').Router(); - - const got = require("got"); - - -const GITHUB_API = "https://api.github.com"; - - -const configLoader = require('../configManager'); - -const authenticate = "client_id=" + configLoader.getClientID() + - "&client_secret=" + configLoader.getClientSecret(); - - -//caching program to make the application run faster const cache = require('memory-cache'); +const dotenv = require("dotenv").config(); +const GITHUB_API = "https://api.github.com"; +const authenticate = `client_id=${process.env.CLIENT_ID}&client_secret=${process.env.CLIENT_SECRET}`; function queryGitHubAPI(requestURL) diff --git a/server.js b/server.js index 0dc6057..b99e1e7 100644 --- a/server.js +++ b/server.js @@ -1,30 +1,21 @@ -/** express app for routing */ const express = require("express"); - -/**session data for login and storing preferences*/ const session = require('express-session'); - -const configLoader = require('./configManager.js'); - - +const dotenv = require("dotenv").config(); const app = express(); -/**Initializes sessions for login */ -app.use(session( - { secret: configLoader.getSessionSecret(), - cookie: { maxAge: 6000000 }} -)); - - -app.use(express.urlencoded()); //for easy retrieval of post and get data +const sessionProperties = { + secret: process.env.SESSION_SECRET, + cookie: { maxAge: 6000000 }, + resave: false, + saveUninitialized: false +}; +app.use(session(sessionProperties)); +app.use(express.urlencoded({ extended: true })); app.use(express.json()); - app.use(express.static('public')); const routes = require('./routes'); app.use('/', routes); -app.listen(configLoader.getConfiguration().port, () => - console.log(`App listening on port ${configLoader.getPort()}!`) -); \ No newline at end of file +app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`)); \ No newline at end of file