mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
ac220ba6e5
* trivial * Simplify build-static-content script and rip out the old markdown compilation for query library * improve error msg * trivial * move helper * bring in the skeleton * Compile handbook as well, and bring more stuff inline * instead of generating sitemap.xml file, could just serve it as a route * Serve sitemap.xml on the fly * add failsafe to prevent search engine accidents * add remaining hand-coded pages to sitemap * rearrange routes and get rid of commented-out ones * Update build-static-content.js * stub out the remaining pieces * Add assertion (Which actually helped catch a real duplicate query: get-mac-os-disk-free-space-percentage) * clean out inadvertently committed stuff in sailsrc * route and serve data for correct query by slug + fix error message re duplicate query slugs + added assertion for duplicate doc page slugs * yaml == dev dependency * remove doc-templater dependency, as promised * stub out handbook page * clarify comments & remove unnecessary skipAssets * Update build-static-content.js * res.badConfig() * add missing exit that I left out back inec95df6a4b
* remove unused file * update comments before commenting out and moving over to basic-documentation.less * move example styling of generated HTML over to docs/handbook * include both links * Fix sitemap.xml URLs in local dev by fixing baseUrl config for local development (since Fleet itself is on 1337). * followup tod55c777590
* Include query pages in sitemap.xml (+make urls generated for docs/handbook in build script slightly more real) -- but also don't serve sitemap * sails.config.builtStaticContent.allPages » sails.config.buildStaticContent.markdownPages (also remove unnecessary trailing slash trimming) * trivial * check config when serving sitemap + smarter error message for contributors * hook up GitHub link to edit the query * remove html ids * Update query-detail.ejs * somre more setup re https://github.com/fleetdm/fleet/issues/368#issuecomment-848566533
55 lines
2.0 KiB
JavaScript
Vendored
55 lines
2.0 KiB
JavaScript
Vendored
/**
|
|
* badConfig.js
|
|
*
|
|
* A custom response.
|
|
*
|
|
* Example usage:
|
|
* ```
|
|
* return res.badConfig();
|
|
* // -or-
|
|
* return res.badConfig('builtStaticContent.queries');
|
|
* ```
|
|
*
|
|
* AKA with actions2:
|
|
* ```
|
|
* exits: {
|
|
* badConfig: { responseType: 'badConfig' }
|
|
* }
|
|
* ```
|
|
*
|
|
* ```
|
|
* throw 'badConfig';
|
|
* // -or-
|
|
* throw { badConfig: 'builtStaticContent.queries' }
|
|
* ```
|
|
*/
|
|
|
|
module.exports = function badConfig(configKeyPath) {
|
|
|
|
let res = this.res;
|
|
|
|
sails.log.verbose('Ran custom response: res.badConfig()');
|
|
|
|
if (configKeyPath !== undefined && (!_.isString(configKeyPath) || configKeyPath === '' || configKeyPath.match(/^sails\.config/))) {
|
|
throw new Error('Invalid usage of "badConfig" custom response: If specified, data sent through into the "badConfig" response should be keypath on sails.config; like "custom.internalEmailAddress", not "sails.config.custom.internalEmailAddress". But instead, got: '+configKeyPath);
|
|
}
|
|
|
|
// Determine a reasonable explanation ± any further info/troubleshooting tips.
|
|
let explanation = 'Missing, incomplete, or invalid configuration';
|
|
if (configKeyPath === undefined) {
|
|
explanation += `. Please check your server logs see which action in api/controllers/ this error is coming from, find where this custom response is being called and determine which config assertion is failing, then update the relevant Sails config, and re-lift the server.`;
|
|
} else {
|
|
explanation += ` (sails.config.${configKeyPath}). Please `;
|
|
// Now for an imperative mood phrase that comes after "Please ":
|
|
if (configKeyPath.match(/^builtStaticContent/)) {
|
|
explanation += 'try doing `sails run build-static-content`, and then re-lifting the server.';
|
|
} else {
|
|
explanation += 'update this configuration, and then re-lift the server.\n [?] Unsure? Check out: https://sailsjs.com/documentation/concepts/configuration';
|
|
}
|
|
}
|
|
|
|
// Note that we don't instantiate an Error instance here because its stack trace would be cliffed out.
|
|
return res.serverError(explanation);
|
|
|
|
};
|