const express = require('express'); const path = require('path'); const CrudModule = require('../../base/CrudModule'); const RepositorySystem = require('../../systems/RepositorySystem'); const RoutingSystem = require('../../systems/RoutingSystem'); let Global = { fields: [ { key: "name", type: "text" }, { key:"value", type: "text" } ] }; class CustomModule extends CrudModule { constructor(){ super('/globals', [3,0,3,4,0], 'Globals'); this.repository = RepositorySystem.create('Globals', Global); this.setRepo(this.repository); // this.users = RepositorySystem.create('Users'); // You can get any repo you want!! this.router = express.Router(); this.init(); } init() { let routes = [ { type: 'custom', method: 'get', endpoint: '/select/:name', customFn: this.selectGlobal.bind(this) } ]; RoutingSystem.loadRoutes(routes, this.router, '/globals'); } selectGlobal(req, res) { let name = req.params.name; this.repository.get('name', name) .then((item) => res.send(item)); } } module.exports = {};//new CustomModule();