Strapi plugin logo for Nova Publisher

Nova Publisher

A flexible and generic plugin for triggering publications on multiple instances and hosting

thumbnail for Nova Publisher
Logo NovaGaïa

Strapi plugin Nova Publisher

by NovaGaïa.

Plugin dedicated to call multiple webhooks for publishing actions.

View on Strapi Marketplace

This plugin does several things:

  1. Flexible publishing, a URL, in POST or GET, with or without headers ;
  2. Allows you to publish to multiple instances (Prod, Preview, etc.);
  3. Adds a publishing component to override Strapi's state management, useful with CRON in particular (no obligation to use);
  4. Activate a cron that will update the active instances that need to be rebuilt every day at 1am (no obligation to use).

1. Installation

a. How to Install

Copy the following code and run from your terminal

1
npm i nova-publisher

or

1
yarn add nova-publisher

b. Configuration

I. plugins.js

The configuration is done in the environment variables and in the plugin configuration.

Here there are two instances configured, but you can add more or put only one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ./config/plugins.js
// if change, run `npm run build --clean`

module.exports = ({ env }) => ({
  // ...
  'nova-publisher': {
    enabled: true,
    config: {
      dateConfiguration: {
        dateLocaleString: 'fr-FR', // sample
        options: {
          // sample
          timeZone: 'Europe/Paris',
          timeZoneName: 'short',
          hour12: false,
        },
      },
      addPublishComponent: false,
      instances: [
        {
          name: env('INSTANCE_0_NAME'),
          icon: '🚀', // sample
          enabled: env('INSTANCE_0_ENABLED'),
          cron: env('INSTANCE_0_USE_CRON'),
          url: env('INSTANCE_0_URL'),
          web_url: env('INSTANCE_0_WEB_URL'),
          method: 'post',
          headers: {
            // sample
            Authorization: `Beaver ${env('INSTANCE_0_BEAVER')}`,
          },
        },
        {
          name: env('INSTANCE_1_NAME'),
          icon: '👁️', // sample
          enabled: env('INSTANCE_1_ENABLED'),
          cron: env('INSTANCE_1_USE_CRON'),
          url: env('INSTANCE_1_URL'),
          web_url: env('INSTANCE_1_WEB_URL'),
          method: 'post',
          headers: {
            // sample
            Authorization: `Beaver ${env('INSTANCE_1_BEAVER')}`,
          },
        },
      ],
    },
  },
  // ...
});
VariableDescriptionTypeDefault value
dateConfigurationConfiguration of the date format in the messages, see (1).Object(See below)
dateConfiguration.dateLocaleStringDate local to use, see (1)Stringen-EN
dateConfiguration.optionsDate formatting options, see (1)Object{ timeZone: 'Europe/London', timeZoneName: 'short', hour12: false }
addPublishComponentAdds the helper component to manage more finely the publications.Booleanfalse
instancesConfiguration of the instances where to launch the publication.Object(See below)
instances.name *Name of the intance.StringMandatory
instances.icon *Emoji.StringMandatory
instances.enabled *Enables or disables the display of the instance.BooleanMandatory
instances.url *Target publish url.StringMandatory
instances.web_urlURL of your instance to open it from Nova-Publisher page.String-
instances.methodPOST ou GET.StringPOST
instances.headersHeaders to send, see (2).Object-

* Mandatory field

(1) Pour dateConfiguration, see Date.prototype.toLocaleString()

(2) pour instances.headers, see HTTP headers

II. server.js

Enabled internal Strapi CRON

1
2
3
4
5
6
7
8
// ./config/server.js
module.exports = ({ env }) => ({
  // ...
  cron: {
    enabled: true,
  },
  // ...
});

2. Utilisation

preview

Warning Before any use, the `Publication Status' displays a generic message.

Note The Publication Status' message is not stored in the database (in case it is copied to other instances), but in a file under./public/status-${instancesid.name}.txt`.

If several instances are configured, the block is repeated.

Auto-publish enabledindicates whether CRON is enabled for this instance, seeinstances.enabled`.

Publish

Click on Publish to initiate the action.

  • The button is disabled while waiting (if you refresh the page, the button will be enabled again).
  • The Publish Status displays Build started at <date>.
  • When the action returns, the button is reactivated.

Return management

When the action returns, the Publish Status will be updated with a success or error message and the time.

  • Release in progress: Build started at <date>.
  • Success: Last build with success at <date>.
  • Error: Last build in error at <date>.

In case of an error, a Toast is displayed with the error message returned by the remote server, which you can find in the Strapi server logs.


Buy Me A Coffee

Install now

npm install nova-publisher

STATS

1 GitHub star1 weekly download

Last updated

482 days ago

Strapi Version

4.0.0 and above

Author

github profile image for NovaGaïa
NovaGaïa

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.