Skip to content

Commit

Permalink
Remove dependency on databases
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben1152000 committed Jul 22, 2021
1 parent 2fb691b commit 7ac9d7f
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 26 deletions.
22 changes: 13 additions & 9 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ const app = require("../src/app");
const port = ( process.env.PORT || 5000 );
const http = require("http");

models.sequelize.sync({
logging: app.get("env") !== "production" && console.log,
force: false
}).then(() => {
console.log("Successfully migrated and connected to database");
http.createServer(app).listen(port, () => console.log("Server listening in on port", port));
}).catch((err) => {
console.log("Could not connect to database", err);
});
// models.sequelize.sync({
// logging: app.get("env") !== "production" && console.log,
// force: false
// }).then(() => {
// console.log("Successfully migrated and connected to database");
// http.createServer(app).listen(port, () => console.log("Server listening in on port", port));
// }).catch((err) => {
// console.log("Could not connect to database", err);
// });

// Ben: I removed the lines above so that the site will work without the database.

http.createServer(app).listen(port, () => console.log("Server listening in on port", port));
201 changes: 201 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"node": "8.2.1"
},
"devDependencies": {
"gh-pages": "^3.2.3",
"install-peers": "^1.0.3",
"node-sass": "^4.13.0",
"nodemon": "^1.18.3"
Expand Down
36 changes: 19 additions & 17 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,31 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(logger("dev"));

let SessionStore = process.env.NODE_ENV == "production" ? (
new MongoStore({
url: process.env.SESSION_STORE,
ttl: 14 * 24 * 60 * 60
})
) : undefined;

app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
store: SessionStore,
cookie: {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 60)
}
}));
app.use(flash());
// let SessionStore = process.env.NODE_ENV == "production" ? (
// new MongoStore({
// url: process.env.SESSION_STORE,
// ttl: 14 * 24 * 60 * 60
// })
// ) : undefined;

// app.use(session({
// secret: process.env.SESSION_SECRET,
// resave: false,
// saveUninitialized: false,
// store: SessionStore,
// cookie: {
// expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 60)
// }
// }));
// app.use(flash());

// Passport initialize
require("./config/passport");
app.use(passport.initialize());
app.use(passport.session());

// Ben: I removed the lines above so that the site will work without the database.

// Import main route controller here
require("./routes/controller")(app);

Expand Down

0 comments on commit 7ac9d7f

Please sign in to comment.