tachyon-drive-node-fs
v0.10.1
Published
Nodejs fs module storage driver implementation
Downloads
42
Readme
tachyon-drive-node-fs
NodeFS File Storage Driver for Tachyon Drive and Tachyon Drive Crypto processor
Initialize simple JSON file storage driver
const driver = new FileStorageDriver('FileStorageDriver', './store.json', bufferSerializer);
Initialize crypt processor with JSON file storage driver
const processor = new CryptoBufferProcessor(Buffer.from('some-secret-key'));
const driver = new FileStorageDriver('FileStorageDriver', './store.json.aes', bufferSerializer, processor);
Example usage of local notification file updates when running multiple process on same host
const fileUpdateNotify = new FileUpdateNotify('./store.notify');
const driver = new SomeDriver('SomeDriverWithoutUpdateNotification', bufferSerializer, fileUpdateNotify);
// includes common strToBufferSerializer
const jsonSerialization: IPersistSerializer<Data, string> = {
deserialize: (buffer: string) => JSON.parse(buffer.toString()),
serialize: (data: Data) => JSON.stringify(data),
validator: (data: Data) => dataSchema.safeParse(data).success,
};
const bufferSerializer: IPersistSerializer<Data, Buffer> = nextSerializer<Data, string, Buffer>(jsonSerialization, strToBufferSerializer);