From 03a939b6437f65f14e5cdca03edf74bc76a9a772 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Tue, 4 Feb 2020 16:05:08 -0700 Subject: [PATCH] Change what is passed to ShelfController --- server/controllers/shelf.js | 6 +++--- server/routes/shelf.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/controllers/shelf.js b/server/controllers/shelf.js index 41ee7af..3c623c7 100644 --- a/server/controllers/shelf.js +++ b/server/controllers/shelf.js @@ -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 = []) { diff --git a/server/routes/shelf.js b/server/routes/shelf.js index 084be7d..426c6d9 100644 --- a/server/routes/shelf.js +++ b/server/routes/shelf.js @@ -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) {