From 7c8a4129e860ac0eb9e7c39616da72caff552a62 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Tue, 1 Aug 2017 23:52:10 +0200 Subject: [PATCH] Add api root path; Introduce ng route config --- api/config/api-url.js | 30 +++++++------ api/server.js | 34 +++++++++------ static/src/app/app.component.html | 28 ++++++------ static/src/app/app.component.ts | 7 ++- static/src/app/app.config.ts | 43 +++++++++++++------ static/src/app/app.routing.ts | 32 +++++++------- .../src/app/army/army-member.component.html | 2 +- static/src/app/army/army-member.component.ts | 3 +- static/src/app/login/login.component.ts | 3 +- static/src/app/login/signup.component.ts | 3 +- .../app-user-service/app-user.service.ts | 6 +-- .../app/services/army-service/army.service.ts | 2 +- .../awarding-service/awarding.service.ts | 12 +++--- .../decoration-service/decoration.service.ts | 8 ++-- .../services/login-service/login-service.ts | 4 +- .../promotion-service/promotion.service.ts | 10 ++--- .../app/services/rank-service/rank.service.ts | 12 +++--- .../services/squad-service/squad.service.ts | 8 ++-- .../app/services/user-service/user.service.ts | 10 ++--- .../app/services/war-service/war.service.ts | 8 ++-- 20 files changed, 149 insertions(+), 116 deletions(-) diff --git a/api/config/api-url.js b/api/config/api-url.js index e474c00..cbd02ca 100644 --- a/api/config/api-url.js +++ b/api/config/api-url.js @@ -1,16 +1,18 @@ +const rootRoute = '/api'; + module.exports = { - auth: '/authenticate', - signUp: '/authenticate/signup', - awards: '/awardings', - command: '/cmd', - cmdCreateSig: '/cmd/createSignature', - decorations: '/decorations', - overview: '/overview', - ranks: '/ranks', - signatures: '/signatures', - squads: '/squads', - users: '/users', - account: '/account', - request: '/request', - wars: '/wars' + auth: rootRoute + '/authenticate', + signUp: rootRoute + '/authenticate/signup', + awards: rootRoute + '/awardings', + command: rootRoute + '/cmd', + cmdCreateSig: rootRoute + '/cmd/createSignature', + decorations: rootRoute + '/decorations', + overview: rootRoute + '/overview', + ranks: rootRoute + '/ranks', + signatures: rootRoute + '/signatures', + squads: rootRoute + '/squads', + users: rootRoute + '/users', + account: rootRoute + '/account', + request: rootRoute + '/request', + wars: rootRoute + '/wars' }; diff --git a/api/server.js b/api/server.js index 4ee2441..c51684f 100644 --- a/api/server.js +++ b/api/server.js @@ -103,21 +103,29 @@ errorResponseWare(app); // Start the server if (process.env.NODE_ENV !== config.test.env) { - mongoose.connect(config.database.uri + config.database.db); - app.listen(config.port, (err) => { - if (err !== undefined) { - debug('Error on startup, ', err); - } - else { - debug('Listening on port ' + config.port); - signatureCronJob.start(); - backupCronJob.start(); - } + const mongoosePromise = mongoose.connect(config.database.uri + config.database.db, { + useMongoClient: true }); + mongoosePromise.then((db) => { + app.listen(config.port, (err) => { + if (err !== undefined) { + debug('Error on startup, ', err); + } + else { + debug('Listening on port ' + config.port); + signatureCronJob.start(); + backupCronJob.start(); + } + }); + }) } else { - mongoose.connect(config.database.uri + config.test.db); - app.listen(config.test.port); - console.log('Listening on port ' + config.test.port); + const mongoosePromise = mongoose.connect(config.database.uri + config.test.db, { + useMongoClient: true + }); + mongoosePromise.then((db) => { + app.listen(config.test.port); + console.log('Listening on port ' + config.test.port); + }) } module.exports = app; diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 611bdc7..46e1d09 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -16,10 +16,10 @@