https://github.com/koopjs/koop-filesystem-local
A local filesystem plugin for Koop that keeps all file actions confined to a single root directory
https://github.com/koopjs/koop-filesystem-local
Last synced: 8 months ago
JSON representation
A local filesystem plugin for Koop that keeps all file actions confined to a single root directory
- Host: GitHub
- URL: https://github.com/koopjs/koop-filesystem-local
- Owner: koopjs
- License: other
- Created: 2016-04-14T19:06:57.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T21:14:17.000Z (over 3 years ago)
- Last Synced: 2025-06-03T21:01:49.669Z (about 1 year ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Koop Local FS
[](https://greenkeeper.io/)
*A filesystem plugin for koop that supports setting a root directory for all actions*
[![npm][npm-img]][npm-url]
[![travis][travis-image]][travis-url]
## Project goal
In order to allow different koop modules to write to local disk without specifying a machine specific absolute path, this module resolves all relative paths to the same base directory. So you can call`koop.fs.createReadStream('foo.txt')` and always know that you can open foo without changing the working directory.
## Usage
### In `default.json`
```json
{
"filesystem": {
"local": {
"rootDir": "/var/koop/files"
}
}
}
```
### In `server.js`
```javascript
const config = require('config')
const koop = require('koop')(config)
const LocalFs = require('koop-localfs')
koop.register(LocalFs)
```
## Supported functions
- stat - Get information about a file
- createReadStream: create a readable stream from a file on disk
- createWriteStream: create a writeable stream you can pipe to
- writeFile: write a file to disk
- readFile: read a file from disk
- unlink: delete a file
- mkdir: make a directory
- rmdir: remove an empty directory
- rmdirp: recursively remove a directory and its contents
- realpathSync: resolve the absolute path when given a relative path
[npm-img]: https://img.shields.io/npm/v/koop-localfs.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/koop-localfs
[travis-image]: https://img.shields.io/travis/koopjs/koop-filesystem-local.svg?style=flat-square
[travis-url]: https://travis-ci.org/koopjs/koop-filesystem-local