UNPKG

awake-heroku

Version:

A package help your heroku app is always runs

41 lines (40 loc) 984 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class DataService { constructor() { this.apps = []; } add(url) { if (!url) { return; } const foundApp = this.apps.find((a) => a.url === url); if (foundApp) { return; } this.apps.push({ id: this.apps.length, url, lastHeartBeat: Date.now(), }); } remove(id) { this.apps = this.apps.filter((app) => app.id !== id); } update(app) { this.apps = this.apps.map((a) => { if (app.id === a.id) { a.url = app.url; a.lastHeartBeat = app.lastHeartBeat; } return a; }); } get(id) { return this.apps.find((app) => app.id === id); } getAll() { return this.apps; } } exports.default = new DataService();