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