OrderHookup.js 673 B

123456789101112131415161718192021222324252627
  1. const express = require('express');
  2. const path = require('path');
  3. const Actions = require('../../systems/ActionSystem');
  4. const OneToOne = require('../../base/OneToOne');
  5. // USELESS
  6. class AddressOrderHookup extends OneToOne {
  7. constructor(){
  8. super('/addresses', [1,1,1,1,3], 'Addresses', 'Orders', '', undefined);
  9. Actions.on("verifyOrder" , this.verify.bind(this));
  10. }
  11. verify(order) {
  12. if (!order["Addresses_id"])
  13. throw "No address id";
  14. let id = order["Addresses_id"];
  15. return this.repository.get('id', id)
  16. .then((res) => {
  17. if(res.length) {
  18. return order;
  19. }
  20. throw 'No such address with id: ' + id;
  21. });
  22. }
  23. }
  24. module.exports = AddressOrderHookup;