const shared_consts = require('../tools/shared_nodejs');

const express = require('express');
const router = express.Router();

const tools = require('../tools/general');

var server_constants = require('../tools/server_constants');

var { authenticate, authenticate_noerror, auth_default } = require('../middleware/authenticate');

var mongoose = require('mongoose').set('debug', false);
const Subscription = require('../models/subscribers');

const _ = require('lodash');
const { QueryAI } = require('../models/queryai');
var { User } = require('../models/user');
const { Reaction } = require('../models/reaction');

const globalTables = require('../tools/globalTables');

const { ObjectID } = require('mongodb');


router.post('/getlist', authenticate_noerror, async function (req, res, next) {


  try {
    let idapp = req.body.idapp;

    let queryAIList = await QueryAI.findAllIdApp(idapp);

    return res.send({
      code: server_constants.RIS_CODE_OK,
      queryAIList
    });

  } catch (e) {
    console.error('/getlist', e);
  }

  return null;

});

module.exports = router;
