All Projects → Meteor-Community-Packages → meteor-method-hooks

Meteor-Community-Packages / meteor-method-hooks

Licence: MIT License
atmospherejs.com/seba/method-hooks

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to meteor-method-hooks

Meteor Collection Hooks
Meteor Collection Hooks
Stars: ✭ 641 (+2570.83%)
Mutual labels:  hooks, meteor
graphire
An unopinionated react graph visualization library.
Stars: ✭ 256 (+966.67%)
Mutual labels:  hooks
ieaseMusic
网易云音乐第三方🎵
Stars: ✭ 62 (+158.33%)
Mutual labels:  hooks
react-native-aria
A library of React Hooks for React-Native (Android/iOS/web) to provide accessible UI primitives for a design system.
Stars: ✭ 164 (+583.33%)
Mutual labels:  hooks
gatsby-react-hooks
An example of using Gatsby with React hooks
Stars: ✭ 26 (+8.33%)
Mutual labels:  hooks
sofie-core
Sofie: The Modern TV News Studio Automation System (Server Core)
Stars: ✭ 70 (+191.67%)
Mutual labels:  meteor
zhooks
Display Zsh hook functions and arrays
Stars: ✭ 36 (+50%)
Mutual labels:  hooks
react-movies-finder
React Movies finder is a React app to search movies and series using redux, redux-thunk, React Hooks, and Material UI
Stars: ✭ 27 (+12.5%)
Mutual labels:  hooks
use-tiny-state-machine
A tiny (~700 bytes) react hook to help you write finite state machines
Stars: ✭ 37 (+54.17%)
Mutual labels:  hooks
document-title
React hook for updating the document-title
Stars: ✭ 60 (+150%)
Mutual labels:  hooks
RT7-example
Code for the React Table 7 article
Stars: ✭ 32 (+33.33%)
Mutual labels:  hooks
use-mutation
🧬 Run side-effects safely in React
Stars: ✭ 81 (+237.5%)
Mutual labels:  hooks
revery-graphql-hooks
A library for easy handling of GraphQL with hooks for Revery
Stars: ✭ 34 (+41.67%)
Mutual labels:  hooks
useReactHooks
useReactHooks is a curated list of custom react hooks that will benefit people in their daily tasks related to development in react.
Stars: ✭ 42 (+75%)
Mutual labels:  hooks
Twenty48
A modified clone of the puzzle game 2048, built in react/typescript!
Stars: ✭ 31 (+29.17%)
Mutual labels:  hooks
hook-into-props
Tiny HoC to use React hooks with class components.
Stars: ✭ 44 (+83.33%)
Mutual labels:  hooks
React-Combine-Provider
combine react providers in ease
Stars: ✭ 29 (+20.83%)
Mutual labels:  hooks
Oxide.Patcher
IL patcher for use with adding Oxide support to .NET games
Stars: ✭ 27 (+12.5%)
Mutual labels:  hooks
wp-documentor
Documentation Generator for WordPress.
Stars: ✭ 28 (+16.67%)
Mutual labels:  hooks
uglifyjs2
Meteor package that exposes options for UglifyJS2 JS minifier
Stars: ✭ 15 (-37.5%)
Mutual labels:  meteor

Meteor Method Hooks

Before/after hooks for Meteor methods

This package extends Meteor with four methods:

  • Meteor.beforeMethod
  • Meteor.afterMethod
  • Meteor.beforeAllMethods
  • Meteor.afterAllMethods

This package differs from hitchcott:method-hooks in that:

  • You can add hooks for all methods
  • It works on both client and server
  • You can add and remove hooks at runtime.
  • After methods can change the methods result

The beforeMethod method can be used for securing Meteor.methods based on the result of a definable function. Any beforeMethod that throws an error will stop the relevant method and any other hooks from executing. If you want to prevent further execution without triggering an error, you can just return 'false' from within your hook.

Here's an example for checking user login:

Meteor.beforeMethod('test',function(){
  if(!Meteor.userId()) throw new Meteor.Error(403,"Forbidden");
})

You can also pass an array of method names as first parameter.

Uses include:

  • Security
  • Logging
  • [insert imaginative idea]

The before methods get the same arguments as the original method,

The after method can get the current result from this.result or the error from this.error If it returns a value that is not undefined, then this will replace the original result.

TODO

  • Testing

Credits

Inspired by: Chris Hitchcott, 2015

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].