# Install Flmngr as a module to your Nest website or app

> Install the Nest Express package and call bindFlmngr inside bootstrap to serve file manager requests from your NestJS application.

Source: https://n1ed.com/docs/file-manager/node-nest  
Original: https://flmngr.com/doc/install-file-manager-server-node-nest  
Section: File manager > Node Nest module  
Every page of n1ed.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://n1ed.com/llms-full.txt

## Requirements

The module requires Node.js >= 18.17 on your server and Nest 9 or newer.

You can check the version you use with the `node -v` command.

## Install NPM package

Flmngr for Nest apps ships as [`@edsdk/flmngr-server-node-nest-express`](https://www.npmjs.com/package/@edsdk/flmngr-server-node-nest-express) NPM package. Go into the directory of your project and run:

```bash
npm i @edsdk/flmngr-server-node-nest-express --save
```

Note that this package is compatible with Nest installations based on the Express platform (this is the default, the alternative platform, Fastify, will be supported in the future).

## Set routes to map a URL

Next, you need to map a URL to the backend. This URL will handle all JSON dialogs between Flmngr file manager and the server. This can be done with the `bindFlmngr` function from the package.

Here is a sample of the app code you will have after:

```js
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { bindFlmngr } from "@edsdk/flmngr-server-node-nest-express";

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  bindFlmngr({
    app: app,
    urlFileManager: "/flmngr",
    urlFiles: "/files/",
    dirFiles: "./files"
  });

  await app.listen(3000);
}
bootstrap();
```

In the sample above, we tell the Flmngr to attach to the `flmngr` URL of the server and use `./files` as a storage with all files user will manage.

Also, this app will serve this storage directory as a public folder mapped to the URL `/files`. Do not confuse the path to the directory with the URL it will be published on, and remember that the `urlFiles` parameter is optional in case you will publish this directory with other tools (e.g., Nginx).

## GitHub sample

There is a sample on GitHub showing how to implement Flmngr backend in existing app:

[Flmngr backend in Nest app sample](https://github.com/flmngr/flmngr-server-node-nest-express-example-ts)

> **Hint:** You can fork the sample if you are starting a new Nest project where you need the Flmngr file manager to be included.

## Link Flmngr with the server

Using the visual Dashboard, you can specify the URLs of your server to link Flmngr with it.

- **File Manager URL** is the value you've passed into the `bindFlmngr()` as the `urlFileManager` option.
- **Files URL** is the value you've passed into the `bindFlmngr()` as the `urlFiles` option.

![File manager control panel](https://n1ed.com/img/screenshots/docs/widgets/config-editor/file-manager-set-url.png)

**Use absolute URLs**. While URLs in Nest server should be without a domain, but from the root of your website (like `/path`), these URLs on the client (in Dashboard or config) should be set in the full absolute form (like `http://your-domain.com/path`) to avoid any possible mistakes.

> **Note:** If you use a HTTP proxy server like Nginx, please use URLs it maps to internal Nest app.

[Go to Dashboard](https://n1ed.com/dashboard)

> **Note:** Alternatively, you can pass these parameters as [Flmngr.urlFileManager](https://flmngr.com/doc/api-load#method_load__param_urlFileManager) and [Flmngr.urlFiles](https://flmngr.com/doc/api-load#method_load__param_urlFiles) parameters into the Flmngr config. This is useful when you need to use different directories based on the current user to support [multi-user installations](https://n1ed.com/docs/multisite/separating-file-storages).

### Files URL explanation

The **Files URL** option is the prefix Flmngr will add to any file when inserting it into your content (or returning it in a callback of your API call). If you can use Flmngr fine, but all inserted images are broken, please see this sample to understand how it works:

**Files URL** or `Flmngr.urlFiles` client-side parameter

`http://your-website.com/files/`

`/var/www/files/`

`dirFiles` server-side parameter

\+ `/path/to/image.png`

For example, Flmngr inserts the file `/path/to/image.png` into your content as `http://your-website.com/files/path/to/image.png`, and on the server that file is `/var/www/files/path/to/image.png`.

## Multi-user environment

Flmngr can work in applications where you have many users with different storages. You can programmatically specify `Flmngr.urlFiles` and `dirFiles` parameters synchronously with values based on the current user's session.

[Multi-user manual](https://n1ed.com/docs/multisite/separating-file-storages)

## S3/Blob support

Flmngr supports not only your own server but also cloud storages: Amazon S3 and Azure Blob. This is an enterprise feature we offer as a separate option.

[S3/Blob support](https://n1ed.com/docs/cloud-storage)
