Socket
Book a DemoInstallSign in
Socket

loopback-likes-mixin

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

loopback-likes-mixin

A mixin to provide like and dislike functionallity for Loopback Models

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

NPM NPM

Loopback Stats Mixin

This module is designed for the Strongloop Loopback framework. It provides likes and dislikes functionallity to any Model.

INSTALL

  npm install loopback-likes-mixin --save

MIXINSOURCES

With loopback-boot@v2.8.0 mixinSources have been implemented in a way which allows for loading this mixin without changes to the server.js file previously required.

Add the mixins property to your server/model-config.json like the following:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-likes-mixin/dist",
      "../common/mixins"
    ]
  }
}

STATS MIXIN

This mixin creates a Remote Method with endpoint entry /:id/like.

EXAMPLE

The following is the default configuration

"mixins": {
    "Likes": [
        {
          "method": "like",
          "endpoint": "/:id/like",
          "likes": "likes",
          "userModel": "User"
        }
    ]
}

is equivalent to

"mixins": {
    "Likes": true
}

The code defined above would create a localhost:3000/api/model/:id/likes endpoint with the ability to like and dislike an instance of a Model in which the mixin is implemented.

BOOT OPTIONS

The following options are the optional configurations for the mixin to work.

OptionsTypeRequriedPossible ValuesExamples
methodStringNoAnylike, likeThis, liker
endpointStringNoURL Form/likes, /:id/likes
descriptionStringNoAnyLoopback Explorer Description
likesStringNoAnyModel property name with Object type
userModelStringNoUser based modelsUser, Account, Admin.. e

LICENSE

MTI

Keywords

loopback

FAQs

Package last updated on 15 Apr 2016

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