You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

baucis-decorator-file

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baucis-decorator-file

Allows properties to be exposed as files.

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
1
-80%
Maintainers
1
Weekly downloads
 
Created
Source

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

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;

Keywords

baucis

FAQs

Package last updated on 24 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts