Create REST endpoint plugin
A plugin to create a REST endpoint configuration file in a light module.
Package name |
|
Repository link |
|
Latest version |
|
Changelog link |
Installing
The plugin doesn’t come pre-installed with Magnolia CLI.
You must add it to the mgnl.config.js
project file.
The plugin is installed automatically by the Jumpstart plugin if it is defined in a project template. |
With add-plugin
Run the following command in the project folder.
npm run mgnl -- add-plugin @magnolia/cli-create-rest-endpoint-plugin
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command automatically downloads, installs, and registers the plugin in the mgnl.config.js
file.
Manually
-
Run the following command in the project folder.
npm install @magnolia/cli-create-rest-endpoint-plugin
-
Modify the
mgnl.config.js
file accordingly.import CreateRestEndpointPlugin from "@magnolia/cli-create-rest-endpoint-plugin"; export default { plugins: [ new CreateRestEndpointPlugin() ] };
Usage
Options
Form (short and long) | Description |
---|---|
|
Sets the destination (subdirectory) of the REST endpoint file.
By default, |
|
Sets the workspace name for the endpoint.
Uses |
|
Sets a light module for the REST endpoint.
By default, uses the directory specified in the |
|
Displays the version. |
|
Displays help information. |
Examples
For the following examples, it’s assumed that the mgnl.config.js
file looks like this:
import CreateRestEndpointPlugin from "@magnolia/cli-create-rest-endpoint-plugin";
export default {
plugins: [
new CreateRestEndpointPlugin()
]
};
For more information, see Configuring plugins.
Endpoint with default values
npm run mgnl -- create-rest-endpoint "my-rest-endpoint"
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command creates a REST endpoint called my-rest-endpoint
with the website
workspace in the ./restEndpoints/delivery
folder.
It also checks the light module folder for component templates and creates reference resolvers for the properties it finds.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the endpoint configuration file will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Endpoint with a custom workspace name
npm run mgnl -- create-rest-endpoint "my-rest-endpoint" --workspace "foo"
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command creates a REST endpoint called my-rest-endpoint
with the foo
workspace in the ./restEndpoints/delivery
folder.
It also checks the light module folder for content types and apps with such a workspace and creates reference resolvers for the properties it finds.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the endpoint configuration file will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Endpoint with custom workspace
and destination
values
npm run mgnl -- create-rest-endpoint "my-rest-endpoint" --workspace "foo" --destination "/zig"
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command creates a REST endpoint called my-rest-endpoint
with the foo
workspace in the ./restEndpoints/zig
folder.
It also checks the light module folder for content types and apps with such a workspace and creates reference resolvers for the properties it finds.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the endpoint mapping will be created.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Endpoint in a specific light module
npm run mgnl -- create-rest-endpoint "my-rest-endpoint" --light-module "my-lm"
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command creates a REST endpoint called my-rest-endpoint
with the website
workspace in the ./restEndpoints/delivery
folder.
It also checks the light module folder for component templates and creates reference resolvers for the properties it finds.
The plugin prompts you to choose a directory containing all light modules.
If the my-lm
light module doesn’t exist yet in the light modules directory, the plugin will prompt you to select another one.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Configuration
In mgnl.config.js
, you can set the following properties to predefine the plugin’s behavior.
Global properties
Property name | Description |
---|---|
|
The path to a directory containing all light modules. |
|
The name of a light module where the endpoints will be created. Alternative forms: |
Plugin properties
Property name | Description |
---|---|
|
The name of a light module where the endpoints will be created. Alternative forms: |
|
The path to a custom Alternative forms: |
For more information, see Configuring plugins.