Not able to find Restivus after having added with meteor add nimble:restivus

401 views Asked by At

I have a functioning Angular2-Meteor installation.

On top of this, I have installed Restivus via the command

meteor add nimble:restivus

The installation does not show any problem.

Following the example found on the Restivus page (https://github.com/kahmali/meteor-restivus) I have created the first file (logs.collection.ts) to configure the API

import {Mongo} from 'meteor/mongo';

import {Restivus} from 'meteor/numble:restivus';

import {Log} from '../interfaces/log.interface';

export const Logs = new Mongo.Collection<Log>('logs');

function loggedIn() {
  return !!Meteor.user();
}

let allowInsert = () => {return false};
let allowUpdate = () => {return false};
let allowDelete = () => {return false}

Logs.allow({
  insert: allowInsert,
  update: allowUpdate,
  remove: allowDelete
});

if (Meteor.isServer) {

  // Global API configuration
  var Api = new Restivus({
    useDefaultAuth: true,
    prettyJson: true
  });

  // Generates: GET, POST on /api/items and GET, PUT, DELETE on
  // /api/items/:id for the Items collection
  Api.addCollection(Logs);

}

My problem is that the IDE is telling me that it 'cannot find module meteor/numble:restivus'

Any idea about what I have done wrong? Thanks in advance

1

There are 1 answers

0
erikwall On

To use Restivus, you don't import it as a module, you simply need to call new Restivus(options). Restivus is only available in server code, so make sure you're in a if (Meteor.isServer) {} block or in a file under a /server directory.