Edit in GitHubLog an issue

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:

Copied to your clipboard
yarn add @magento/upward-js

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:

Copied to your clipboard
yarn global add @magento/upward-js

Launch the server in the foreground using the following command:

Copied to your clipboard
upward-js-server

This command does not take arguments. Instead, it uses the following environment variables for configuration:

VariableRequiredDescription
UPWARD_JS_UPWARD_PATHYesThe path to the server definition file.
UPWARD_JS_BIND_LOCALYesThis must be set to 1.
UPWARD_JS_LOG_URLNoPrints the bound URL to stdout if set to 1.

Server API#

Require server from @magento/upward-js in your Node script to import the server into your project.

Example:

Copied to your clipboard
1const { server } = require("@magento/upward-js");
2
3const { app } = upward({
4 upwardPath: "./my-upward-server.yml",
5});
6
7app.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:

Copied to your clipboard
1const express = require("express");
2const { middleware } = require("@magento/upward-js");
3
4const app = express();
5
6app.use(otherMiddlewaresMaybe);
7
8app.use(middleware("./my-upward-server.yml"));

You can also pass an IOAdapter as a second argument to the middleware.

  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.