1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const FilterService = require('./FilterService')
- const express = require('express');
- const RepositorySystem = require('../../systems/RepositorySystem');
- const RoutingSystem = require('../../systems/RoutingSystem');
- const knex = require('../../database/db');
- //1 Dont know if it will be Crud Extension
- //2
- class SearchModule {
- constructor(){
- //Missing Roles Options
- //Dont know it will extends Crud
- this.router = express.Router();
- this.table = 'products';
- this.init();
- }
- init() {
- let routes = [
- {
- type: 'custom',
- method: 'get',
- endpoint: '/',
- customFn: (req,res) => {
- this.searchFn(req,res)
- }
- }
- ];
- RoutingSystem.loadRoutes(routes, this.router, '/search');
- }
- searchFn(req,res) {
- console.log("here")
- var query = knex.table(this.table).select('*');
- if(req.body.length){
- query = FilterService.parseFilters(query, req.body);
- }
- // Missing lots of functionality
- res.send(200)
- }
- }
- module.exports = SearchModule;
|