BoosterService.js 516 B

1234567891011121314151617181920212223
  1. let BoostersRepository = require('../../database').Repositories.Boosters;
  2. var Booster = require('./Booster');
  3. class BoosterService {
  4. constructor() {
  5. }
  6. getUserBoosters(user) {
  7. return BoostersRepository.getBoostersByUser(user);
  8. }
  9. givePack(user) {
  10. let {id, ...boosterdata} = new Booster(user);
  11. return BoostersRepository.insert(id, boosterdata);
  12. }
  13. }
  14. let service = null;
  15. function getSingleton() {
  16. return service = (service === null ? new BoosterService() : service);
  17. }
  18. module.exports = getSingleton();