Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baucis-decorator-init

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baucis-decorator-init

Initializes certain properties upon creation of a resource. Different from `default` in that it is able to use the `req` object.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

baucis-decorator-init

Initializes certain properties upon creation of a resource. Different from default in that it is able to use the req object.

Install

npm install baucis-decorators baucis-decorator-init --save

Usage

Add the decorator and it will add the functionality to any properties containing an init field as a function.

Example

controllers/Resource.js

var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;

var ResourceProps = {};

ResourceProps.editors = {
  type: [{
    type: ObjectId,
    ref: 'User'
  }],
  init: function (req, res, next) {
    return [req.session.userId];
  }
};

var ResourceSchema = new Schema(ResourceProps);
var ResourceModel = mongoose.model('Resource', ResourceSchema);
var ResourceController = baucis.rest('Resource');

var decorators = require('baucis-decorators');
decorators.add.call(ResourceController, [
  'baucis-decorator-init'
]);

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

Keywords

FAQs

Package last updated on 05 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc