Fix node script start; Fix squad-model sortingNumber max; Refractor config path

pull/1/head
Florian Hartwich 2017-05-11 18:36:32 +02:00
parent 2becc92b31
commit 686186b306
17 changed files with 27 additions and 31 deletions

3
.gitignore vendored
View File

@ -1,8 +1,5 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# external project
/rest-server
# compiled output
/dist
/tmp

View File

@ -1,11 +1,10 @@
module.exports = {
port: 8091,
secret: "!78sg7gu/fdi78(G/bgu=lö'+++c:4863",
secret: "$8h94j+8z4trh%nj+18tj!h4gf8zu&#418zf4zjt(16",
database: {
uri: 'mongodb://localhost:27017/',
db: 'cc',
},
test: {

View File

@ -1,7 +1,7 @@
"use strict"
const jwt = require('jsonwebtoken');
const config = require('../config');
const config = require('../config/config');
const apiAuthentication = (req, res, next) => {

View File

@ -15,7 +15,6 @@ const SquadSchema = new Schema({
},
sortingNumber: {
type: Number,
max: 22,
get: v => Math.round(v),
set: v => Math.round(v),
default: 0

View File

@ -11,7 +11,7 @@ const logger = require('debug')('cc:authenticate');
// HTTP status codes by name
const codes = require('./http-codes');
const config = require('../config');
const config = require('../config/config');
const routerHandling = require('../middleware/router-handling');

View File

@ -29,7 +29,7 @@ squads.route('/')
if (req.query.q) {
filter.name = {$regex: req.query.q, $options: 'i'}
}
SquadModel.find(filter, {}, {sort: {fraction: 'asc', name: 'asc'}}, (err, items) => {
SquadModel.find(filter, {}, {sort: {sortingNumber: 'asc', fraction: 'asc'}}, (err, items) => {
if (err) {
err.status = codes.servererror;
return next(err);

View File

@ -9,7 +9,8 @@ const debug = require('debug')('cc:server');
const mongoose = require('mongoose');
// own modules
const config = require('./config');
const config = require('./config/config');
const urls = require('./config/api-url');
const restAPIchecks = require('./middleware/request-checks.js');
const errorResponseWare = require('./middleware/error-response');
const apiAuthenticationMiddleware = require('./middleware/auth-middleware');
@ -48,17 +49,17 @@ app.use(restAPIchecks);
// Routes ******************************************************
app.use('/authenticate', authenticateRouter);
app.use('/signatures', signatureRouter);
app.use(urls.auth, authenticateRouter);
app.use(urls.signatures, signatureRouter);
// all following routes need a jwt token to access
app.use('/overview', overviewRouter);
app.use('/users', userRouter);
app.use('/squads', squadRouter);
app.use('/ranks', rankRouter);
app.use('/decorations', decorationRouter);
app.use('/awardings', apiAuthenticationMiddleware, awardingRouter);
app.use('/cmd', apiAuthenticationMiddleware, commandRouter);
app.use(urls.overview, overviewRouter);
app.use(urls.users, userRouter);
app.use(urls.squads, squadRouter);
app.use(urls.ranks, rankRouter);
app.use(urls.decorations, decorationRouter);
app.use(urls.awards, apiAuthenticationMiddleware, awardingRouter);
app.use(urls.command, apiAuthenticationMiddleware, commandRouter);
// send index.html on all different paths
app.use(function (req, res) {

View File

@ -1,6 +1,6 @@
let mongoose = require("mongoose");
let AwardingModel = require('../models/awarding');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -1,6 +1,6 @@
let mongoose = require("mongoose");
let AwardingModel = require('../models/awarding');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -1,3 +1,3 @@
const config = require('../../config');
const config = require('../../config/config');
process.env.NODE_ENV = config.test.env;

View File

@ -1,4 +1,4 @@
const config = require('../../config');
const config = require('../../config/config');
const mongoose = require('mongoose');
mongoose.connect(config.database.uri + config.database.db);
const UserModel = require('../../models/user');

View File

@ -1,6 +1,6 @@
let mongoose = require("mongoose");
let DecorationModel = require('../models/decoration');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -1,6 +1,6 @@
let mongoose = require("mongoose");
let RankModel = require('../models/rank');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -1,6 +1,6 @@
let mongoose = require("mongoose");
let SquadModel = require('../models/squad');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -1,7 +1,7 @@
let mongoose = require("mongoose");
let UserModel = require('../models/user');
let AppUserModel = require('../models/app-user');
let urls = require('../routes/api-url');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');

View File

@ -4,10 +4,10 @@
"license": "MIT",
"private": true,
"scripts": {
"start": "npm run deploy-static-prod && node ./rest-server/server.js",
"dev": "npm run deploy-static && nodemon api/server.js",
"deploy-static": "cd static && ng build && ln -s ../api/resource/ ../public/resource",
"deploy-static-prod": "cd static && ng build --env=prod && ln -s ../api/resource/ ../public/resource",
"start": "npm run deploy-static-prod && node ./api/server.js",
"dev": "npm run deploy-static && nodemon ./api/server.js",
"deploy-static": "cd ./static && ng build && ln -s ../api/resource/ ../public/resource",
"deploy-static-prod": "cd ./static && ng build --env=prod && ln -s ../api/resource/ ../public/resource",
"postinstall": "npm install --prefix ./static && npm install --prefix ./api",
"mongodb": "mongod --dbpath ./mongodb-data",
"test": "npm test --prefix ./api"