fleet/website/api/controllers/admin/view-query-generator.js
Eric 4ad16cc46f
Website: Update admin query generator to work in production. (#25363)
Changes:
- Updated the `build-static-content` script to add the merged osquery
schema JSON to the website's `builtStaticContent` configuration
- Updated view-query-generator to have a badConfig exit that is used if
the website has an invalid `builtStaticContent.schemaTables`
configuration
- Updated `get-llm-generated-sql` to use the
`builtStaticContent.schemaTables` instead of attempting to use
`sails.helpers.getExtendedOsquerySchema()` (Which does not work as
intended when run in a production environment.)
2025-01-10 17:51:03 -06:00

29 lines
515 B
JavaScript
Vendored

module.exports = {
friendlyName: 'View query generator',
description: 'Display "Query generator" page.',
exits: {
success: {
viewTemplatePath: 'pages/admin/query-generator'
},
badConfig: { responseType: 'badConfig' },
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.schemaTables)) {
throw {badConfig: 'builtStaticContent.schemaTables'};
}
// Respond with view.
return {};
}
};