0

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

Picci
  • 16,775
  • 13
  • 70
  • 113
  • Does the code execute even though you are getting an error? Which IDE are you using? What is most likely happening is that it is importing the Restivus code just fine, but your Linter is being thrown off by meteor module import. – Andrew Hill Oct 01 '16 at 14:09
  • I am using Visual Studio Code. Is it correct to import from mongo/nimble:restivus. Do you think it can be fixed? Thx in any case – Picci Oct 01 '16 at 15:56
  • You've written numble instead of nimble. – erikwall Oct 02 '16 at 06:42
  • Thanks, you are right. Unfortunately though even if I fix it the error does not disappear. If I ignore it and launch the 'meteor' command I get the same message 'Cannot find module 'meteor/nimble:restivus'' on the console and the execution stalls on the message 'Starting the app'. I will try to reinstall the whole thing in a brand new directory and see if it works. Thanks anyway – Picci Oct 02 '16 at 10:00

1 Answers1

0

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.

erikwall
  • 151
  • 4