Cogitoergo / strapi-voting

Voting system/plugin for Strapi v4
7 stars 1 forks source link

Strapi Voting

A plugin for Strapi Headless CMS that provides a simple voting system together with a moderation panel and logs.

✨ Features

⏳ Installation

(Use npm to install this plugin within your Strapi project (recommended). Install npm with these docs.)

npm install strapi-plugin-voting@latest

After successful installation you've to build a fresh package that includes plugin UI. To achieve that simply use:

npm run build
npm run develop

or just run Strapi in the development mode with --watch-admin option:

npm run develop --watch-admin

The Voting plugin should appear in the Plugins section of Strapi sidebar after you run app again.

🕸️ Public REST API specification

Vote

POST <host>/voting/api::<collection name>.<content type name>:<entity id>

Vote for a specific entity of a content type, for example Page with ID: 1.

Everytime You call this endpoint, on success, selected entities votes field will be increased by +1 and a user and a votelog will be created accordingly.

Example URL: https://localhost:1337/voting/api::page.page:1/vote

Example response body

{
  "createdAt": "2022-04-26T12:50:49.954Z",
  "id": 1,
  "publishedAt": "2022-04-26T12:50:50.600Z",
  "title": "Apple pie",
  "updatedAt": "2022-04-28T12:17:45.893Z",
  "votes": 64
}

Enjoy 🎉