2016-10-01 62 views
0

我有一个功能正常的Angular2-Meteor安装。添加流星添加敏捷后无法找到Restivus:restivus

在此之上,我已经通过命令

meteor add nimble:restivus 

安装不显示任何问题安装Restivus。

继Restivus页上的例子(https://github.com/kahmali/meteor-restivus)我创建的第一个文件(logs.collection.ts)配置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); 

} 

我的问题是,IDE告诉我那它'找不到模块meteor/numble:restivus'

任何关于我做错了什么想法? 在此先感谢

+0

即使您收到错误,代码是否仍然执行?你在使用哪个IDE?最有可能发生的是它正在导入Restivus代码,但是你的Linter被流星模块导入所抛弃。 –

+0

我正在使用Visual Studio代码。从mongo/nimble导入是否正确:restivus。你认为它可以修复吗? Thx在任何情况下 – Picci

+0

你写的不是敏捷而是笨拙的。 – erikwall

回答

0

要使用Restivus,您不需要将其作为模块导入,只需拨打new Restivus(options)即可。 Restivus仅在服务器代码中可用,因此请确保您位于if (Meteor.isServer) {}块或/ server目录下的文件中。