diff --git a/README.md b/README.md index 85eb04f..b19c6f1 100755 --- a/README.md +++ b/README.md @@ -347,34 +347,7 @@ ass is intended to provide a strong backend for developers to build their own fr A Papito data engine implements support for one type of database (or file, such as JSON or YAML). This lets ass server hosts pick their database of choice, because all they'll have to do is enter the connection/authentication details, and ass will handle the rest, using the resource ID as the key. -The only engine ass comes with by default is **JSON**. If you find or create an engine you like, you can use it by installing it with `npm i ` then changing the contents of [`data.js`]. The engines own README file should also instruct how to use it. At this time, a modified `data.js` might look like this: - -```js -/** - * Used for global data management - */ - -//const { JsonStorageEngine } = require('@tycrek/papito'); -const { CustomStorageEngine } = require('my-custom-papito'); - -//const data = new JsonStorageEngine(); - -// StorageEngines may take no parameters... -const data1 = new CustomStorageEngine(); - -// multiple parameters... -const data2 = new CustomStorageEngine('Parameters!!', 420); - -// or object-based parameters, depending on what the StorageEngine dev decides on. -const data3 = new CustomStorageEngine({ key1: 'value1', key2: { key3: 44 } }); - -module.exports = data1; - -``` - -As long as the engine properly implements `GET`/`PUT`/`DEL`/`HAS` StorageFunctions, replacing the file/database system is just that easy. - -**For a detailed walkthrough on developing engines, [consult the wiki][ctw2].** +**~~For a detailed walkthrough on developing engines, [consult the wiki][ctw2].~~ Outdated!** [`data.js`]: https://github.com/tycrek/ass/blob/master/data.js [ctw2]: https://github.com/tycrek/ass/wiki/Writing-a-StorageEngine diff --git a/data.js b/data.js index 8ba1ff5..c265eee 100644 --- a/data.js +++ b/data.js @@ -2,6 +2,11 @@ * Used for global data management */ +// Old data const { JsonDataEngine } = require('@tycrek/papito'); -const data = new JsonDataEngine(); -module.exports = data; + +// Actual data engine +const { dataEngine } = require('./config.json'); +const { _ENGINE_ } = require(dataEngine); + +module.exports = _ENGINE_(new JsonDataEngine()); diff --git a/package-lock.json b/package-lock.json index 8b7ccc2..f3a8aee 100755 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@tycrek/express-nofavicon": "^1.0.2", "@tycrek/isprod": "^2.0.2", "@tycrek/log": ">=0.5.x", - "@tycrek/papito": "^0.3.1", + "@tycrek/papito": "^0.3.4", "any-shell-escape": "^0.1.1", "aws-sdk": "^2.930.0", "check-node-version": "^4.1.0", @@ -598,9 +598,9 @@ } }, "node_modules/@tycrek/papito": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@tycrek/papito/-/papito-0.3.1.tgz", - "integrity": "sha512-hhUMqe+rLIMeLEDERq8LoL20wAaEJMF3RH2nONpiz4ihkUjzLyuRwc6DDayyJkrzIdJVohLWcSK3vV3icJ2RCw==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@tycrek/papito/-/papito-0.3.4.tgz", + "integrity": "sha512-P5sQAJQOeirCzpphU6tXqjiCUmJf+A8T/1iJkpWu/uLq30lHyKjIoOeCXnW92b3hdDDxO1ruanxX2muJZTPQdA==", "dependencies": { "fs-extra": "^10.0.0" }, @@ -4109,9 +4109,9 @@ } }, "@tycrek/papito": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@tycrek/papito/-/papito-0.3.1.tgz", - "integrity": "sha512-hhUMqe+rLIMeLEDERq8LoL20wAaEJMF3RH2nONpiz4ihkUjzLyuRwc6DDayyJkrzIdJVohLWcSK3vV3icJ2RCw==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@tycrek/papito/-/papito-0.3.4.tgz", + "integrity": "sha512-P5sQAJQOeirCzpphU6tXqjiCUmJf+A8T/1iJkpWu/uLq30lHyKjIoOeCXnW92b3hdDDxO1ruanxX2muJZTPQdA==", "requires": { "fs-extra": "^10.0.0" }, diff --git a/package.json b/package.json index 5f0e583..e6c15c7 100755 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@tycrek/express-nofavicon": "^1.0.2", "@tycrek/isprod": "^2.0.2", "@tycrek/log": ">=0.5.x", - "@tycrek/papito": "^0.3.1", + "@tycrek/papito": "^0.3.4", "any-shell-escape": "^0.1.1", "aws-sdk": "^2.930.0", "check-node-version": "^4.1.0", diff --git a/setup.js b/setup.js index 238d503..127beaf 100755 --- a/setup.js +++ b/setup.js @@ -12,6 +12,7 @@ const config = { spaceReplace: '_', mediaStrict: false, viewDirect: false, + dataEngine: '@tycrek/papito', frontendName: 'ass-x', indexFile: '', s3enabled: false, @@ -159,6 +160,12 @@ function doSetup() { default: config.viewDirect, required: false }, + dataEngine: { + description: 'Data engine to use (must match an NPM package name. If unsure, leave blank)', + type: 'string', + default: config.dataEngine, + required: false + }, frontendName: { description: 'Name of your frontend (leave blank if not using frontends)', type: 'string',