Unit service that loads and creates Filesystem drivers from config. The filesystems will automatically be opened when the app starts, and closed when it stops.

Example

Filesystems can be defined in the server.filesystems config. For example:

import {basePath} from "@extollo/lib"
import {LocalFilesystem, LocalFilesystemConfig} from "@extollo/util"

export default {
// ... other configs ...
filesystems: {
default: {
driver: LocalFilesystem,
config: {
baseDir: basePath('..', 'uploads').toLocal,
} as LocalFilesystemConfig,
},
},
}

The config key should be an instance of the config interface for the driver in question.

Example

Filesystems can then be accessed from the Files service:

if ( files.hasFilesystem('default') ) {
const filesystem = files.getFilesystem('default')
// ... do something with the filesystem ...
}

Hierarchy

Constructors

Properties

config: Config
defaultFilesystem?: Filesystem
filesystems: {
    [key: string]: Filesystem;
} = {}

Type declaration

logging: Logging
status: UnitStatus = UnitStatus.Stopped

The current status of the unit.

Accessors

Methods

  • This method is called to stop the unit when the application is shutting down. Here, you should do any teardown required to stop the package cleanly.

    IN PARTICULAR take care to free blocking resources that could prevent the process from exiting without a kill.

    Returns Promise<void>

  • Get the method with the given name from this class, bound to this class.

    Returns

    function

    Parameters

    • methodName: string

    Returns ((...args: any[]) => any)

      • (...args: any[]): any
      • Get the method with the given name from this class, bound to this class.

        Returns

        function

        Parameters

        • Rest ...args: any[]

        Returns any

  • Returns true if a filesystem with the given name exists.

    Parameters

    • Optional key: string

    Returns boolean

  • Call the make() method on the global container.

    Type Parameters

    • T

    Parameters

    • target: any
    • Rest ...parameters: any[]

    Returns T

  • This method is called to start the unit when the application is booting. Here, you should do any setup required to get the package up and running.

    Returns Promise<void>