@magnolia/cli-create-rest-endpoint-plugin v1.0.0
CreateRestEndpointPlugin
A plugin for Magnolia CLI to create a rest endpoint in a light module
Installation
Using add-plugin
Run the following command in the project's root directory:
npm run mgnl -- add-plugin @magnolia/cli-create-rest-endpoint-plugin
The command will install the plugin, and automatically register the plugin in
mgnl.config.js
file:import CreateRestEndpointPlugin from "@magnolia/cli-create-rest-endpoint-plugin"; export default { plugins: [ new CreateRestEndpointPlugin() ] };
To confirm that the plugin has been successfully installed, run:
npm run mgnl -- create-rest-endpoint --help
Manually
- Run the following command in the project's root directory:
npm install @magnolia/cli-create-rest-endpoint-plugin
Manually add CreateRestEndpointPlugin to mgnl.config.js file:
import CreateRestEndpointPlugin from "@magnolia/cli-create-rest-endpoint-plugin"; export default { plugins: [ new CreateRestEndpointPlugin() ] };
To confirm that the plugin has been successfully installed, run:
npm run mgnl -- create-rest-endpoint --help
Usage
Options
Short | Long | Description |
---|---|---|
-d [path] | --destination [path] | specify the destination (subdirectory) of the rest endpoint file; defaults to "/delivery" or to value specified in mgnl.config.js file |
-w [name] | --workspace [name] | specify the workspace of the rest endpoint; defaults to "website" |
-lm [name] | --light-module [name] | set the light module for the rest endpoint; defaults to the directory specified in mgnl.config.js file |
-v | --version | output the version number |
-h | --help | display help for command |
Examples
Create rest endpoint
npm run mgnl -- create-rest-endpoint "myRestEndpoint"
This commands creates a new rest endpoint file in ${lightModulesPath}/${lightModule}/restEndpoints/delivery
folder called "myRestEndpoint".
If neither the lightModulesPath
nor the lightModule
property exists in mgnl.config.js, the plugin will prompt you to choose each.
Create rest endpoint "workspace" parameter
npm run mgnl -- create-rest-endpoint "myRestEndpoint" --workspace "myWorkspace"
This commands creates a new rest endpoint file in ${lightModulesPath}/${lightModule}/restEndpoints/delivery
folder called "myRestEndpoint", with workspace
set to myWorkspace
.
If neither the lightModulesPath
nor the lightModule
property exists in mgnl.config.js, the plugin will prompt you to choose each.
Create rest endpoint defined "workspace" and "destination" parameters
npm run mgnl -- create-rest-endpoint "myFooMapping" --workspace "myWorkspace" --destination "/foo"
This commands creates a new rest endpoint file in ${lightModulesPath}/${lightModule}/restEndpoints/foo
folder called "myRestEndpoint", with workspace
set to myWorkspace
.
If neither the lightModulesPath
nor the lightModule
property exists in mgnl.config.js, the plugin will prompt you to choose each.
Plugin Documentation
For detailed documentation of the plugin, please refer to Plugin Documentation
Magnolia CMS
This plugin is created to work with Magnolia CMS. For more information, please refer to Magnolia CMS Documentation
5 months ago