Fix config missing on test
This commit is contained in:
parent
6e57b478e4
commit
3e0dd4f48f
3 changed files with 6 additions and 4 deletions
7
app.js
7
app.js
|
@ -5,18 +5,21 @@ let cookieParser = require("cookie-parser");
|
|||
let logger = require("morgan");
|
||||
let sassMiddleware = require("node-sass-middleware");
|
||||
const session = require("express-session");
|
||||
const config = require("./config/config.json");
|
||||
let config = process.env.NODE_ENV === "test" ? {} : require("./config/config.json");
|
||||
|
||||
let indexRouter = require("./routes/index");
|
||||
const loginRouter = require("./routes/login");
|
||||
|
||||
let app = express();
|
||||
const sessionMiddleware = session({secret: config.secret});
|
||||
const sessionMiddleware = session({
|
||||
secret: process.env.NODE_ENV === "test" ? "Keyboard Cat" : config.secret
|
||||
});
|
||||
|
||||
// view engine setup
|
||||
app.set("views", path.join(__dirname, "views"));
|
||||
app.set("view engine", "pug");
|
||||
app.set("sessionMiddleware", sessionMiddleware);
|
||||
app.set("config", config);
|
||||
|
||||
app.use(logger("dev"));
|
||||
app.use(express.json());
|
||||
|
|
|
@ -4,7 +4,6 @@ const fs = require("fs");
|
|||
const path = require("path");
|
||||
const Sequelize = require("sequelize");
|
||||
const basename = path.basename(__filename);
|
||||
const config = require(__dirname + "/../config/config.json")["database"];
|
||||
const db = {};
|
||||
|
||||
let sequelize;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const crypto = require("crypto");
|
||||
const privateKey = require("../config/config.json").passwordPrivateKey;
|
||||
const privateKey = process.env.NODE_ENV === "test" ? require("../config/config_example.json") : require("../config/config.json").passwordPrivateKey;
|
||||
|
||||
const {
|
||||
Model
|
||||
|
|
Reference in a new issue