-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 933244d
Showing
31 changed files
with
2,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = false | ||
indent_style = tab | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
$schema: 'https://json.schemastore.org/eslintrc', | ||
rules: { | ||
'no-underscore-dangle': 0, | ||
}, | ||
extends: ['@strapi-community', 'prettier'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes | ||
|
||
# Handle line endings automatically for files detected as text | ||
# and leave all files detected as binary untouched. | ||
* text=auto | ||
|
||
# | ||
# The above will handle all files NOT found below | ||
# | ||
|
||
# | ||
## These files are text and should be normalized (Convert crlf => lf) | ||
# | ||
|
||
# source code | ||
*.php text | ||
*.css text | ||
*.sass text | ||
*.scss text | ||
*.less text | ||
*.styl text | ||
*.js text eol=lf | ||
*.coffee text | ||
*.json text | ||
*.htm text | ||
*.html text | ||
*.xml text | ||
*.svg text | ||
*.txt text | ||
*.ini text | ||
*.inc text | ||
*.pl text | ||
*.rb text | ||
*.py text | ||
*.scm text | ||
*.sql text | ||
*.sh text | ||
*.bat text | ||
|
||
# templates | ||
*.ejs text | ||
*.hbt text | ||
*.jade text | ||
*.haml text | ||
*.hbs text | ||
*.dot text | ||
*.tmpl text | ||
*.phtml text | ||
|
||
# git config | ||
.gitattributes text | ||
.gitignore text | ||
.gitconfig text | ||
|
||
# code analysis config | ||
.jshintrc text | ||
.jscsrc text | ||
.jshintignore text | ||
.csslintrc text | ||
|
||
# misc config | ||
*.yaml text | ||
*.yml text | ||
.editorconfig text | ||
|
||
# build config | ||
*.npmignore text | ||
*.bowerrc text | ||
|
||
# Documentation | ||
*.md text | ||
LICENSE text | ||
AUTHORS text | ||
|
||
|
||
# | ||
## These files are binary and should be left untouched | ||
# | ||
|
||
# (binary is a macro for -text -diff) | ||
*.png binary | ||
*.jpg binary | ||
*.jpeg binary | ||
*.gif binary | ||
*.ico binary | ||
*.mov binary | ||
*.mp4 binary | ||
*.mp3 binary | ||
*.flv binary | ||
*.fla binary | ||
*.swf binary | ||
*.gz binary | ||
*.zip binary | ||
*.7z binary | ||
*.ttf binary | ||
*.eot binary | ||
*.woff binary | ||
*.pyc binary | ||
*.pdf binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will publish a package to NPM when a release is created | ||
|
||
name: Publish to NPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node v14 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install Yarn | ||
run: npm install -g yarn | ||
|
||
- name: Clean install deps | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Publish to NPM | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Don't check auto-generated stuff into git | ||
coverage | ||
node_modules | ||
stats.json | ||
|
||
# Cruft | ||
.DS_Store | ||
npm-debug.log | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# npm | ||
npm-debug.log | ||
|
||
# git | ||
.git | ||
.gitattributes | ||
|
||
# vscode | ||
.vscode | ||
|
||
# RC files | ||
.eslintrc.js | ||
.prettierrc.json | ||
|
||
# ignore files | ||
.prettierignore | ||
.gitignore | ||
|
||
# config files | ||
.editorconfig | ||
|
||
# github | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/prettierrc", | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"useTabs": true, | ||
"arrowParens": "always", | ||
"endOfLine": "lf", | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 @ComfortablyCoding | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# strapi-plugin-io | ||
|
||
A plugin for [Strapi CMS](https://github.com/strapi/strapi) that provides the ability for [Socket IO](https://socket.io) integration | ||
|
||
[![Downloads](https://img.shields.io/npm/dm/strapi-plugin-io?style=for-the-badge)](https://img.shields.io/npm/dm/strapi-plugin-io?style=for-the-badge) | ||
[![Install size](https://img.shields.io/npm/l/strapi-plugin-io?style=for-the-badge)](https://img.shields.io/npm/l/strapi-plugin-io?style=for-the-badge) | ||
[![Package version](https://img.shields.io/github/v/release/ComfortablyCoding/strapi-plugin-io?style=for-the-badge)](https://img.shields.io/github/v/release/ComfortablyCoding/strapi-plugin-io?style=for-the-badge) | ||
|
||
## Requirements | ||
|
||
The installation requirements are the same as Strapi itself and can be found in the documentation on the [Quick Start](https://strapi.io/documentation/developer-docs/latest/getting-started/quick-start.html) page in the Prerequisites info card. | ||
|
||
### Supported Strapi versions | ||
|
||
- v4.x.x | ||
|
||
**NOTE**: While this plugin may work with the older Strapi versions, they are not supported, it is always recommended to use the latest version of Strapi. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install strapi-plugin-io | ||
|
||
# or | ||
|
||
yarn add strapi-plugin-io | ||
``` | ||
|
||
## Configuration | ||
|
||
The plugin configuration is stored in a config file located at `./config/plugins.js`. | ||
|
||
### Sample configuration | ||
|
||
```javascript | ||
module.exports = ({ env }) => ({ | ||
// ... | ||
"io": { | ||
"enabled": true, | ||
"config": { | ||
"IOServerOptions" :{ | ||
"cors": { origin: "http://localhost:5000", methods: ["GET"] }, | ||
} | ||
"contentTypes": { | ||
"messages": *, | ||
"chats":["create"] | ||
}, | ||
}, | ||
}, | ||
// ... | ||
}); | ||
``` | ||
|
||
This will emit all events for the messages content type and only the create event for the chats content type. | ||
|
||
**IMPORTANT NOTE**: Make sure any sensitive data is stored in env files. | ||
|
||
## The Complete Plugin Configuration Object | ||
|
||
| Property | Description | Type | Default | Required | | ||
| -------- | ----------- | ---- | ------- | -------- | | ||
| IOServerOptions | The [Socket IO Server Options](https://socket.io/docs/v4/server-options). | Object | {} | No | ||
| contentTypes | The Content Types to emit events for. A "*" can be used to listen for all content types and events. | Object `or` String | {} | No | | ||
| contentTypes[apiName] | The events to listen for on the given content type. The apiName is the `singularName` in the [model schema](https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#model-schema). The value can be an array of events or a "*" to listen for all. | Array `or` String | N/A | Yes | | ||
|
||
### Currently Supported Emit events | ||
|
||
- `find` | ||
- `findOne` | ||
- `delete` | ||
- `create` | ||
- `update` | ||
- `publish` | ||
- `unpublish` | ||
- `bulkDelete` | ||
|
||
## Emit Syntax | ||
|
||
All events emitted have the following syntax `singularName:action`. | ||
|
||
## Bugs | ||
|
||
If any bugs are found please report them as a [Github Issue](https://github.com/ComfortablyCoding/strapi-plugin-io/issues) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/package", | ||
"name": "strapi-plugin-io", | ||
"version": "0.1.0", | ||
"description": "A plugin for Strapi CMS that provides the ability for Socket IO integration", | ||
"scripts": { | ||
"lint": "eslint . --fix", | ||
"format": "prettier --write **/*.{ts,js,json,yml}" | ||
}, | ||
"author": { | ||
"name": "@ComfortablyCoding", | ||
"url": "https://github.com/ComfortablyCoding" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "@ComfortablyCoding", | ||
"url": "https://github.com/ComfortablyCoding", | ||
"lead": true | ||
}, | ||
{ | ||
"name": "@hrdunn", | ||
"url": "https://github.com/hrdunn" | ||
} | ||
], | ||
"homepage": "https://github.com/ComfortablyCoding/strapi-plugin-slugify#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ComfortablyCoding/strapi-plugin-slugify.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ComfortablyCoding/strapi-plugin-slugify/issues" | ||
}, | ||
"dependencies": { | ||
"socket.io": "^4.4.1" | ||
}, | ||
"devDependencies": { | ||
"@strapi-community/eslint-config": "^0.2.0", | ||
"eslint": "^8.11.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"prettier": "^2.6.0" | ||
}, | ||
"peerDependencies": { | ||
"@strapi/strapi": "^4.1.5", | ||
"lodash": "^4.17.21", | ||
"yup": "^0.32.11" | ||
}, | ||
"strapi": { | ||
"name": "io", | ||
"displayName": "IO", | ||
"description": "A plugin for Strapi CMS that provides the ability for Socket IO integration", | ||
"kind": "plugin" | ||
}, | ||
"engines": { | ||
"node": ">=12.x.x <=16.x.x", | ||
"npm": ">=6.0.0" | ||
}, | ||
"keywords": [ | ||
"strapi", | ||
"strapi-plugin", | ||
"plugin", | ||
"strapi plugin", | ||
"socket io", | ||
"io" | ||
], | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const { IO } = require('./structures/IO'); | ||
const IOMiddleware = require('./middlewares/io'); | ||
|
||
module.exports = async ({ strapi }) => { | ||
const { getService } = require('./utils/getService'); | ||
const settingsService = getService({ name: 'settingsService' }); | ||
const settings = await settingsService.get(); | ||
|
||
// build settings structure | ||
const normalizedSettings = settingsService.build(settings); | ||
|
||
// reset plugin settings | ||
await settingsService.set(normalizedSettings); | ||
|
||
// setup io | ||
strapi.$io = new IO(normalizedSettings.IOServerOptions); | ||
IOMiddleware({ strapi }); | ||
}; |
Oops, something went wrong.