Compare commits
No commits in common. "85b97c771fb58cbbd4a390c49edbc9bf33ef93e5" and "85be1ff3c962707ff27ef404ed3bee508877813b" have entirely different histories.
85b97c771f
...
85be1ff3c9
|
@ -3,15 +3,15 @@
|
|||
List all awardings
|
||||
|
||||
+ Parameters
|
||||
+ userId: `5ab68d42f547ed304064e5f7` (string, optional)
|
||||
+ userId (string, optional)
|
||||
specific army member Id to show the awardings for
|
||||
|
||||
+ inProgress: false (boolean, optional)
|
||||
+ inProgress (boolean, optional)
|
||||
true to filter by awarding state 'in progress'
|
||||
|
||||
+ Default: false
|
||||
|
||||
+ fractFilter: `BLUFOR` (enum[string], optional)
|
||||
+ fractFilter (enum[string], optional)
|
||||
Field to filter by fraction
|
||||
|
||||
+ Members
|
||||
|
@ -22,4 +22,4 @@ List all awardings
|
|||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (array[Awarding], fixed-type)
|
||||
+ Attributes (array[Awarding])
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
List all decorations
|
||||
|
||||
+ Parameters
|
||||
+ q: `tapferkeit` (string, optional)
|
||||
+ q (string, optional)
|
||||
Filter string for the partial decoration name
|
||||
|
||||
+ fractFilter: `BLUFOR` (enum[string], optional)
|
||||
+ fractFilter (enum[string], optional)
|
||||
Field to filter by fraction
|
||||
|
||||
+ Members
|
||||
|
@ -16,16 +16,4 @@ List all decorations
|
|||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (array[Decoration], fixed-type)
|
||||
|
||||
|
||||
### GET Decoration [GET /decorations/{id}]
|
||||
|
||||
Retrieve single decoration data
|
||||
|
||||
+ Parameters
|
||||
+ id: `5abd3dff6e6a0334d95b8ba0` (string, required) - unique id of the decoration to fetch
|
||||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (Decoration, fixed-type)
|
||||
+ Attributes (array[Decoration])
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
List all promotion requests
|
||||
|
||||
+ Parameters
|
||||
+ squadId: `591470249e9fae286e008e31` (string, optional)
|
||||
+ squadId (string, optional)
|
||||
specific squad Id to show the promotion requests for
|
||||
|
||||
+ inProgress: false (boolean, optional)
|
||||
+ inProgress (boolean, optional)
|
||||
true to filter by promotion state 'in progress'
|
||||
|
||||
+ Default: false
|
||||
|
||||
+ fractFilter: `BLUFOR` (enum[string], optional)
|
||||
+ fractFilter (enum[string], optional)
|
||||
Field to filter by fraction
|
||||
|
||||
+ Members
|
||||
|
|
|
@ -5,7 +5,7 @@ List all ranks
|
|||
+ Parameters
|
||||
+ q: `Gefr` (string, optional) - filter string which filters for partial rank name
|
||||
|
||||
+ fractFilter: `BLUFOR` (enum[string], optional)
|
||||
+ fractFilter (enum[string], optional)
|
||||
Field to filter by fraction
|
||||
|
||||
+ Members
|
||||
|
@ -15,16 +15,4 @@ List all ranks
|
|||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (array[Rank], fixed-type)
|
||||
|
||||
|
||||
### GET Rank [GET /ranks/{id}]
|
||||
|
||||
Retrieve single rank data
|
||||
|
||||
+ Parameters
|
||||
+ id: `5aba5504eadcce6332c6a775` (string, required) - unique id of the rank to fetch
|
||||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (Rank, fixed-type)
|
||||
+ Attributes (array[Rank])
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
### Get Users [GET /users{?q,fractFilter,limit,offset}]
|
||||
### GET Users [GET /users{?q,fractFilter,limit,offset}]
|
||||
|
||||
Get single army member information
|
||||
|
||||
+ Parameters
|
||||
+ q: `hardi` (string, optional) - filter string which filters for partial username
|
||||
|
||||
+ fractFilter: `BLUFOR` (enum[string], optional)
|
||||
+ fractFilter (enum[string], optional)
|
||||
Field to filter by fraction
|
||||
|
||||
+ Members
|
||||
|
@ -18,7 +18,7 @@ Get single army member information
|
|||
|
||||
+ Default: Infinity
|
||||
|
||||
+ offset: 0 (number, optional)
|
||||
+ offset (number, optional)
|
||||
Offset into result-set (useful for pagination)
|
||||
|
||||
+ Default: 0
|
||||
|
@ -32,7 +32,7 @@ Get single army member information
|
|||
+ Attributes (array[User], fixed-type)
|
||||
|
||||
|
||||
### Get User [GET /users/{id}]
|
||||
### GET User [GET /users/{id}]
|
||||
|
||||
Get single army member information
|
||||
|
||||
|
@ -42,46 +42,3 @@ Get single army member information
|
|||
+ Response 200
|
||||
|
||||
+ Attributes (User, fixed-type)
|
||||
|
||||
|
||||
### Create User [POST /users]
|
||||
|
||||
Create a new army member
|
||||
|
||||
+ Request Create new army member (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ username: `[GNC]Paolo` (string, required) - display name of the user
|
||||
|
||||
+ Response 201
|
||||
|
||||
+ Attributes (User, fixed-type)
|
||||
|
||||
### Update User [PUT /users/{id}]
|
||||
|
||||
Update an army member, identified by its id
|
||||
|
||||
+ Parameters
|
||||
+ id: `5abd4780396bc0487068be0e` (string, required) - unique id of army-member
|
||||
|
||||
+ Request Create Entry with Title (application/json)
|
||||
|
||||
+ Attributes
|
||||
+ _id: `5abd4780396bc0487068be0e` (string, required) - unique id of army-member
|
||||
+ username: `Paolo` (string, optional) - display name of the user
|
||||
+ rankLvl: 22 (number, optional) - rank level representing the rank
|
||||
+ squadId: `591470249e9fae286e008e31` (string, optional) - squadId of squad which army member is part of
|
||||
|
||||
+ Response 200
|
||||
|
||||
+ Attributes (User, fixed-type)
|
||||
|
||||
|
||||
### Delete User [DELETE /users/{id}]
|
||||
|
||||
Delete an army member
|
||||
|
||||
+ Parameters
|
||||
+ id: `5abd4780396bc0487068be0e` (string, required) - unique id of army-member
|
||||
|
||||
+ Response 204
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
The running express server instance saves entity related files like squad logos and statistic logs on the file system.
|
||||
In the original MEAN application they are served in the `/resource` path of the application server.
|
||||
In the original mean application they are served in the `/resource` path of the application server.
|
||||
|
||||
The following examples show where those files are located, to be accessed on the cloud instance.
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# Squad (object)
|
||||
|
||||
A Squad entity
|
||||
Default API Squad entity
|
||||
|
||||
## Properties
|
||||
|
||||
+ _id: `591470249e9fae286e008e31` (string, required) - the unique id of the squad
|
||||
+ sortingNumber: 30 (number, required) - the number for orders in lists of squads
|
||||
+ updatedAt: `2017-05-31T20:43:07.165Z` (string, required) - version timestamp
|
||||
+ timestamp: `2017-05-11T14:07:32.471Z` (string, required) - creation timestamp
|
||||
+ name: `Alpha` (string, required) - display name of the squad
|
||||
+ fraction: `BLUFOR` (string, required) - fraction the squad is part of
|
||||
+ __v: 2 (number, required) - version number
|
||||
+ _id: `591470249e9fae286e008e31` (string, required)
|
||||
+ sortingNumber: 30 (number, required)
|
||||
+ updatedAt: `2017-05-31T20:43:07.165Z` (string, required)
|
||||
+ timestamp: `2017-05-11T14:07:32.471Z` (string, required)
|
||||
+ name: `Alpha` (string, required)
|
||||
+ fraction: `BLUFOR` (string, required)
|
||||
+ __v: 2 (number, required)
|
||||
|
|
|
@ -20,7 +20,7 @@ FORMAT: 1A
|
|||
|
||||
:[Gists](auth/login.apib)
|
||||
|
||||
# Group Account
|
||||
<!-- Group Account -->
|
||||
|
||||
# Group Army Overview
|
||||
|
||||
|
@ -30,15 +30,15 @@ FORMAT: 1A
|
|||
|
||||
:[Gists](army-management/awardings.apib)
|
||||
|
||||
# Group Campaigns
|
||||
<!-- Group Campaigns -->
|
||||
|
||||
# Group Decorations
|
||||
|
||||
:[Gists](army-management/decorations.apib)
|
||||
|
||||
# Group Logs
|
||||
<!-- Group Logs -->
|
||||
|
||||
# Group Players
|
||||
<!-- Group Players -->
|
||||
|
||||
# Group Ranks
|
||||
|
||||
|
@ -48,10 +48,10 @@ FORMAT: 1A
|
|||
|
||||
:[Gists](army-management/promotions.apib)
|
||||
|
||||
# Group Squads
|
||||
<!-- Group Squads -->
|
||||
|
||||
# Group Users
|
||||
|
||||
:[Gists](army-management/users.apib)
|
||||
|
||||
# Group Wars
|
||||
<!-- Group Wars -->
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"_id":{"$oid":"5ab68ceef547ed304064e5f6"},"squad":null,"permission":4,"activated":true,"username":"testuser","secret":"my secret","password":"$2a$10$wvgBbcckHrFu8Ctw8hSPNuFLoBy4sRubioyiK1NabOC0UgYD.KITi","timestamp":{"$date":"2018-03-24T17:37:50.668Z"},"updatedAt":{"$date":"2018-03-24T17:37:50.668Z"},"__v":0}
|
||||
{"_id":{"$oid":"5ab68ceef547ed304064e5f6"},"squad":null,"permission":3,"activated":true,"username":"testuser","secret":"my secret","password":"$2a$10$wvgBbcckHrFu8Ctw8hSPNuFLoBy4sRubioyiK1NabOC0UgYD.KITi","timestamp":{"$date":"2018-03-24T17:37:50.668Z"},"updatedAt":{"$date":"2018-03-24T17:37:50.668Z"},"__v":0}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"_id":{"$oid":"5abd3dff6e6a0334d95b8ba0"},"sortingNumber":0,"name":"Orden der Tapferkeit","fraction":"BLUFOR","isMedal":true,"description":"Das ist ein Orden den tapfere Leute bekommen","timestamp":{"$date":"2018-03-29T19:26:55.387Z"},"updatedAt":{"$date":"2018-03-29T19:26:55.387Z"},"__v":0}
|
|
@ -1,2 +1 @@
|
|||
{"_id":{"$oid":"5ab68d42f547ed304064e5f7"},"rankLvl":0,"squadId":{"$oid":"5aba54eaeadcce6332c6a774"},"username":"hardiready","updatedAt":{"$date":"2018-03-27T14:28:04.533Z"},"__v":0}
|
||||
{"_id":{"$oid":"5abd4780396bc0487068be0e"},"rankLvl":0,"squadId":null,"username":"KalleK","timestamp":{"$date":"2018-03-29T20:07:28.960Z"},"updatedAt":{"$date":"2018-03-29T20:07:28.960Z"},"__v":0}
|
||||
|
|
|
@ -10,7 +10,7 @@ names: false
|
|||
only: []
|
||||
reporter: base
|
||||
output: []
|
||||
header: ['X-Access-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWI2OGNlZWY1NDdlZDMwNDA2NGU1ZjYiLCJpYXQiOjE1MjIzNTMwNzAsImV4cCI6MTAyMzIyMzUzMDcwfQ.aC4TYkPc8gYcpdsYNnYcs8D8e6OPilrgSGZF6pI3g1w']
|
||||
header: []
|
||||
sorted: false
|
||||
user: null
|
||||
inline-errors: false
|
||||
|
|
|
@ -46,7 +46,7 @@ let authCheck = (username, password, res) => {
|
|||
AppUserModel.findOne({username: username.toLowerCase()}).populate('squad').exec((err, user) => {
|
||||
if (err) deferred.reject(err.name + ': ' + err.message);
|
||||
|
||||
const diff = 28 * 60 * 1000*1000; // time till expiration [minutes]
|
||||
const diff = 28 * 60 * 24; // time till expiration [minutes]
|
||||
|
||||
if (user && !user.activated) {
|
||||
res.status(codes.unauthorized).send('Account is not yet activated');
|
||||
|
|
|
@ -103,12 +103,52 @@ users.route('/:id')
|
|||
});
|
||||
})
|
||||
|
||||
.patch(apiAuthenticationMiddleware, checkHl, (req, res, next) => {
|
||||
if (!req.body || (req.body._id && req.body._id !== req.params.id)) {
|
||||
// little bit different as in PUT. :id does not need to be in data, but if the _id and url id must match
|
||||
const err =
|
||||
new Error('id of PATCH resource and send JSON body are not equal ' + req.params.id + ' ' + req.body._id);
|
||||
err.status = codes.notfound;
|
||||
next(err);
|
||||
return; // prevent node to process this function further after next() has finished.
|
||||
}
|
||||
|
||||
// optional task 3: increment version manually as we do not use .save(.)
|
||||
req.body.updatedAt = new Date();
|
||||
req.body.$inc = {__v: 1};
|
||||
|
||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||
// reset attributes that are missing.
|
||||
UserModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||
if (err) {
|
||||
err.status = codes.wrongrequest;
|
||||
} else if (!item) {
|
||||
err = new Error('item not found');
|
||||
err.status = codes.notfound;
|
||||
}
|
||||
UserModel.populate(item, {path: 'squadId'}, (err, extUser) => {
|
||||
if (err) {
|
||||
err.status = codes.servererror;
|
||||
return next(err);
|
||||
}
|
||||
if (!user) {
|
||||
res.locals.items = {};
|
||||
res.locals.processed = true;
|
||||
return next();
|
||||
}
|
||||
res.locals.items = extUser;
|
||||
res.locals.processed = true;
|
||||
return next();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
.put(apiAuthenticationMiddleware, checkHl, (req, res, next) => {
|
||||
// first check that the given element id is the same as the URL id
|
||||
if (!req.body || req.body._id !== req.params.id) {
|
||||
// the URL does not fit the given element
|
||||
let err =
|
||||
new Error('id of PUT resource and send JSON body are not equal ' + req.params.id + ' ' + req.body._id);
|
||||
new Error('id of PATCH resource and send JSON body are not equal ' + req.params.id + ' ' + req.body._id);
|
||||
err.status = codes.notfound;
|
||||
next(err);
|
||||
return; // prevent node to process this function further after next() has finished.
|
||||
|
@ -116,8 +156,8 @@ users.route('/:id')
|
|||
// main difference of PUT and PATCH is that PUT expects all data in request: checked by using the schema
|
||||
const user = new UserModel(req.body);
|
||||
UserModel.findById(req.params.id, req.body, {new: true}, (err, item) => {
|
||||
// with parameter {new: true} the TweetNModel will return the new and changed object
|
||||
// from the DB and not the old one.
|
||||
// with parameter {new: true} the TweetNModel will return the new and changed object from the DB and not the
|
||||
// old one.
|
||||
if (err) {
|
||||
err.status = codes.wrongrequest;
|
||||
return next(err);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<code_scheme name="OPT-CC" version="173">
|
||||
<option name="FORMATTER_TAGS_ENABLED" value="true" />
|
||||
<code_scheme name="Default" version="173">
|
||||
<JSCodeStyleSettings>
|
||||
<option name="USE_CHAINED_CALLS_GROUP_INDENTS" value="true" />
|
||||
</JSCodeStyleSettings>
|
||||
|
@ -10,15 +9,11 @@
|
|||
<option name="RIGHT_MARGIN" value="120" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_WRAP" value="1" />
|
||||
<option name="WRAP_COMMENTS" value="true" />
|
||||
<option name="WRAP_ON_TYPING" value="1" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="WRAP_COMMENTS" value="true" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</code_scheme>
|
Loading…
Reference in New Issue