Skip to content

Commit 7c65fe1

Browse files
authored
(feat): add description to postNewBox route (#822)
1 parent 54fb294 commit 7c65fe1

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

packages/api/lib/controllers/boxesController.js

+38-39
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ const getBox = async function getBox (req, res) {
478478
* measurements in. The accepted formats are listed under `Measurements/Post mutliple new Measurements`
479479
*
480480
* @apiParam (RequestBody) {String} name the name of this senseBox.
481+
* @apiParam (RequestBody) {String} [description] detailed description of this senseBox.
481482
* @apiParam (RequestBody) {String} [grouptag] the grouptag of this senseBox.
482483
* @apiParam (RequestBody) {String="indoor","outdoor","mobile","unknown"} exposure the exposure of this senseBox.
483484
* @apiParam (RequestBody) {Location} location the coordinates of this senseBox.
@@ -713,80 +714,80 @@ module.exports = {
713714
checkContentType,
714715
retrieveParameters([
715716
{ predef: 'boxId', required: true },
716-
{ predef: 'password' },
717+
{ predef: 'password' }
717718
]),
718719
checkPrivilege,
719-
deleteBox,
720+
deleteBox
720721
],
721722
getTransfer: [
722723
retrieveParameters([{ predef: 'boxId', required: true }]),
723724
checkPrivilege,
724-
getTransfer,
725+
getTransfer
725726
],
726727
createTransfer: [
727728
retrieveParameters([
728729
{ predef: 'boxId', required: true },
729-
{ predef: 'dateNoDefault' },
730+
{ predef: 'dateNoDefault' }
730731
]),
731732
validateDateNotPast,
732733
checkPrivilege,
733-
createTransfer,
734+
createTransfer
734735
],
735736
updateTransfer: [
736737
retrieveParameters([
737738
{ predef: 'boxId', required: true },
738739
{ name: 'token', dataType: 'String' },
739-
{ predef: 'dateNoDefault', required: true },
740+
{ predef: 'dateNoDefault', required: true }
740741
]),
741742
validateDateNotPast,
742743
checkPrivilege,
743-
updateTransfer,
744+
updateTransfer
744745
],
745746
removeTransfer: [
746747
retrieveParameters([
747748
{ predef: 'boxId', required: true },
748-
{ name: 'token', dataType: 'String' },
749+
{ name: 'token', dataType: 'String' }
749750
]),
750751
checkPrivilege,
751-
removeTransfer,
752+
removeTransfer
752753
],
753754
claimBox: [
754755
checkContentType,
755756
retrieveParameters([{ name: 'token', dataType: 'String' }]),
756-
claimBox,
757+
claimBox
757758
],
758759
getSketch: [
759760
retrieveParameters([
760761
{ predef: 'boxId', required: true },
761762
{
762763
name: 'serialPort',
763764
dataType: 'String',
764-
allowedValues: ['Serial1', 'Serial2'],
765+
allowedValues: ['Serial1', 'Serial2']
765766
},
766767
{
767768
name: 'soilDigitalPort',
768769
dataType: 'String',
769-
allowedValues: ['A', 'B', 'C'],
770+
allowedValues: ['A', 'B', 'C']
770771
},
771772
{
772773
name: 'soundMeterPort',
773774
dataType: 'String',
774-
allowedValues: ['A', 'B', 'C'],
775+
allowedValues: ['A', 'B', 'C']
775776
},
776777
{
777778
name: 'windSpeedPort',
778779
dataType: 'String',
779-
allowedValues: ['A', 'B', 'C'],
780+
allowedValues: ['A', 'B', 'C']
780781
},
781782
{ name: 'ssid', dataType: 'StringWithEmpty' },
782783
{ name: 'password', dataType: 'StringWithEmpty' },
783784
{ name: 'devEUI', dataType: 'StringWithEmpty' },
784785
{ name: 'appEUI', dataType: 'StringWithEmpty' },
785786
{ name: 'appKey', dataType: 'StringWithEmpty' },
786-
{ name: 'display_enabled', allowedValues: ['true', 'false'] },
787+
{ name: 'display_enabled', allowedValues: ['true', 'false'] }
787788
]),
788789
checkPrivilege,
789-
getSketch,
790+
getSketch
790791
],
791792
updateBox: [
792793
checkContentType,
@@ -804,10 +805,10 @@ module.exports = {
804805
{ name: 'addons', dataType: 'object' },
805806
{ predef: 'location' },
806807
{ name: 'useAuth', allowedValues: ['true', 'false'] },
807-
{ name: 'generate_access_token', allowedValues: ['true', 'false'] },
808+
{ name: 'generate_access_token', allowedValues: ['true', 'false'] }
808809
]),
809810
checkPrivilege,
810-
updateBox,
811+
updateBox
811812
],
812813
// no auth required
813814
getBoxLocations: [
@@ -816,18 +817,19 @@ module.exports = {
816817
{
817818
name: 'format',
818819
defaultValue: 'json',
819-
allowedValues: ['json', 'geojson'],
820+
allowedValues: ['json', 'geojson']
820821
},
821822
{ predef: 'toDate' },
822823
{ predef: 'fromDate' },
823-
validateFromToTimeParams,
824+
validateFromToTimeParams
824825
]),
825-
getBoxLocations,
826+
getBoxLocations
826827
],
827828
postNewBox: [
828829
checkContentType,
829830
retrieveParameters([
830831
{ name: 'name', required: true },
832+
{ name: 'description', dataType: 'StringWithEmpty' },
831833
{ name: 'grouptag', dataType: ['String'], aliases: ['tag'] },
832834
{ name: 'exposure', allowedValues: Box.BOX_VALID_EXPOSURES },
833835
{ name: 'model', allowedValues: Box.BOX_VALID_MODELS },
@@ -848,50 +850,50 @@ module.exports = {
848850
'scd30',
849851
'dps310',
850852
'sps30'
851-
],
853+
]
852854
},
853855
{
854856
name: 'serialPort',
855857
dataType: 'String',
856858
defaultValue: 'Serial1',
857-
allowedValues: ['Serial1', 'Serial2'],
859+
allowedValues: ['Serial1', 'Serial2']
858860
},
859861
{
860862
name: 'soilDigitalPort',
861863
dataType: 'String',
862864
defaultValue: 'A',
863-
allowedValues: ['A', 'B', 'C'],
865+
allowedValues: ['A', 'B', 'C']
864866
},
865867
{
866868
name: 'soundMeterPort',
867869
dataType: 'String',
868870
defaultValue: 'B',
869-
allowedValues: ['A', 'B', 'C'],
871+
allowedValues: ['A', 'B', 'C']
870872
},
871873
{
872874
name: 'windSpeedPort',
873875
dataType: 'String',
874876
defaultValue: 'C',
875-
allowedValues: ['A', 'B', 'C'],
877+
allowedValues: ['A', 'B', 'C']
876878
},
877879
{ name: 'mqtt', dataType: 'object' },
878880
{ name: 'ttn', dataType: 'object' },
879881
{ name: 'useAuth', allowedValues: ['true', 'false'] },
880882
{ predef: 'location', required: true },
881883
{ name: 'sharedBox', allowedValues: ['true', 'false'] }
882884
]),
883-
postNewBox,
885+
postNewBox
884886
],
885887
getBox: [
886888
retrieveParameters([
887889
{ predef: 'boxId', required: true },
888890
{
889891
name: 'format',
890892
defaultValue: 'json',
891-
allowedValues: ['json', 'geojson'],
892-
},
893+
allowedValues: ['json', 'geojson']
894+
}
893895
]),
894-
getBox,
896+
getBox
895897
],
896898
getBoxes: [
897899
retrieveParameters([
@@ -900,7 +902,7 @@ module.exports = {
900902
{
901903
name: 'exposure',
902904
allowedValues: Box.BOX_VALID_EXPOSURES,
903-
dataType: ['String'],
905+
dataType: ['String']
904906
},
905907
{ name: 'model', dataType: ['StringWithEmpty'] },
906908
{ name: 'grouptag', dataType: ['StringWithEmpty'] },
@@ -909,29 +911,26 @@ module.exports = {
909911
{
910912
name: 'format',
911913
defaultValue: 'json',
912-
allowedValues: ['json', 'geojson'],
914+
allowedValues: ['json', 'geojson']
913915
},
914916
{
915917
name: 'classify',
916918
defaultValue: 'false',
917-
allowedValues: ['true', 'false'],
919+
allowedValues: ['true', 'false']
918920
},
919921
{
920922
name: 'minimal',
921923
defaultValue: 'false',
922-
allowedValues: ['true', 'false'],
924+
allowedValues: ['true', 'false']
923925
},
924926
{ name: 'full', defaultValue: 'false', allowedValues: ['true', 'false'] },
925927
{ predef: 'near' },
926928
{ name: 'maxDistance' },
927-
{ predef: 'bbox' },
929+
{ predef: 'bbox' }
928930
]),
929931
parseAndValidateTimeParamsForFindAllBoxes,
930932
addCache('5 minutes', 'getBoxes'),
931933
getBoxes
932934
],
933-
getAllTags: [
934-
addCache('5 minutes', 'getAllTags'),
935-
getAllTags
936-
]
935+
getAllTags: [addCache('5 minutes', 'getAllTags'), getAllTags]
937936
};

packages/models/src/box/box.js

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ boxSchema.post('save', function boxPostSave (savedBox) {
220220
// initializes and saves new box document
221221
boxSchema.statics.initNew = function ({
222222
name,
223+
description,
223224
location,
224225
grouptag,
225226
exposure,
@@ -279,6 +280,7 @@ boxSchema.statics.initNew = function ({
279280
// create box document and persist in database
280281
return this.create({
281282
name,
283+
description,
282284
currentLocation: boxLocation,
283285
locations: [boxLocation],
284286
grouptag,

0 commit comments

Comments
 (0)