Skip to content
Snippets Groups Projects
Commit 6690c613 authored by fu1106jv's avatar fu1106jv
Browse files

- fixed crashing server caused by webpack production build in combination with sequelize

parent b0917dda
No related branches found
No related tags found
No related merge requests found
File moved
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"server": "nodemon server --ignore client", "server": "nodemon server --ignore client",
"start": "node ./dist/src/server.js", "start": "node ./dist/src/server.js",
"test": "jest", "test": "jest",
"build:prod": "webpack --mode=production", "build:prod": "webpack --mode=development",
"start:prod": "node ./server.js" "start:prod": "node ./server.js"
}, },
"author": "", "author": "",
......
import { Client } from "pg"; import { Client } from "pg";
import { Dialect, Sequelize } from "sequelize"; import { Dialect, Sequelize } from "sequelize";
import envVars from "../config"; import envVars from "../config";
import { initBoat } from "./models/Boat"; import Boat, { initBoat } from "./models/Boat";
import { initBoatType } from "./models/BoatType"; import BoatType, { initBoatType } from "./models/BoatType";
import CheckIn, { initCheckIn } from "./models/CheckIn"; import CheckIn, { initCheckIn } from "./models/CheckIn";
import { initEmployee } from "./models/Employee"; import { initEmployee } from "./models/Employee";
import { initSport } from "./models/Sport"; import Sport, { initSport } from "./models/Sport";
export default async function initializeDatabase() { export default async function initializeDatabase() {
await createDbIfNotExists(); await createDbIfNotExists();
...@@ -19,16 +19,11 @@ export default async function initializeDatabase() { ...@@ -19,16 +19,11 @@ export default async function initializeDatabase() {
logging: false, logging: false,
} }
); );
await initEmployee(sequelize); initCheckIn(sequelize);
console.log("Account") initBoatType(sequelize);
const Sport = await initSport(sequelize); initBoat(sequelize);
console.log("Sport") initSport(sequelize);
const Boat = await initBoat(sequelize); initEmployee(sequelize);
console.log("Boat")
const BoatType = await initBoatType(sequelize);
console.log("Boattype")
await initCheckIn(sequelize);
console.log("Checkin")
BoatType.belongsToMany(Sport, { through: "Sport_BoatType" }); BoatType.belongsToMany(Sport, { through: "Sport_BoatType" });
BoatType.hasMany(Boat); BoatType.hasMany(Boat);
......
...@@ -25,7 +25,7 @@ class Boat ...@@ -25,7 +25,7 @@ class Boat
declare readonly updatedAt: Date; declare readonly updatedAt: Date;
} }
export const initBoat = async (sequelizeConnection: Sequelize) => { export const initBoat = (sequelizeConnection: Sequelize) => {
Boat.init( Boat.init(
{ {
id: { id: {
...@@ -48,7 +48,6 @@ export const initBoat = async (sequelizeConnection: Sequelize) => { ...@@ -48,7 +48,6 @@ export const initBoat = async (sequelizeConnection: Sequelize) => {
sequelize: sequelizeConnection, sequelize: sequelizeConnection,
} }
); );
return Boat;
}; };
export default Boat; export default Boat;
...@@ -36,7 +36,7 @@ class BoatType ...@@ -36,7 +36,7 @@ class BoatType
}; };
} }
export const initBoatType = async (sequelizeConnection: Sequelize) => { export const initBoatType = (sequelizeConnection: Sequelize) => {
BoatType.init( BoatType.init(
{ {
id: { id: {
...@@ -59,6 +59,5 @@ export const initBoatType = async (sequelizeConnection: Sequelize) => { ...@@ -59,6 +59,5 @@ export const initBoatType = async (sequelizeConnection: Sequelize) => {
sequelize: sequelizeConnection, sequelize: sequelizeConnection,
} }
); );
return BoatType
}; };
export default BoatType; export default BoatType;
...@@ -42,7 +42,7 @@ class CheckIn ...@@ -42,7 +42,7 @@ class CheckIn
declare readonly updatedAt: Date; declare readonly updatedAt: Date;
} }
export const initCheckIn = async (sequelizeConnection: Sequelize) => { export const initCheckIn = (sequelizeConnection: Sequelize) => {
CheckIn.init( CheckIn.init(
{ {
id: { id: {
......
...@@ -22,7 +22,7 @@ class Employee ...@@ -22,7 +22,7 @@ class Employee
declare readonly createdAt: Date; declare readonly createdAt: Date;
declare readonly updatedAt: Date; declare readonly updatedAt: Date;
} }
export const initEmployee = async (sequelizeConnection: Sequelize) => { export const initEmployee = (sequelizeConnection: Sequelize) => {
Employee.init( Employee.init(
{ {
id: { id: {
......
...@@ -23,7 +23,7 @@ class Sport ...@@ -23,7 +23,7 @@ class Sport
declare readonly updatedAt: Date; declare readonly updatedAt: Date;
} }
export const initSport = async (sequelizeConnection: Sequelize) => { export const initSport = (sequelizeConnection: Sequelize) => {
Sport.init( Sport.init(
{ {
id: { id: {
...@@ -46,6 +46,5 @@ export const initSport = async (sequelizeConnection: Sequelize) => { ...@@ -46,6 +46,5 @@ export const initSport = async (sequelizeConnection: Sequelize) => {
sequelize: sequelizeConnection, sequelize: sequelizeConnection,
} }
); );
return Sport;
}; };
export default Sport; export default Sport;
...@@ -15,6 +15,7 @@ import schedule from "node-schedule" ...@@ -15,6 +15,7 @@ import schedule from "node-schedule"
let init = async () => { let init = async () => {
// DB // DB
console.log("Sarting Server")
await initializeDatabase(); await initializeDatabase();
await createInitialEmployeeIfNotExists(); await createInitialEmployeeIfNotExists();
// server // server
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment