nextdrive
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

A lightweight Node.js based file server for modern apps

Install

npm install nextdrive

Usage

import NextDriveServer from 'nextdrive';

const server = new NextDriveServer({
    port:3000,
    apiKey: process.env.API_KEY,
});

server.start();

Optional Parameters

folder: default to '{working dir}/uploads'

options.cors: Allow CORS

options.allowedDomains: Allow CORS only for certain domains

API Endpoints

[POST] /upload/{foldername}

To upload files to the drive. Just send as Formdata. Rest will be handled and returns the file name to store in your db.

const formData = new FormData();
formData.append('files', file);


fetch('http://localhost:3000/upload/{foldername}', 
{
    method: 'POST',
    body : formData,
    {
        headers : {
            'X-API-KEY' : 'API_KEY_ADDED_IN_CONFIGS'
        }
    }
});

// OUTPUTS: File name & details

File access:

http://{root_url}/uploads/{foldername}/{filename}

[DELETE] /{foldername}

To delete files from the drive. Send file names as an Array

const formData = new FormData();
formData.append('files', [filenames]);


fetch('http://localhost:3000/{foldername}', 
{
    method: 'DELETE',
    body : formData,
    {
        headers : {
            'X-API-KEY' : 'API_KEY_ADDED_IN_CONFIGS'
        }
    }
});

Package Sidebar

Install

npm i nextdrive

Homepage

ziqx.cc

Weekly Downloads

5

Version

0.1.0

License

ISC

Unpacked Size

16.4 kB

Total Files

7

Last publish

Collaborators

  • fathah_cr