New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

magnet-algolia

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magnet-algolia

Magnet adapter for algoliasearch

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Usage

All Algolia api should refer algoliasearch

Basic

import magnet from 'magnet-core';
import Config from 'magnet-config';
import Logger from 'magnet-bunyan';
import Server from 'magnet-spdy';
import Session from 'magnet-session';
import Router from 'magnet-router';
import Algolia from 'magnet-algolia';

let app = await magnet([Config, Logger, Server, Session, Router, algolia]);

server/controllers/user.js

export default function user({ router, algolia }) {
  router

  .get('/users', async function (ctx) {
    var index = algolia.initIndex('users');

    index.search('Atlenta', function(err, results) {
      if (err) {
        throw err;
      }

      console.log('We got `' + results.nbHits + '` results');
      console.log('Here is the first one: ', results.hits[0]);

      // call client.destroy() this when you need to stop the node.js client
      // it will release any keepalived connection
      algolia.destroy();
    });
    ctx.body = [];
  })

  .post('/user', async function (ctx) {
    ctx.body = ctx.request.body;
  })

  .put('/user/:userId', async function (ctx) {
    ctx.body = ctx.params;
  })

  .get('/user/:userId', async function (ctx) {
    ctx.body = ctx.query;
  });
}

Keywords

magnet

FAQs

Package last updated on 03 Aug 2017

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