Fix node script start; Fix squad-model sortingNumber max; Refractor config path
parent
2becc92b31
commit
686186b306
|
@ -1,8 +1,5 @@
|
||||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
# external project
|
|
||||||
/rest-server
|
|
||||||
|
|
||||||
# compiled output
|
# compiled output
|
||||||
/dist
|
/dist
|
||||||
/tmp
|
/tmp
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
port: 8091,
|
port: 8091,
|
||||||
secret: "!78sg7gu/fdi78(G/bgu=lö'+++c:4863",
|
secret: "$8h94j+8z4trh%nj+18tj!h4gf8zuƢzf4zjt(16",
|
||||||
|
|
||||||
database: {
|
database: {
|
||||||
uri: 'mongodb://localhost:27017/',
|
uri: 'mongodb://localhost:27017/',
|
||||||
db: 'cc',
|
db: 'cc',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
test: {
|
test: {
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const config = require('../config');
|
const config = require('../config/config');
|
||||||
|
|
||||||
const apiAuthentication = (req, res, next) => {
|
const apiAuthentication = (req, res, next) => {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ const SquadSchema = new Schema({
|
||||||
},
|
},
|
||||||
sortingNumber: {
|
sortingNumber: {
|
||||||
type: Number,
|
type: Number,
|
||||||
max: 22,
|
|
||||||
get: v => Math.round(v),
|
get: v => Math.round(v),
|
||||||
set: v => Math.round(v),
|
set: v => Math.round(v),
|
||||||
default: 0
|
default: 0
|
||||||
|
|
|
@ -11,7 +11,7 @@ const logger = require('debug')('cc:authenticate');
|
||||||
// HTTP status codes by name
|
// HTTP status codes by name
|
||||||
const codes = require('./http-codes');
|
const codes = require('./http-codes');
|
||||||
|
|
||||||
const config = require('../config');
|
const config = require('../config/config');
|
||||||
|
|
||||||
const routerHandling = require('../middleware/router-handling');
|
const routerHandling = require('../middleware/router-handling');
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ squads.route('/')
|
||||||
if (req.query.q) {
|
if (req.query.q) {
|
||||||
filter.name = {$regex: req.query.q, $options: 'i'}
|
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) {
|
if (err) {
|
||||||
err.status = codes.servererror;
|
err.status = codes.servererror;
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|
|
@ -9,7 +9,8 @@ const debug = require('debug')('cc:server');
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
// own modules
|
// 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 restAPIchecks = require('./middleware/request-checks.js');
|
||||||
const errorResponseWare = require('./middleware/error-response');
|
const errorResponseWare = require('./middleware/error-response');
|
||||||
const apiAuthenticationMiddleware = require('./middleware/auth-middleware');
|
const apiAuthenticationMiddleware = require('./middleware/auth-middleware');
|
||||||
|
@ -48,17 +49,17 @@ app.use(restAPIchecks);
|
||||||
|
|
||||||
|
|
||||||
// Routes ******************************************************
|
// Routes ******************************************************
|
||||||
app.use('/authenticate', authenticateRouter);
|
app.use(urls.auth, authenticateRouter);
|
||||||
app.use('/signatures', signatureRouter);
|
app.use(urls.signatures, signatureRouter);
|
||||||
|
|
||||||
// all following routes need a jwt token to access
|
// all following routes need a jwt token to access
|
||||||
app.use('/overview', overviewRouter);
|
app.use(urls.overview, overviewRouter);
|
||||||
app.use('/users', userRouter);
|
app.use(urls.users, userRouter);
|
||||||
app.use('/squads', squadRouter);
|
app.use(urls.squads, squadRouter);
|
||||||
app.use('/ranks', rankRouter);
|
app.use(urls.ranks, rankRouter);
|
||||||
app.use('/decorations', decorationRouter);
|
app.use(urls.decorations, decorationRouter);
|
||||||
app.use('/awardings', apiAuthenticationMiddleware, awardingRouter);
|
app.use(urls.awards, apiAuthenticationMiddleware, awardingRouter);
|
||||||
app.use('/cmd', apiAuthenticationMiddleware, commandRouter);
|
app.use(urls.command, apiAuthenticationMiddleware, commandRouter);
|
||||||
|
|
||||||
// send index.html on all different paths
|
// send index.html on all different paths
|
||||||
app.use(function (req, res) {
|
app.use(function (req, res) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let AwardingModel = require('../models/awarding');
|
let AwardingModel = require('../models/awarding');
|
||||||
let urls = require('../routes/api-url');
|
let urls = require('../config/api-url');
|
||||||
let codes = require('../routes/http-codes');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let AwardingModel = require('../models/awarding');
|
let AwardingModel = require('../models/awarding');
|
||||||
let urls = require('../routes/api-url');
|
let urls = require('../config/api-url');
|
||||||
let codes = require('../routes/http-codes');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
const config = require('../../config');
|
const config = require('../../config/config');
|
||||||
|
|
||||||
process.env.NODE_ENV = config.test.env;
|
process.env.NODE_ENV = config.test.env;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const config = require('../../config');
|
const config = require('../../config/config');
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
mongoose.connect(config.database.uri + config.database.db);
|
mongoose.connect(config.database.uri + config.database.db);
|
||||||
const UserModel = require('../../models/user');
|
const UserModel = require('../../models/user');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let DecorationModel = require('../models/decoration');
|
let DecorationModel = require('../models/decoration');
|
||||||
let urls = require('../routes/api-url');
|
let urls = require('../config/api-url');
|
||||||
let codes = require('../routes/http-codes');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let RankModel = require('../models/rank');
|
let RankModel = require('../models/rank');
|
||||||
let urls = require('../routes/api-url');
|
let urls = require('../config/api-url');
|
||||||
let codes = require('../routes/http-codes');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let SquadModel = require('../models/squad');
|
let SquadModel = require('../models/squad');
|
||||||
let urls = require('../routes/api-url');
|
let urls = require('../config/api-url');
|
||||||
let codes = require('../routes/http-codes');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
let mongoose = require("mongoose");
|
let mongoose = require("mongoose");
|
||||||
let UserModel = require('../models/user');
|
let UserModel = require('../models/user');
|
||||||
let AppUserModel = require('../models/app-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');
|
let codes = require('../routes/http-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run deploy-static-prod && node ./rest-server/server.js",
|
"start": "npm run deploy-static-prod && node ./api/server.js",
|
||||||
"dev": "npm run deploy-static && nodemon 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": "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",
|
"deploy-static-prod": "cd ./static && ng build --env=prod && ln -s ../api/resource/ ../public/resource",
|
||||||
"postinstall": "npm install --prefix ./static && npm install --prefix ./api",
|
"postinstall": "npm install --prefix ./static && npm install --prefix ./api",
|
||||||
"mongodb": "mongod --dbpath ./mongodb-data",
|
"mongodb": "mongod --dbpath ./mongodb-data",
|
||||||
"test": "npm test --prefix ./api"
|
"test": "npm test --prefix ./api"
|
||||||
|
|
Loading…
Reference in New Issue