2016-10-01 61 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目錄下的文件中。