A flexible and generic plugin for triggering publications on multiple instances and hosting
by NovaGaïa.
Plugin dedicated to call multiple webhooks for publishing actions.
View on Strapi Marketplace
This plugin does several things:
Copy the following code and run from your terminal
1npm i nova-publisher
or
1yarn add nova-publisher
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// ./config/plugins.js
2// if change, run `npm run build --clean`
3
4module.exports = ({ env }) => ({
5 // ...
6 'nova-publisher': {
7 enabled: true,
8 config: {
9 dateConfiguration: {
10 dateLocaleString: 'fr-FR', // sample
11 options: {
12 // sample
13 timeZone: 'Europe/Paris',
14 timeZoneName: 'short',
15 hour12: false,
16 },
17 },
18 addPublishComponent: false,
19 instances: [
20 {
21 name: env('INSTANCE_0_NAME'),
22 icon: '🚀', // sample
23 enabled: env('INSTANCE_0_ENABLED'),
24 cron: env('INSTANCE_0_USE_CRON'),
25 url: env('INSTANCE_0_URL'),
26 web_url: env('INSTANCE_0_WEB_URL'),
27 method: 'post',
28 headers: {
29 // sample
30 Authorization: `Beaver ${env('INSTANCE_0_BEAVER')}`,
31 },
32 },
33 {
34 name: env('INSTANCE_1_NAME'),
35 icon: '👁️', // sample
36 enabled: env('INSTANCE_1_ENABLED'),
37 cron: env('INSTANCE_1_USE_CRON'),
38 url: env('INSTANCE_1_URL'),
39 web_url: env('INSTANCE_1_WEB_URL'),
40 method: 'post',
41 headers: {
42 // sample
43 Authorization: `Beaver ${env('INSTANCE_1_BEAVER')}`,
44 },
45 },
46 ],
47 },
48 },
49 // ...
50});
Variable | Description | Type | Default value |
---|---|---|---|
dateConfiguration | Configuration of the date format in the messages, see (1). | Object | (See below) |
dateConfiguration.dateLocaleString | Date local to use, see (1) | String | en-EN |
dateConfiguration.options | Date formatting options, see (1) | Object | { timeZone: 'Europe/London', timeZoneName: 'short', hour12: false } |
addPublishComponent | Adds the helper component to manage more finely the publications. | Boolean | false |
instances | Configuration of the instances where to launch the publication. | Object | (See below) |
instances.name * | Name of the intance. | String | Mandatory |
instances.icon * | Emoji. | String | Mandatory |
instances.enabled * | Enables or disables the display of the instance. | Boolean | Mandatory |
instances.url * | Target publish url. | String | Mandatory |
instances.web_url | URL of your instance to open it from Nova-Publisher page. | String | - |
instances.method | POST ou GET . | String | POST |
instances.headers | Headers to send, see (2). | Object | - |
* Mandatory field
(1) Pour
dateConfiguration
, see Date.prototype.toLocaleString()(2) pour
instances.headers
, see HTTP headers
Enabled internal Strapi CRON
1// ./config/server.js
2module.exports = ({ env }) => ({
3 // ...
4 cron: {
5 enabled: true,
6 },
7 // ...
8});
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, see
instances.enabled`.
Click on Publish
to initiate the action.
Publish Status
displays Build started at <date>
.When the action returns, the Publish Status
will be updated with a success or error message and the time.
<date>
.<date>
.<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.
npm install nova-publisher
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.