简体   繁体   English

Remix.run 不使用 node.js 作为后端吗?

[英]Is Remix.run not using node.js as backend?

I'm very stoked about Remix.run , but there's one thing I really don't get.我对Remix.run非常兴奋,但有一件事我真的不明白。 In the technical explanation of the Framework it says:在框架的技术解释中,它说:

"While Remix runs on the server, it is not actually a server. It's just a handler that is given to an actual JavaScript server. It's built on the Web Fetch API instead of Node.js. This enables Remix to run in any Node.js server like Vercel, Netlify, Architect, etc. as well as non-Node.js environments like Cloudflare Workers and Deno Deploy." “虽然 Remix 在服务器上运行,但它实际上并不是一个服务器。它只是一个提供给实际 JavaScript 服务器的处理程序。它构建在 Web Fetch API 而不是 Node.js 之上。这使得 Remix 可以在任何 Node.js 中运行。 js 服务器,如 Vercel、Netlify、Architect 等,以及非 Node.js 环境,如 Cloudflare Workers 和 Deno Deploy。”

So.. is the backend a Node.js server or not?那么.. 后端是否是 Node.js 服务器? If not.. how can it execute JS in the backend?如果没有..它如何在后端执行JS? I think it a bit contradictory in the above explanation.我觉得上面的解释有点矛盾。

Remix is build with a lot of different adapters (not sure if that is the official term, but the idea of adapter is fitting). Remix 是用许多不同的适配器构建的(不确定这是否是官方术语,但适配器的想法很合适)。 This allows remix to swap out parts of its architecture to make Remix "fit".这允许 remix 交换其架构的一部分以使 Remix “适合”。 Examples of those adapter packages are remix-vercel, remix-express, and so on.这些适配器包的示例是 remix-vercel、remix-express 等。 They all serve te purpose of converting the different interfaces of the requests/events on those platforms to the request/response model of Remix (thus fetch).它们都用于将这些平台上的请求/事件的不同接口转换为 Remix 的请求/响应模型(因此是 fetch)。

All the previous mentioned adapters are Node-based environments, but Remix also has some adapters for non-node environments.前面提到的所有适配器都是基于节点的环境,但 Remix 也有一些用于非节点环境的适配器。 For example remix-clouflare-workers is an adapter designed to make the Cloudflare Workers environment play nice with Remix.例如,remix-clouflare-workers 是一个适配器,旨在使 Cloudflare Workers 环境与 Remix 配合得很好。 Cloudflare Workers are not running on Node, in fact its not even a server but just javascript functions being triggered by events. Cloudflare Workers 不在 Node 上运行,实际上它甚至不是服务器,而只是由事件触发的 javascript 函数。 Workers are running directly on the V8 Javascript Engine, the engine that is used by Chrome and Node to run JavaScript. Worker 直接在 V8 Javascript 引擎上运行,Chrome 和 Node 使用该引擎来运行 JavaScript。

So yes, Remix can run in NodeJS environments as a server, but because of its adapter architecture, it can also provide adapters for non NodeJS environments, and be (serverless) functions, etc.所以是的,Remix 可以作为服务器运行在 NodeJS 环境中,但是由于它的适配器架构,它还可以为非 NodeJS 环境提供适配器,以及成为(无服务器)功能等。

Fun fact, even remix-react is a seperate package (adapter), allowing the Remix team (or community) to implement adapters for other front end frameworks in the future!有趣的是,甚至 remix-react 也是一个单独的包(适配器),允许 Remix 团队(或社区)在未来为其他前端框架实现适配器!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM