egg-tmpfs

0.0.5 • Public • Published

egg-tmpfs

Greenkeeper badge

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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.

License

MIT

Package Sidebar

Install

npm i egg-tmpfs

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

6.66 kB

Total Files

8

Last publish

Collaborators

  • paranoidjk