diff --git a/w3/app.js b/w3/app.js index 719544a..1319055 100644 --- a/w3/app.js +++ b/w3/app.js @@ -1,10 +1,11 @@ -const express = require('express'); -const app = express(); -const bodyParser = require('body-parser'); -const morgan = require('morgan'); -const db = require('./db/db'); -const Student = require('./routes/student'); -const Test = require('./routes/test'); +const express = require('express') +const app = express() +const bodyParser = require('body-parser') +const Student = require('./routes/student') +const Test = require('./routes/test') +const morgan = require('morgan') +const db = require('./db/db') +const path = require('path'); app.use(bodyParser.json()); @@ -12,23 +13,19 @@ app.use(bodyParser.urlencoded({ extended: true })); app.use(morgan('dev')); +app.use('/student', Student) +app.use('/test', Test) + +app.use(express.static(path.join(__dirname, 'public'))); app.use(function(err, req, res, next) { console.error(err.stack); res.status(500).send('Something broke!'); }); - -if (require.main === module){ - //will only run when run with npm start and not with npm test to avoid db syncing in multiple threads when running tests - db - .sync() - .then(() => - app.listen(3000, function() { - console.log('Server is listening on port 3000!'); - }) - ) - .catch(console.error); -} - -module.exports = app; +db.sync() + .then(() => app.listen(3000, function () { + console.log('Server is listening on port 3000!'); + }) + ) + .catch(console.error); diff --git a/w3/public/bundle.js b/w3/public/bundle.js index b269e9b..986ff4f 100644 --- a/w3/public/bundle.js +++ b/w3/public/bundle.js @@ -60,11 +60,12 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ return __webpack_require__(__webpack_require__.s = 14); /******/ }) /************************************************************************/ -/******/ ([ -/* 0 */ +/******/ ({ + +/***/ 14: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -73,5 +74,6 @@ console.log("Hello Webpack!"); /***/ }) -/******/ ]); + +/******/ }); //# sourceMappingURL=bundle.js.map \ No newline at end of file diff --git a/w3/public/bundle.js.map b/w3/public/bundle.js.map index 071f0f6..293e9c2 100644 --- a/w3/public/bundle.js.map +++ b/w3/public/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap b898ba5b551de1dfcc79","webpack:///./browser/index.js"],"names":["console","log"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;AC7DAA,QAAQC,GAAR,CAAY,gBAAZ,E","file":"./public/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap b898ba5b551de1dfcc79","console.log(\"Hello Webpack!\")\n\n\n// WEBPACK FOOTER //\n// ./browser/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 51c911d43a254aa58ae1","webpack:///./browser/index.js"],"names":["console","log"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;AC7DAA,QAAQC,GAAR,CAAY,gBAAZ,E","file":"./public/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 51c911d43a254aa58ae1","console.log(\"Hello Webpack!\")\n\n\n// WEBPACK FOOTER //\n// ./browser/index.js"],"sourceRoot":""} \ No newline at end of file