# baucis-decorator-file

> Allows properties to be exposed as files.

Latest version **1.0.2** (published 2015-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install baucis-decorator-file
pnpm add baucis-decorator-file
yarn add baucis-decorator-file
bun add baucis-decorator-file
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-06-24 |
| First published | 2015-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | timbur |
| Maintainers | timbur |
| Keywords | baucis, decorator, properties, as, files, resource |

## Links

- npm: https://www.npmjs.com/package/baucis-decorator-file
- Repository: https://github.com/loggur/baucis-decorator-file
- Homepage: https://github.com/loggur/baucis-decorator-file#readme
- Issues: https://github.com/loggur/baucis-decorator-file/issues
- npm.io page: https://npm.io/package/baucis-decorator-file

## Dependencies (4)

- [baucis](https://npm.io/package/baucis.md) ^1.3.1
- [baucis-decorators](https://npm.io/package/baucis-decorators.md) ^1.0.0
- [baucis-decorator-env](https://npm.io/package/baucis-decorator-env.md) ^1.0.0
- [baucis-decorator-auth](https://npm.io/package/baucis-decorator-auth.md) ^1.0.0

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-06-24
- 1.0.1 — 2015-06-05
- 1.0.0 — 2015-06-03

## README

# baucis-decorator-file
Allows properties to be exposed as files.

## Install
```
npm install baucis-decorators baucis-decorator-file --save
```

## Usage
Add the decorator and it will add the functionality to any properties containing a `file` field set to some `mime-type`.  For the following example, you could GET the `jsx` as a file via something like `/api/components/123.jsx` or `/api/components/my-component.123.jsx`.

## Example
`controllers/Component.js`
```js
var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var extend = require('deep-extend');
var ResourceProps = require('../props/Resource.js');
var ResourceController = require('../controllers/Resource.js');

var ComponentProps = extend({}, ResourceProps);

ComponentProps.jsx = {
  type: String,
  file: 'text/jsx'
};

var ComponentSchema = new Schema(ComponentProps);
var ComponentModel = mongoose.model('Component', ComponentSchema);
var ComponentController = baucis.rest('Component');

var decorators = require('baucis-decorators');

// decorate controller
decorators.add.call(ComponentController, [
  'baucis-decorator-file',  // checks each property for any `file` fields and adds functionality accordingly
  ResourceController        // `ComponentController` will inherit all of `ResourceController`'s decorators
]);

/**
 * Expose controller.
 */
module.exports = ComponentController;

---
_Source: https://npm.io/package/baucis-decorator-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
