diff --git a/server/app.js b/server/app.js index c7a42c8..1d29be9 100644 --- a/server/app.js +++ b/server/app.js @@ -3,6 +3,7 @@ var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var logger = require('morgan'); +const cors = require('cors'); var indexRouter = require('./routes/index'); @@ -16,6 +17,7 @@ app.use(logger('dev')); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); +app.use(cors()) app.use(express.static(path.join(__dirname, 'public'))); app.use('/', indexRouter); diff --git a/server/database/data.json b/server/database/data.json index 01d9236..da72eb0 100644 --- a/server/database/data.json +++ b/server/database/data.json @@ -1,102 +1,104 @@ -[ - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false -] \ No newline at end of file +{ + "data": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] +} diff --git a/server/package-lock.json b/server/package-lock.json index de5e59a..596e4ad 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -206,6 +206,16 @@ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.10.tgz", "integrity": "sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==" }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", diff --git a/server/package.json b/server/package.json index 6fd12b3..7defeb6 100644 --- a/server/package.json +++ b/server/package.json @@ -12,5 +12,8 @@ "http-errors": "~1.6.3", "morgan": "~1.9.1", "pug": "^2.0.4" + }, + "devDependencies": { + "cors": "^2.8.5" } } diff --git a/server/routes/index.js b/server/routes/index.js index f148084..e744cab 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -5,7 +5,7 @@ var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { - res.json(JSON.parse(fs.readFileSync('../database/data.json').toString())); + res.json(JSON.parse(fs.readFileSync(__dirname + '/../database/data.json').toString())); }); module.exports = router; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 826bfe8..b6e6294 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,5 +1,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import { HttpClientModule } from '@angular/common/http'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; @@ -14,7 +15,8 @@ import { LoginComponent } from './components/login/login.component'; ], imports: [ BrowserModule, - AppRoutingModule + AppRoutingModule, + HttpClientModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/components/home/home.component.html b/src/app/components/home/home.component.html index 5f2c53f..953253e 100644 --- a/src/app/components/home/home.component.html +++ b/src/app/components/home/home.component.html @@ -1 +1,6 @@ -
home works!
+