🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

baucis-decorator-once

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-once

Prevents clients from updating certain properties.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

baucis-decorator-once

Prevents clients from updating certain properties.

Install

npm install baucis-decorators baucis-decorator-once --save

Usage

Add the decorator and it will add the functionality to any properties containing a once 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.createdBy = {
  type: ObjectId,
  ref: 'User',
  required: true,
  once: function getUserId (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-once'
]);

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

Keywords

baucis

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