This repository has been archived by the owner on Jan 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
aa51577
commit 65f8038
Showing
21 changed files
with
2,630 additions
and
2 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,201 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module", | ||
"ecmaFeatures": { "jsx": true} | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"jquery": true, | ||
"es6": true | ||
}, | ||
"globals": { | ||
"$": true, | ||
"router": true, | ||
"express": true, | ||
"appRootDirectory": true, | ||
"req": true, | ||
"next": true, | ||
"res": true, | ||
"govuk": true, | ||
"logger": true, | ||
"config": true, | ||
"gulpPaths" : true | ||
}, | ||
"rules": { | ||
"strict": [2, "global" ], | ||
"init-declarations": 0, | ||
"no-catch-shadow": 0, | ||
"no-delete-var": 1, | ||
"no-label-var": 2, | ||
"no-shadow-restricted-names": 2, | ||
"no-shadow": [ 2, { "builtinGlobals": false, "hoist": "all" }], | ||
"no-undef-init": 1, | ||
"no-undef": 2, | ||
"no-undefined": 2, | ||
"no-unused-vars": [1, { "vars": "all", "args": "after-used"}], | ||
"no-use-before-define": 1, | ||
"comma-dangle": [2, "never"], | ||
"no-cond-assign": [2, "except-parens"], | ||
"no-console": 1, | ||
"no-constant-condition": 2, | ||
"no-control-regex": 2, | ||
"no-debugger": 2, | ||
"no-dupe-args": 2, | ||
"no-dupe-keys": 2, | ||
"no-duplicate-case": 2, | ||
"no-empty-character-class": 2, | ||
"no-empty": 2, | ||
"no-ex-assign": 2, | ||
"no-extra-boolean-cast": 2, | ||
"no-extra-parens": [0, "all"], | ||
"no-extra-semi": 1, | ||
"no-func-assign": 2, | ||
"no-inner-declarations": [2, "both"], | ||
"no-invalid-regexp": 2, | ||
"no-irregular-whitespace": [2, { "skipRegExps": true }], | ||
"no-negated-in-lhs": 2, | ||
"no-obj-calls": 2, | ||
"no-regex-spaces": 2, | ||
"no-sparse-arrays": 2, | ||
"no-unreachable": 2, | ||
"use-isnan": 2, | ||
"valid-jsdoc": 0, | ||
"valid-typeof": 2, | ||
"no-unexpected-multiline": 2, | ||
"accessor-pairs": [2, { "getWithoutSet": false, "setWithoutGet": true}], | ||
"block-scoped-var": 2, | ||
"complexity": [1, 10], | ||
"consistent-return": 2, | ||
"curly": [2, "all"], | ||
"default-case": 2, | ||
"dot-notation": [ 2, { "allowKeywords": true, "allowPattern": ""}], | ||
"dot-location": [2, "property"], | ||
"eqeqeq": 2, | ||
"guard-for-in": 2, | ||
"no-alert": 1, | ||
"no-caller": 2, | ||
"no-div-regex": 2, | ||
"no-else-return": 0, | ||
"no-eq-null": 2, | ||
"no-eval": 2, | ||
"no-extend-native": 2, | ||
"no-extra-bind": 2, | ||
"no-fallthrough": 1, | ||
"no-floating-decimal": 1, | ||
"no-implicit-coercion": [1, { "boolean": false, "number": true, "string": false}], | ||
"no-implied-eval": 2, | ||
"no-invalid-this": 0, | ||
"no-iterator": 2, | ||
"no-labels": 2, | ||
"no-lone-blocks": 2, | ||
"no-loop-func": 2, | ||
"no-multi-spaces": [1, { "exceptions": { "VariableDeclarator": true, "ImportDeclaration": true, "AssignmentExpression": true, "ObjectExpression": true }}], | ||
"no-multi-str": 2, | ||
"no-native-reassign": 2, | ||
"no-new-func": 2, | ||
"no-new-wrappers": 2, | ||
"no-new": 2, | ||
"no-octal-escape": 2, | ||
"no-octal": 2, | ||
"no-param-reassign": 0, | ||
"no-process-env": 0, | ||
"no-proto": 2, | ||
"no-redeclare": [ 2, { "builtinGlobals": true}], | ||
"no-return-assign": [2, "except-parens"], | ||
"no-script-url": 2, | ||
"no-self-compare": 0, | ||
"no-sequences": 2, | ||
"no-throw-literal": 2, | ||
"no-unused-expressions": 2, | ||
"no-useless-call": 1, | ||
"no-useless-concat": 2, | ||
"no-void": 2, | ||
"no-warning-comments": [0, { "terms": [ "todo", "fixme"], "location": "start"}], | ||
"no-with": 2, | ||
"radix": 1, | ||
"vars-on-top": 1, | ||
"wrap-iife": [2, "inside"], | ||
"yoda": [1, "never"], | ||
"array-bracket-spacing": [2, "never"], | ||
"block-spacing": [1, "always"], | ||
"brace-style": [2, "1tbs"], | ||
"camelcase": [1, { "properties": "always"}], | ||
"comma-spacing": [1, { "before": false, "after": true}], | ||
"comma-style": [1, "last"], | ||
"computed-property-spacing": [2, "never"], | ||
"consistent-this": [1, "self"], | ||
"eol-last": 1, | ||
"func-names": 1, | ||
"func-style": 0, | ||
"id-length": 0, | ||
"id-match": 0, | ||
"indent": [1, 4], | ||
"jsx-quotes": [1, "prefer-single"], | ||
"key-spacing": [1, { "beforeColon": true, "afterColon": true, "mode": "minimum"}], | ||
"keyword-spacing": [2, {"before": true, "after": true}], | ||
"lines-around-comment": 0, | ||
"linebreak-style": 0, | ||
"max-nested-callbacks": [1, 3], | ||
"new-cap": [1, { "newIsCap": true, "capIsNew": true}], | ||
"new-parens": 1, | ||
"newline-after-var": [0, "always"], | ||
"no-array-constructor": 1, | ||
"no-continue": 1, | ||
"no-inline-comments": 0, | ||
"no-lonely-if": 1, | ||
"no-mixed-spaces-and-tabs": 2, | ||
"no-multiple-empty-lines": [1, { "max": 1}], | ||
"no-nested-ternary": 1, | ||
"no-new-object": 1, | ||
"no-restricted-syntax": 0, | ||
"no-spaced-func": 1, | ||
"no-ternary": 0, | ||
"no-trailing-spaces": [1, { "skipBlankLines": false}], | ||
"no-underscore-dangle": 0, | ||
"no-unneeded-ternary": [1, { "defaultAssignment": true}], | ||
"object-curly-spacing": [1, "never"], | ||
"one-var": [0, "never"], | ||
"operator-assignment": 0, | ||
"operator-linebreak": [1, "after"], | ||
"padded-blocks": [1, "never"], | ||
"quote-props": [1, "as-needed", { "keywords": false, "unnecessary": false, "numbers": true}], | ||
"quotes": [2, "single", "avoid-escape"], | ||
"require-jsdoc": 0, | ||
"semi-spacing": [1, { "before": false, "after": true}], | ||
"semi": [1, "always"], | ||
"sort-vars": 0, | ||
"space-before-blocks": [1, "always"], | ||
"space-before-function-paren": [1, { "anonymous": "never", "named": "never"}], | ||
"space-in-parens": [1, "never"], | ||
"space-infix-ops": [1, { "int32Hint": false}], | ||
"space-unary-ops": [1, { "words": true, "nonwords": false}], | ||
"wrap-regex": 2, | ||
"arrow-parens": [2, "always"], | ||
"arrow-spacing": [2, { "before": true, "after": true}], | ||
"constructor-super": 2, | ||
"generator-star-spacing": [2, { "before": false, "after": true}], | ||
"no-class-assign": 2, | ||
"no-const-assign": 2, | ||
"no-dupe-class-members": 0, | ||
"no-this-before-super": 2, | ||
"no-var": 0, | ||
"object-shorthand": 0, | ||
"prefer-arrow-callback": 0, | ||
"prefer-const": 1, | ||
"prefer-spread": 0, | ||
"prefer-reflect": 0, | ||
"prefer-template": 0, | ||
"require-yield": 2, | ||
"callback-return": 1, | ||
"global-require": 0, | ||
"handle-callback-err": 1, | ||
"no-mixed-requires": 1, | ||
"no-new-require": 1, | ||
"no-path-concat": 1, | ||
"no-process-exit": 1, | ||
"no-restricted-modules": 1, | ||
"no-sync": 0 | ||
} | ||
} |
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 |
---|---|---|
|
@@ -102,3 +102,9 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
#Apple OS | ||
.DS_Store | ||
.sublime-project | ||
.sublime-workspace | ||
npm-debug.log |
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) 2020 Vincent Pickering | ||
|
||
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 @@ | ||
web: node ./bin/server.js |
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 |
---|---|---|
@@ -1,2 +1,25 @@ | ||
# mc-syndication | ||
The Mastr Cntrl Microservice responsible for syndicating content | ||
# About | ||
|
||
Mastr Cntrl Syndication is a part of a Microservices suite of [IndieWeb](https://indieweb.org/) tools. | ||
|
||
- [Mastr Cntrl](https://github.com/vipickering/mastr-cntrl) is the Microservice responsible for recieving Micropub and social content. | ||
- [MC Webmebtion](https://github.com/vipickering/mc-webmention) is the webmention service. Designed to send and recieve [Webmentions](https://indieweb.org/Webmention). | ||
- [MC Syndication](https://github.com/vipickering/mc-syndicate-content) is the syndication service. Designed to syndicate content to other platforms. | ||
|
||
## Purpose | ||
|
||
The service polls a JSON feed once every 10 mins (interval configurable) to check for content flagged for syndication that has not been sent. | ||
If it finds any new content it will: | ||
|
||
1. Loop through the items and identify the syndication preferences. | ||
2. Pass the syndication data on to its handler | ||
3. Syndicate the content | ||
4. Update the last sent time. | ||
|
||
Otherwise it will do nothing and check again at your specified interval. | ||
|
||
## Install | ||
|
||
1. Download the content and install with ```npm install```. | ||
2. Create your ```.env``` file and use the ```sample.env``` as your guide. | ||
3. Run with ```npm start``` |
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,25 @@ | ||
/*eslint no-process-env: "off"*/ | ||
const config = {}; | ||
|
||
config.github = { | ||
'postUrl' : process.env.GITHUB_HOST + '/repos/' + process.env.GITHUB_NAME + '/' + process.env.GITHUB_REPO + '/contents', | ||
'key' : process.env.GITHUB_KEY, | ||
'repo' : process.env.GITHUB_REPO, | ||
'name' : process.env.GITHUB_NAME, | ||
'user' : process.env.GITHUB_USER, | ||
'email' : process.env.GITHUB_USER_EMAIL, | ||
'host' : process.env.GITHUB_HOST, | ||
'branch' : process.env.GITHUB_BRANCH | ||
}; | ||
|
||
config.api = { | ||
'port' : process.env.API_PORT | ||
}; | ||
|
||
config.syndicate = { | ||
'feed' : process.env.SYNDICATION_FEED, | ||
'interval' : process.env.INTERVAL_DURATION, | ||
'lastSentPath' : process.env.SYNDICATION_LAST_PATH | ||
}; | ||
|
||
module.exports = config; |
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,4 @@ | ||
{ | ||
"service" : "MC Syndicate Content", | ||
"purpose" : "IndieWeb Syndication MicroService" | ||
} |
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,51 @@ | ||
/* | ||
Update or Create a file in the Github API | ||
https://developer.github.com/v3/repos/contents/#create-or-update-a-file | ||
*/ | ||
|
||
const logger = require(appRootDirectory + '/app/logging/bunyan'); | ||
const axios = require('axios'); | ||
const base64 = require('base64it'); | ||
const config = require(appRootDirectory + '/app/config.js'); | ||
const github = config.github; | ||
const webmention = config.webmention; | ||
|
||
exports.update = function update(payload, sha) { | ||
const payloadEncoded = base64.encode(payload); | ||
const urlDestination = `${github.postUrl}/${webmention.lastSentPath}`; | ||
const messageContent = ':robot: last sent datetime updated'; | ||
|
||
logger.info(urlDestination); | ||
|
||
(async () => { | ||
try { | ||
const options = { | ||
method : 'PUT', | ||
url : urlDestination, | ||
headers : { | ||
Authorization : `token ${github.key}`, | ||
'Content-Type' : 'application/vnd.github.v3+json; charset=UTF-8', | ||
'User-Agent' : github.name | ||
}, | ||
data : { | ||
message : messageContent, | ||
content : payloadEncoded, | ||
sha : sha, | ||
committer : { | ||
name : github.user, | ||
email : github.email | ||
} | ||
} | ||
}; | ||
|
||
const response = await axios(options); | ||
// logger.info(response); | ||
logger.info('GIT UPDATE Success'); | ||
} catch (error) { | ||
logger.error(error); | ||
logger.error(error.response); | ||
logger.info(error.response.data.message); | ||
logger.info('GIT PUT Failed'); | ||
} | ||
})(); | ||
}; |
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,38 @@ | ||
const bunyan = require('bunyan'); | ||
const streamsContent = [ | ||
{ | ||
stream : process.stdout, | ||
level : 'debug' | ||
}, | ||
{ | ||
type : 'rotating-file', | ||
path : './logs/error.log', | ||
level : 'error', | ||
period : '1d', | ||
count : 3 | ||
}, | ||
{ | ||
type : 'rotating-file', | ||
path : './logs/debug.log', | ||
level : 'debug', | ||
period : '1d', | ||
count : 3 | ||
}, | ||
{ | ||
type : 'rotating-file', | ||
path : './logs/fatal.log', | ||
level : 'fatal', | ||
period : '1d', | ||
count : 3 | ||
} | ||
]; | ||
|
||
const logger = bunyan.createLogger({ | ||
name : 'MC-SendWebmentions', | ||
serializers : { | ||
err : bunyan.stdSerializers.err | ||
}, | ||
streams : streamsContent | ||
}); | ||
|
||
module.exports = logger; |
Oops, something went wrong.