egg-tmpfs
v0.0.5
Published
A plugin for egg which help to create and auto clean temp folder when request finish or error
Downloads
4
Readme
egg-tmpfs
Install
$ npm i egg-tmpfs --save
Usage
// {app_root}/config/plugin.js
exports.tmpfs = {
enable: true,
package: 'egg-tmpfs',
};
Configuration
// {app_root}/config/config.default.js
exports.tmpfs = {
baseTmpPath: '/foo/bar',
};
see config/config.default.js for more detail.
api
ctx.tmpfs.ensureDir(dir[,options][,callback])
same as fsextra.ensureDir, but path will based on config.tmpfs.baseTmpPath
, and the created folder will be auto cleand when request is finished or errored.
ctx.tmpfs.mark(path)
just incase you have to use original node fs module, then you can create file first, then mark it need to be delete.
ctx.tmpfs.unmark(path)
to revert what ctx.tmpfs.mark(path)
did.
ctx.tmpfs.clean()
clean all tmp folders, return a Promise
Generally, you do not need to use this :) egg-tmpfs will auto call clean.
Example
see test
Questions & Suggestions
Please open an issue here.