Skip to content

Commit

Permalink
feat(albums): remove useless properties from album schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jun 9, 2016
1 parent 52e4f58 commit 9831f96
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 58 deletions.
31 changes: 27 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,34 @@ app.get('/v1/albums', (req, res, next) => {
return next(new HttpError('Fotoweb API returned no data', 502));
}

body.data = body.data.map(album => {
album.id = album.data.split('/')[4];
album.photosUrl = `${req.fullUrl}/v1/albums/${album.id}/photos`;
body.data = body.data.map(({
name,
data,
description,
type,
created,
modified,
deleted,
archived,
posterImages: posterImagesOrg,
color,
}) => {
const id = data.split('/')[4];
const photosUrl = `${req.fullUrl}/v1/albums/${id}/photos`;

return album;
return {
id,
name,
description,
type,
created,
modified,
deleted,
archived,
photosUrl,
posterImages: posterImagesOrg,
color,
};
});

/* Rewrite Fotoweb API paging URLs to API wrapper URLs */
Expand Down
55 changes: 1 addition & 54 deletions test/integration/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,72 +70,19 @@ describe('server', () => {
id: Joi.string().regex(/^[\d]+\.[\w-]+$/),
name: Joi.string(),
description: Joi.string().allow(''),
photosUrl: Joi.string().regex(/\/v1\/albums\/[^\/]+\/photos$/),
href: Joi.string(),
data: Joi.string(),
type: Joi.string().valid('archive'),
created: Joi.date().iso(),
modified: Joi.date().iso(),
deleted: Joi.date().iso().allow(null),
archived: Joi.date().iso().allow(null),
metadataEditor: Joi.object().keys({
name: Joi.string(),
href: Joi.string(),
}),
searchURL: Joi.string(),
originalURL: Joi.string().allow(''),
searchString: Joi.string().allow(''),
taxonomies: Joi.array().items(Joi.object().keys({
field: Joi.number().integer(),
value: Joi.string(),
label: Joi.string(),
description: Joi.string().allow(''),
href: Joi.string(),
langAlts: Joi.array(),
hasChildren: Joi.boolean(),
acl: Joi.string().allow(null),
detailsHref: Joi.string(),
taxonomyHref: Joi.string(),
taxonomyTitle: Joi.string(),
synonyms: Joi.array(),
sameAs: Joi.array(),
linkedFields: Joi.array(),
items: Joi.array(),
broaderTerms: Joi.array(),
})),
canHaveChildren: Joi.boolean(),
isSearchable: Joi.boolean(),
isSelectable: Joi.boolean(),
isLinkCollection: Joi.boolean(),
hasChildren: Joi.boolean(),
canCopyTo: Joi.boolean(),
canMoveTo: Joi.boolean(),
canUploadTo: Joi.boolean(),
canCreateFolders: Joi.boolean(),
canIngestToChildren: Joi.boolean(),
canBeDeleted: Joi.boolean(),
canBeArchived: Joi.boolean(),
canCreateAlerts: Joi.boolean(),
isFolderNavigationEnabled: Joi.boolean(),
canSelect: Joi.boolean(),
permissions: Joi.array().items(Joi.string()),
photosUrl: Joi.string().regex(/\/v1\/albums\/[^\/]+\/photos$/),
posterImages: Joi.array().items(Joi.object().keys({
size: Joi.number().integer(),
width: Joi.number().integer(),
height: Joi.number().integer(),
href: Joi.string(),
square: Joi.boolean(),
})),
posterAsset: Joi.string().allow(null),
props: Joi.object().keys({
owner: Joi.string().allow(null),
shares: Joi.object(),
comments: Joi.object(),
facebookComments: Joi.boolean(),
annotations: Joi.object(),
tags: Joi.array(),
}),
iconCharacter: Joi.string(),
color: Joi.string(),
})),
paging: Joi.object().allow(null),
Expand Down

0 comments on commit 9831f96

Please sign in to comment.