UNPKG

tspace-nfs

Version:

tspace-nfs is a Network File System (NFS) and provides both server and client capabilities for accessing files over a network.

191 lines (190 loc) 5.37 kB
/// <reference types="node" /> import { Server } from 'http'; import { Spear } from 'tspace-spear'; /** * The 'NfsServer' class is a created the server for nfs * * @example * import { NfsServer } from "tspace-nfs"; * * new NfsServer() * .listen(8000 , ({ port }) => console.log(`Server is running on port http://localhost:${port}`)) */ declare class NfsServer { private _queue; private _app; private _router; private _html; private _credentials; private _buckets; private _onStudioBucketCreated?; private _onStudioCredentials?; private _onLoadBucketCredentials?; private _fileExpired; private _rootFolder; private _cluster; private _jwtExipred; private _jwtSecret; private _progress; private _debug; private _trash; private _backup; get instance(): Spear; /** * The 'progress' is method used to view the progress of the file upload. * * @returns {this} */ debug(): this; /** * The 'progress' is method used to view the progress of the file upload. * * @returns {this} */ progress(): this; /** * The 'defaultPage' is method used to set default home page. * * @param {string} html * @returns {this} */ defaultPage(html: string): this; /** * The 'directory' is method used to set directory for root directory * * @param {string} folder * @returns {this} */ directory(folder: string): this; /** * The 'cluster' is method used to make cluster for server * * @param {number} workers * @returns {this} */ cluster(workers?: number): this; /** * The 'fileExpired' is method used to set file expiration * * @param {number} seconds * @returns {this} */ fileExpired(seconds: number): this; /** * The 'credentials' is method used to set expiration and secret for credentials * * @param {object} credentials * @property {number} credentials.expired by seconds * @property {string?} credentials.secret * @returns {this} */ credentials({ expired, secret }: { expired: number; secret?: string; }): this; /** * The 'bucketLists' method is used to inform the server about the available bucket lists. * * @param {function} callback * @returns {this} */ bucketLists(callback: () => Promise<string[]>): this; /** * The 'onBucketLists' method is used to inform the server about the available bucket lists. * * @param {function} callback * @returns {this} */ onLoadBucketLists(callback: () => Promise<string[]>): this; /** * The 'onCredentials' is method used to wrapper to check the credentials. * * @param {function} callback * @returns {this} */ onCredentials(callback: ({ token, secret, bucket }: { token: string; secret: string; bucket: string; }) => Promise<boolean>): this; /** * The 'useStudio' is method used to wrapper to check the credentials for studio. * @param {object} studio * @property {function} studio.onCredentials * @property {function} studio.onBucketCreated * @returns {this} */ useStudio({ onCredentials, onBucketCreated, onLoadBucketCredentials }: { onCredentials: (({ username, password }: { username: string; password: string; }) => Promise<{ logged: boolean; buckets: string[]; }>); onBucketCreated?: (({ token, secret, bucket }: { token: string; secret: string; bucket: string; }) => Promise<void>); onLoadBucketCredentials?: (() => Promise<{ bucket: string; token: string; secret: string; }[]>); }): this; /** * The 'listen' method is used to bind and start a server to a particular port and optionally a hostname. * * @param {number} port * @param {function} cb * @returns */ listen(port: number, cb?: ({ port, server }: { port: number; server: Server; }) => void): void; private _default; private _benchmark; private _media; private _apiFile; private _apiBase64; private _apiStream; private _apiStorage; private _apiFolders; private _apiUpload; private _apiMerge; private _apiUploadBase64; private _apiRemove; private _apiConnect; private _studio; private _studioStorage; private _studioPreview; private _stduioPreviewText; private _stduioPreviewTextEdit; private _studioLogin; private _studioLogout; private _studioUpload; private _studioBucket; private _studioBucketCreate; private _studioFiles; private _studioEdit; private _studioRemove; private _fileStructure; private _makeStream; private _verify; private _authMiddleware; private _authStudioMiddleware; private _files; private _normalizeFolder; private _normalizeDirectory; private _normalizePath; private _remove; private _trashed; private _trashedWithFolder; private _fileExists; private _removeOldDirInTrash; private _removeDir; } export { NfsServer }; export default NfsServer;