Browse Source

Implement dotenv and fixed express deprecation errors

pull/18/head
Peter Morgan 4 years ago
parent
commit
3c74fe5734
2 changed files with 13 additions and 33 deletions
  1. +3
    -14
      routes/api.js
  2. +10
    -19
      server.js

+ 3
- 14
routes/api.js View File

@ -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)

+ 10
- 19
server.js View File

@ -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()}!`)
);
app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`));

Loading…
Cancel
Save