Fix BooksController.createBookReference()
This commit is contained in:
parent
707c22dac7
commit
63c7d3676d
|
@ -105,10 +105,10 @@ class Inventaire {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const bookData = await json;
|
let bookData = await json;
|
||||||
|
|
||||||
if (typeof bookData.entities !== 'undefined' && typeof bookData.entities[uri] !== 'undefined') {
|
if (typeof bookData.entities !== 'undefined' && typeof bookData.entities[uri] !== 'undefined') {
|
||||||
const bookData = Inventaire.handleEntity(bookData.entities[uri], this.lang);
|
bookData = Inventaire.handleEntity(bookData.entities[uri], this.lang);
|
||||||
bookData['covers'] = await this.getCovers(bookData.uri);
|
bookData['covers'] = await this.getCovers(bookData.uri);
|
||||||
|
|
||||||
return bookData;
|
return bookData;
|
||||||
|
|
|
@ -98,20 +98,18 @@ class BooksController {
|
||||||
const inventaire = new Inventaire(this.language);
|
const inventaire = new Inventaire(this.language);
|
||||||
const bookData = await inventaire.getBookData(uri);
|
const bookData = await inventaire.getBookData(uri);
|
||||||
return await bookReferencesModel.create({
|
return await bookReferencesModel.create({
|
||||||
values: {
|
|
||||||
name: bookData.name,
|
name: bookData.name,
|
||||||
description: bookData.description,
|
description: bookData.description,
|
||||||
sources: {
|
sources: {
|
||||||
[source]: uri,
|
[source]: uri,
|
||||||
},
|
},
|
||||||
covers: bookData.covers.map(cover => {
|
covers: (bookData.covers ? bookData.covers : []).map(cover => {
|
||||||
return {
|
return {
|
||||||
sourceId: uri,
|
sourceId: uri,
|
||||||
url: cover.url,
|
url: cover.url,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
locale: this.language,
|
locale: this.language,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ async function routes(fastify, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const books = new BooksController(request.body.source, request.body.uri, request.language);
|
const books = new BooksController(request.body.source, request.body.uri, request.language);
|
||||||
const newBookReference = await books.createBookReference(request.body.source, request.body.uri);
|
const newBookReference = await books.createBookReference(fastify.models.BookReference, request.body.source, request.body.uri);
|
||||||
console.log('created new bookreference', newBookReference);
|
console.log('created new bookreference', newBookReference);
|
||||||
return newBookReference.id;
|
return newBookReference.id;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue