123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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();
|