Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ask-lowdb-persistence-adapter
Advanced tools
An Alexa Skills Kit persistence adapter for lowdb.
For deployed Alexa Skills, you should use a proper persistence layer (for example Amazon S3 using the ask-sdk-s3-persistence-adapter), but for local development S3 can be awkward to use. Using lowdb is great because it saves the data locally making it easy to debug and work with.
Install adapter:
npm i ask-lowdb-persistence-adapter
Install peer dependencies:
npm i lowdb
Basic usage:
const LowdbPersistenceAdapter = require("ask-lowdb-persistence-adapter");
// ...
const options = {
// the name of the lowdb database, default value shown here
dbName: "persistenceAttributes.db.json",
// the name of the key to store persistence attributes under in the
// database, default value shown here
attributesKey: "persistenceAttributes",
};
Alexa.SkillBuilders.custom()
.withPersistenceAdapter(new LowdbPersistenceAdapter(options))
.addRequestHandlers(/* ... */)
.lambda();
Since the primary purpose of this adapter is for use locally when a proper persistence layer is unavailable, a nice pattern for creating your persistence adapter is to use a factory. For example, if one wanted to use S3 when it was available and lowdb otherwise, one could implement it like so:
const LowdbPersistenceAdapter = require("ask-lowdb-persistence-adapter");
const S3PersistenceAdapter = require("ask-sdk-s3-persistence-adapter")
.S3PersistenceAdapter;
class PersistenceAdapterFactory {
constructor(s3BucketName) {
this.s3BucketName = s3BucketName;
}
createPersistenceAdapter() {
if (this.s3BucketName) {
return new S3PersistenceAdapter({
bucketName: this.s3BucketName,
});
} else {
return new LowdbPersistenceAdapter();
}
}
}
// ...
const persistenceAdapterFactory = new PersistenceAdapterFactory(
process.env.S3_PERSISTENCE_BUCKET
);
Alexa.SkillBuilders.custom()
.withPersistenceAdapter(persistenceAdapterFactory.createPersistenceAdapter())
.addRequestHandlers(/* ... */)
.lambda();
FAQs
An Alexa Skills Kit persistence adapter for Lowdb
We found that ask-lowdb-persistence-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.