Skip to content

Commit

Permalink
fix(simpleCollections): add a key to array of data (BREAKING CHANGES)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed Jun 1, 2022
1 parent b9ad90a commit 9da254a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions api/controllers/v1/entrance/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ module.exports = async (req, res) => {
})
.intercept('rightNotFound', () =>
res.serverError(
'A server error occured when checking your right to have a limited view of a sensible entrance.'
'A server error occured when checking your right to have a limited view of a sensitive entrance.'
)
)
: false;
if (!hasLimitedViewRight && !hasCompleteViewRight) {
return res.forbidden(
'You are not authorized to view this sensible entrance.'
'You are not authorized to view this sensitive entrance.'
);
}
if (!hasCompleteViewRight) {
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/v1/file-format/find-all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = async (req, res) => {
try {
const fileFormats = await TFileFormat.find();
return res.ok(fileFormats);
return res.ok({ fileFormats });
} catch (err) {
return res.serverError(
'There was a problem while retrieving the file formats.'
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/v1/license/find-all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = async (req, res) => {
try {
const licenses = await TLicense.find();
return res.ok(licenses);
return res.ok({ licenses });
} catch (err) {
return res.serverError(
'There was a problem while retrieving the licenses.'
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/v1/option/find-all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = async (req, res) => {
try {
const options = await TOption.find();
return res.ok(options);
return res.ok({ options });
} catch (err) {
return res.serverError('There was a problem while retrieving the options.');
}
Expand Down
8 changes: 4 additions & 4 deletions api/services/MappingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ module.exports = {
source.forEach((item) =>
caves.push(module.exports.convertToCaveModel(item))
);
return caves;
return { caves };
},

/**
Expand Down Expand Up @@ -630,7 +630,7 @@ module.exports = {

// Networks (from DB)
if (source.networks) {
result.networks = module.exports.convertToCaveList(source.networks);
result.networks = module.exports.convertToCaveList(source.networks).caves;
}

// Nb caves & entrances (from ES)
Expand Down Expand Up @@ -687,7 +687,7 @@ module.exports = {
if (source.exploredNetworks instanceof Array) {
result.exploredNetworks = module.exports.convertToCaveList(
source.exploredNetworks
);
).caves;
}
if (source.documents instanceof Array) {
result.documents = module.exports.convertToDocumentList(
Expand All @@ -702,7 +702,7 @@ module.exports = {
if (source.partnerNetworks instanceof Array) {
result.partnerNetworks = module.exports.convertToCaveList(
source.partnerNetworks
);
).caves;
}

return result;
Expand Down
5 changes: 3 additions & 2 deletions test/integration/4_routes/Caves/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ describe('Cave features', () => {
.expect(200)
.end((err, res) => {
if (err) return done(err);
const { body: caves } = res;
sails.log(caves);
const {
body: { caves },
} = res;
caves.forEach((cave) => {
should(cave).have.properties(CAVE_PROPERTIES);
should(cave.name).not.be.empty();
Expand Down
4 changes: 3 additions & 1 deletion test/integration/4_routes/FileFormat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe('FileFormat features', () => {
.expect(200)
.end((err, res) => {
if (err) return done(err);
const { body: fileFormats } = res;
const {
body: { fileFormats },
} = res;
for (const fileFormat of fileFormats) {
should(fileFormat).have.properties(FILE_FORMAT_PROPERTIES);
should(fileFormat.id).not.be.undefined();
Expand Down
4 changes: 3 additions & 1 deletion test/integration/4_routes/License.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe('License features', () => {
.expect(200)
.end((err, res) => {
if (err) return done(err);
const { body: licenses } = res;
const {
body: { licenses },
} = res;
for (const license of licenses) {
should(license).have.properties(LICENSE_PROPERTIES);
should(license.id).not.be.undefined();
Expand Down
4 changes: 3 additions & 1 deletion test/integration/4_routes/Option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe('Option features', () => {
.expect(200)
.end((err, res) => {
if (err) return done(err);
const { body: options } = res;
const {
body: { options },
} = res;
for (const option of options) {
should(option).have.properties(OPTION_PROPERTIES);
should(option.id).not.be.undefined();
Expand Down

0 comments on commit 9da254a

Please sign in to comment.