serve

Creates a web server for serving static files (e.g., plugins) and plugin's metadata.

You can learn more about plugins metadata here.

Copy
devkit-scripts serve

Options

Copy
-p, --port <port>               use this port to serve the static files (default: 5000)

--no-serve-metadata             does not serve plugins' metadata

--metadata-path <metadataPath>  the path from where the metadata will be served (default: "/plugins.json")

--plugins <plugins>             list of the plugins to be served, comma separated

--from <from>                   relative path where the local plugins are located (default:
                                "path.join(process.cwd(), plugins"))

--env <env>                     specifies the environment, if not specified uses "process.env.NODE_ENV"

--cache-metadata                set if the served metadata should be a cache from startup or a live version (default:
                                false)

--disable-https                 the web server will be served as HTTP if this option is true (default: false)

-h, --help                      display help for command

Warning: The script serves HTTPS by default. This means that it requires accepted and non-expired server keys and certificates. Use Devkit Config to provide them.

API usage

The script can be used programmatically too using similar options as the CLI.

Copy
const { serve } = require('@pos-web/devkit-scripts');

serve({
  port: (String|Number)?,
  serveMetadata: Boolean?,
  metadataPath: String?,
  env: String?,
  plugins: [String]?,
  from: String?,
});

Dev mode

This script is useful to serve the compiled files and metadata of the plugins to be used by the Dev Mode.

For example, you can build a plugin keep watching, so every time you do a change in the code of the plugin, it will be re-compiled. Then use this script to serve the plugin and the plugin's metadata, and finally use the tunnel to use it at the Dev Mode.