# file-system-mongo

> Creates a windows explorer type tree structure of files and folders in Atlas MongoDB data base.

Latest version **2.0.6** (published 2023-07-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-system-mongo
pnpm add file-system-mongo
yarn add file-system-mongo
bun add file-system-mongo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2023-07-24 |
| First published | 2021-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 69.5 KB |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | cah12 |

## Links

- npm: https://www.npmjs.com/package/file-system-mongo
- npm.io page: https://npm.io/package/file-system-mongo

## Dependencies (7)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [bcrypt](https://npm.io/package/bcrypt.md) ^5.1.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [mongoose](https://npm.io/package/mongoose.md) ^5.10.3
- [streamifier](https://npm.io/package/streamifier.md) ^0.1.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.6

## Recent versions

- 2.0.6 (latest) — 2023-07-24
- 2.0.5 — 2023-07-24
- 2.0.4 — 2023-07-24
- 2.0.3 — 2023-07-23
- 2.0.2 — 2023-07-23
- 2.0.1 — 2022-12-17
- 2.0.0 — 2022-12-17
- 1.0.18 — 2022-12-04
- 1.0.17 — 2021-08-30

## README

File-System-Mongo module creates a "window explorer type" tree structure of files and folders in Atlas MongoDB database.

- [Installation](#installation)
- [Usage](#usage)
  - [Environment variables](#environment-variables)
  - [Simple usage](#simple-usage)
  - [Configuring file-system-mongo](#configuring-file-system-mongo)
  - [REST API Endpoints](#rest-api-endpoints)
- [Examples](#examples)

# Installation


This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [npm install command](https://docs.npmjs.com/downloading-and-installing-packages-locally):

    $ npm install file-system-mongo

# Usage

## Environment variables

The following environment variables are required.

| Evironment Variable Name  | Description |
|:----                      |:---         |
| FILESYSTEM_DATABASE_URL | [URI connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) could reference a local database during development |
| ACCESS_TOKEN_SECRET | A string generated by running [require('crypto').randomBytes(64).toString()](https://nodejs.org/api/crypto.html#cryptorandombytessize-callback) in the terminal will work as a secret |
| REFRESH_TOKEN_SECRET | A string generated by running [require('crypto').randomBytes(64).toString()](https://nodejs.org/api/crypto.html#cryptorandombytessize-callback) in the terminal will work as a secret |



## Simple usage

    const express = require('express')
    var app = express()
    const fileSystemMongo = require('file-system-mongo')(app)

    app.use(fileSystemMongo)

    app.get('/tree', function (req, res) {
      res.json({msg: 'This is CORS-enabled for all origins!'})
    })

    app.listen(80, function () {
      console.log('Web server listening on port 80')
    })

## Configuring file-system-mongo

Options:

- white_list: "http://127.0.0.1:5500,http://localhost:5000", //default: undefined
- access_token_expiry: "15s", //default: 900s
- cookie_max_age: 1000\*60\*60, //default: 1000\*60\*60\*24 (1 day)
- cookie_secure: false, //default: true

## REST API Endpoints

File-System-Mongo REST API provides many document-oriented endpoints, but also allows you to [customize your own](#customizing-file-system-mongo-rest-api).

See [endpoints doc](https://documenter.getpostman.com/view/283450/2s8Z6sbvtg) for a full documentation of the endpoints

Here are the endpoints provided by File-System-Mongo that perform CRUD operations on resources in REST style.
            |

## Customizing File-System-Mongo REST API

    ...
    const app = express();

    const { router, getFileSystem, authenticateToken } = require("./file-system-routes")(app);

    router.get("/custom", authenticateToken, (req, res) => {
      const username = req.user.username;
      const fsPromises = getFileSystem(username).promises;
      console.log(fsPromises);
    });

    app.use(router);
    ...

---
_Source: https://npm.io/package/file-system-mongo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
