silex-website-builder-goodevent
Version:
Free and easy website builder for everyone.
81 lines (71 loc) • 2.55 kB
text/typescript
import * as CloudExplorer from 'cloud-explorer';
import * as Os from 'os';
import {CeOptions} from '../ServerConfig';
export default function(ceOptions: CeOptions) {
const routerOptions: any = {};
// FTP service
if (ceOptions.enableFtp) {
console.log('> FTP service enabled');
routerOptions.ftp = {
redirectUri: ceOptions.rootUrl + '/ftp/signin',
};
} else {
console.log('> FTP service disabled, env vars ENABLE_FTP not set');
}
// SFTP service
if (ceOptions.enableSftp) {
console.log('> SFTP service enabled');
routerOptions.sftp = {
redirectUri: ceOptions.rootUrl + '/sftp/signin',
};
} else {
console.log('> SFTP service disabled, env vars ENABLE_SFTP not set');
}
// Webdav service
if (ceOptions.enableWebdav) {
console.log('> Webdav service enabled');
routerOptions.webdav = {
redirectUri: ceOptions.rootUrl + '/webdav/signin',
};
} else {
console.log('> Webdav service disabled, env vars ENABLE_WEBDAV not set');
}
// Github service
if (ceOptions.githubClientId && ceOptions.githubClientSecret) {
console.log('> Github service enabled', ceOptions.githubClientId);
routerOptions.github = {
clientId: ceOptions.githubClientId,
clientSecret: ceOptions.githubClientSecret,
redirectUri: ceOptions.rootUrl + '/github/oauth_callback',
};
} else {
console.log('> Github service disabled, env vars GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET not set');
}
// Dropbox service
if (ceOptions.dropboxClientId && ceOptions.dropboxClientSecret) {
console.log('> Dropbox service enabled', ceOptions.dropboxClientId);
routerOptions.dropbox = {
clientId: ceOptions.dropboxClientId,
clientSecret: ceOptions.dropboxClientSecret,
redirectUri: ceOptions.rootUrl + '/dropbox/oauth_callback',
};
} else {
console.log('> Dropbox service disabled, env vars DROPBOX_CLIENT_ID and DROPBOX_CLIENT_SECRET not set');
}
// Local file system service
if (ceOptions.enableFs) {
const fsRoot = ceOptions.fsRoot || Os.homedir();
console.log('> Local file system service enabled');
console.warn('Warning local file system is writable, use FS_ROOT as root (', fsRoot, ')');
routerOptions.fs = {
showHiddenFile: false,
sandbox: fsRoot,
infos: {
displayName: 'fs',
},
};
} else {
console.log('> Local file system service disabled, env vars SILEX_ELECTRON or SILEX_DEBUG or ENABLE_FS not set');
}
return new CloudExplorer(routerOptions);
}