Change what is passed to ShelfController
This commit is contained in:
parent
abbc8b5591
commit
03a939b643
|
@ -1,9 +1,9 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
class ShelfController {
|
||||
constructor (shelfModel, shelfItemModel) {
|
||||
this.model = shelfModel;
|
||||
this.itemModel = shelfItemModel;
|
||||
constructor (sequelizeModels) {
|
||||
this.model = sequelizeModels.Shelf;
|
||||
this.itemModel = sequelizeModels.ShelfItem;
|
||||
}
|
||||
|
||||
static newShelfNameIsValid (name, existingNames = []) {
|
||||
|
|
|
@ -15,7 +15,7 @@ async function routes(fastify, options) {
|
|||
});
|
||||
}
|
||||
|
||||
const shelfController = new ShelfController(fastify.models.Shelf, fastify.models.ShelfItem);
|
||||
const shelfController = new ShelfController(fastify.models);
|
||||
|
||||
const shelves = await request.user.getShelves({
|
||||
attributes: ['id', 'name', 'isDeletable', 'isPublic', 'updatedAt'],
|
||||
|
@ -45,7 +45,7 @@ async function routes(fastify, options) {
|
|||
return ShelfController.CheckExternalDomainForShelf(request.params.domain.trim(), request.params.shelfId);
|
||||
}
|
||||
|
||||
const shelfController = new ShelfController(fastify.models.Shelf, fastify.models.ShelfItem);
|
||||
const shelfController = new ShelfController(fastify.models);
|
||||
|
||||
const shelf = await shelfController.getShelfById(request.params.shelfId);
|
||||
if (typeof shelf.error !== 'undefined') {
|
||||
|
@ -88,7 +88,7 @@ async function routes(fastify, options) {
|
|||
return reply.code(400).send(shelfNameIsValid);
|
||||
}
|
||||
|
||||
const shelfController = new ShelfController(fastify.models.Shelf, fastify.models.ShelfItem);
|
||||
const shelfController = new ShelfController(fastify.models);
|
||||
|
||||
const newShelf = shelfController.createShelf(request.user, request.body.shelfName);
|
||||
if (typeof newShelf.error !== 'undefined' && newShelf.error !== false) {
|
||||
|
@ -136,7 +136,7 @@ async function routes(fastify, options) {
|
|||
return reply.code(400).send(shelfNameIsValid);
|
||||
}
|
||||
|
||||
const shelfController = new ShelfController(fastify.models.Shelf, fastify.models.ShelfItem);
|
||||
const shelfController = new ShelfController(fastify.models);
|
||||
|
||||
const newShelf = shelfController.renameShelf(request.user, request.body.shelfId, request.body.shelfName);
|
||||
if (typeof newShelf.error !== 'undefined' && newShelf.error !== false) {
|
||||
|
|
Loading…
Reference in New Issue