UPWARD JavaScript implementation
The upward-js package is a JavaScript implementation of an UPWARD server. This implementation is able to run as standalone server or as an Express/Connect middleware.
Installation
Use the following command add the upward-js dependency to your project:
yarn add @magento/upward-js
data-variant=info
data-slots=text
Usage
Use the command line, server API, or middleware API to launch the upward-js server.
Command line
You can make this package available to the command line by installing it globally:
yarn global add @magento/upward-js
Launch the server in the foreground using the following command:
upward-js-server
This command does not take arguments. Instead, it uses the following environment variables for configuration:
UPWARD_JS_UPWARD_PATHUPWARD_JS_BIND_LOCALUPWARD_JS_LOG_URLServer API
Require server from @magento/upward-js in your Node script to import the server into your project.
Example:
const { server } = require("@magento/upward-js");
const { app } = server({
upwardPath: "./my-upward-server.yml",
});
app.listen(8000);
Middleware API
Use middleware from @magento/upward-js to use the middleware into your project. This middleware is compatible with Express 4, Connect, and other frameworks that use this common pattern. It returns a Promise for a function which handles request/response pairs.
Example:
const express = require("express");
const { middleware } = require("@magento/upward-js");
const app = express();
app.use(otherMiddlewaresMaybe);
app.use(middleware("./my-upward-server.yml"));
You can also pass an IOAdapter as a second argument to the middleware.