From 375e7ce6175ce91a31491647ab0f91fa7a33e7a5 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Mon, 29 Mar 2021 11:14:07 -0500 Subject: [PATCH] Add config structure for Filesystems --- src/Units.extollo.ts | 3 ++- src/app/configs/server.config.ts | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Units.extollo.ts b/src/Units.extollo.ts index ff9fc1d..2bcf2b0 100644 --- a/src/Units.extollo.ts +++ b/src/Units.extollo.ts @@ -1,10 +1,11 @@ -import {Config, Controllers, HTTPServer, Middlewares, Routing, Unit} from '@extollo/lib' +import {Config, Controllers, HTTPServer, Files, Middlewares, Routing, Unit} from '@extollo/lib' import {Database, Models} from "@extollo/orm"; import {CommandLine} from "@extollo/cli"; import {Internationalization} from "@extollo/i18n"; export const Units = [ Config, + Files, CommandLine, Controllers, Middlewares, diff --git a/src/app/configs/server.config.ts b/src/app/configs/server.config.ts index a893c3e..7cf69ec 100644 --- a/src/app/configs/server.config.ts +++ b/src/app/configs/server.config.ts @@ -1,13 +1,41 @@ -import {env} from "@extollo/lib" +import {env, basePath} from "@extollo/lib" import {ORMSession} from "@extollo/orm" +import {LocalFilesystem, LocalFilesystemConfig} from "@extollo/util" export default { debug: env('DEBUG_MODE', false), session: { + /* The implementation of @extollo/lib.Session that serves as the session backend. */ driver: ORMSession, }, + /* + * Here, you can define various filesystem drivers that can be used in + * your application to store/retrieve files. + * + * The key in the object is the 'name' of the filesystem as it will be + * fetched in code. For example, if you have a `fubar: { ... }` item, + * then you can retrieve that filesystem using the Files service like + * so: + * + * files.getFilesystem('fubar') // => Filesystem { ... } + */ + filesystems: { + default: { + /* If true, this will serve as the default filesystem for modules in your application. */ + isDefault: true, + + /* The implementation of @extollo/util.Filesystem that serves as the backend. */ + driver: LocalFilesystem, + + /* The config required by the filesystem driver. */ + config: { + baseDir: basePath('..', 'uploads').toLocal, + } as LocalFilesystemConfig, + } + }, + middleware: { global: { pre: ['LogRequest'],