This package has been deprecated

Author message:

This package is no longer maintained and has been deprecated. Please migrate to other solutions as soon as possible.

@dynamico/fs-storage
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.10 • Public • Published

File system storage

File system saves components in a specific folder provided in initialization. It uses node file system APIs and needs both read and write permissions as well as permissions to list the folder. Generally this isn't a production grade solution as it's not scalable and should be used mostly when playing around.

Let's set up a file system storage provider. It'll take just a few minutes!

Note: this guide assumes you have an express server set up along with the express middleware. If this is not the case refer to our Getting Started - Backend guide.

Getting Started With File System Storage

Let's start by adding the dependency:

$ npm install @dynamico/fs-storage --save

Now find the file where you initialized dynamico middleware and add the following require statement.

const { FSStorage } = require('@dynamico/fs-storage');

And initialize the provider and middleware:

const storageProvider = new FSStorage('./components');
const dynamicoMiddleware = dynamico(storageProvider);
// Use the middleware

And that's it! you now have a server that uses file system to manage dynamic components.

The full code looks something like this:

const express = require('express');
const dynamico = require('@dynamico/express-middleware');
const { FSStorage } = require('@dynamico/fs-storage');

const storageProvider = new FSStorage('./components');
const dynamicoMiddleware = dynamico(storageProvider);

const app = express();
app.use('/api/components', dynamico(storageProvider);
app.listen(Number(process.env.PORT || 1234), () => {
  console.log(`Listening on port ${process.env.PORT}`);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @dynamico/fs-storage

Weekly Downloads

0

Version

0.0.1-alpha.10

License

MIT

Unpacked Size

79.5 kB

Total Files

22

Last publish

Collaborators

  • asurion-security
  • solutobuild