How do you make a REST API and upload files in Met

2019-03-29 12:44发布

What is about a REST API? Is there already a way to define some routes and logic for the API on the server? I think this is nowadays a must-have feature.

And the same with File-Uploads. With express framework I can already handle uploads really easy. How do I do this in Meteor? The documentation says nothing about it. So are there some plans to implement it? Or is there already a way?

标签: rest meteor
2条回答
欢心
2楼-- · 2019-03-29 12:59

I have been using https://github.com/crazytoad/meteor-collectionapi#readme

Which will create rest endpoints on your collections right out of the box. You can use meteorite to install it.

查看更多
太酷不给撩
3楼-- · 2019-03-29 13:08

As far as REST goes: Meteor doesn't yet provide a supported API for serving HTTP from your application. This is intentional: in the not-too-distant future, your application server is likely to not be just a single process directly serving end users, but an arbitrarily parallelizable service behind a proxy tier. So we'll need to provide a supported API for responded to HTTP requests (for example, REST) that continues to work in such a setting.

If you really need to accept direct HTTP REST requests now, take a peek at how packages/accounts-oauth-helper/oauth_server.js uses __meteor_bootstrap__.app to hook into the Connect middleware framework. This will work for now, but we don't promise that Meteor will always be powered by Connect :)

Supporting REST endpoints is on Meteor's roadmap.

So is file uploads (that's what binary type refers to).

查看更多
登录 后发表回答