1.0.0 • Published 5 months ago

@magnolia/cli-create-rest-endpoint-plugin v1.0.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
5 months ago

CreateRestEndpointPlugin

A plugin for Magnolia CLI to create a rest endpoint in a light module

Installation

Using add-plugin

  1. 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()
      ]
    };
  2. To confirm that the plugin has been successfully installed, run:

    npm run mgnl -- create-rest-endpoint --help

Manually

  1. Run the following command in the project's root directory:
    npm install @magnolia/cli-create-rest-endpoint-plugin
  2. Manually add CreateRestEndpointPlugin to mgnl.config.js file:

    import CreateRestEndpointPlugin from "@magnolia/cli-create-rest-endpoint-plugin";
    
    export default {
      plugins: [
        new CreateRestEndpointPlugin()
      ]
    };
  3. To confirm that the plugin has been successfully installed, run:

    npm run mgnl -- create-rest-endpoint --help

Usage

Options

ShortLongDescription
-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--versionoutput the version number
-h--helpdisplay 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