Socket
Socket
Sign inDemoInstall

@dynamico/fs-storage

Package Overview
Dependencies
5
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dynamico/fs-storage

Simple file system implementation as Dynamico storage provider


Version published
Weekly downloads
1
Maintainers
3
Install size
170 kB
Created
Weekly downloads
 

Readme

Source

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}`);
});

FAQs

Last updated on 03 Sep 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc