Initial commit

This commit is contained in:
Spencer Pincott
2024-07-15 22:20:13 -04:00
commit 97737ca1ae
16618 changed files with 934131 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
const algolia = require('algoliasearch');
const Base = require('./Base.js');
class GetSettingsScript extends Base {
constructor() {
super();
// Bind class methods
this.start = this.start.bind(this);
// Define validation constants
this.message =
'\nExample: $ algolia getsettings -a algoliaappid -k algoliaapikey -n algoliaindexname\n\n';
this.params = ['algoliaappid', 'algoliaapikey', 'algoliaindexname'];
}
async start(program) {
try {
// Validate command; if invalid display help text and exit
this.validate(program, this.message, this.params);
// Config params
const appId = program.algoliaappid;
const apiKey = program.algoliaapikey;
const indexName = program.algoliaindexname;
// Instantiate Algolia index
const client = algolia(appId, apiKey);
const index = client.initIndex(indexName);
// Get index settings
const settings = await index.getSettings();
return console.log(JSON.stringify(settings));
} catch (e) {
throw e;
}
}
}
const getSettingsScript = new GetSettingsScript();
module.exports = getSettingsScript;