Skip to content

Commit

Permalink
* general code cleanup, * moved unused and/or old started modules to …
Browse files Browse the repository at this point in the history
…deprecated folder, * name updated, * keywords updated, * loading messages generator ready to use
  • Loading branch information
Matheus Cesar C. - Matsukii committed Oct 4, 2019
1 parent ea85240 commit f3a96dc
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
desktop.ini
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# opentk-apis
# PolarPod
A set of useful apis


Expand All @@ -20,7 +20,7 @@ A set of useful apis
# General usage

## Og tag getter
https://open-toolkit-api-tolls.herokuapp.com/apis/ogtags?u=[URL]<br><br>
https://polarpod.herokuapp.com/apis/ogtags?u=[URL]<br><br>

parameters:<br>
* u: url<br>
Expand All @@ -32,7 +32,7 @@ response:<br>


## SVG QR Code generator
https://open-toolkit-api-tolls.herokuapp.com/apis/qr?u=[URL]&d=[true]/[false]&w=[width]&c=[color]&bg=[background]<br><br>
https://polarpod.herokuapp.com/apis/qr?u=[URL]&d=[true]/[false]&w=[width]&c=[color]&bg=[background]<br><br>
parameters:<br>
* u: data<br>
* d: dark/light [true/false] (if true generates a lighet qr)<br>
Expand All @@ -46,15 +46,15 @@ response:<br>


## Video URL parser
http://opentk-apis.herokuapp.com/apis/vidurl?u=[URL]<br>
http://polarpod.herokuapp.com/apis/vidurl?u=[URL]<br>
params:<br>
* u: video url

response:<br>
* json

## Bad-word message filter
https://open-toolkit-api-tolls.herokuapp.com/apis/filter?msg=[message_to_filter]<br><br>
https://polarpod.herokuapp.com/apis/filter?msg=[message_to_filter]<br><br>
params:<br>
* msg: message

Expand Down
30 changes: 24 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
/**
* @description A toolkit to generate, get, filter and work with data!
* made with open npm libs and open to use
*
* @author Matsukii
*
*
* * Og tag getter
* https://polarpod.herokuapp.com/apis/ogtags?u=[url]
*
* * SVG QR Code generator
* https://polarpod.herokuapp.com/apis/qr?u=[url]&d=[true]/[false]&w=[width]&c=[color]&bg=[background]
*
* * video URL parser
* http://polarpod.herokuapp.com/apis/vidurl?u=[url]
*
* * Bad-word message filter
* https://polarpod.herokuapp.com/apis/filter?msg=[message_to_filter]
*
*/


var express = require("express");
const path = require('path');
const cors = require('cors')
const conf = require('./src/config');


// 0ac6kh - 1abz19
const hasher = require('object-hash');

// 0ac6kh
// 1abz19
console.log(hasher.sha1(''));


Expand All @@ -18,13 +38,11 @@ app.use(cors())
app.use(express.urlencoded({ extended: true }));

//* call router
var router = require(`${__dirname}/src/router`) (app, __dirname, conf);
var router = require(`${__dirname}/src/router`) (app, __dirname);

//* start server
var server = app.listen(port, function(){
var port = server.address().port;
console.log(`Server started at: http://localhost:${port}`);
});


// https://www.npmjs.com/package/open-graph-scraper
22 changes: 8 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
{
"name": "opentk-apis",
"name": "polarpod",
"version": "1.0.4",
"description": "a service to get open graph meta tags",
"description": "A set of useful APIs",
"main": "index.js",
"scripts": {
"test": "nodemon index.js",
"start": "node index.js"
},
"keywords": [
"og",
"open",
"graph",
"og",
"meta",
"tags",
"get",
"og",
"get",
"og",
"meta",
"tags"
"qr code api",
"open graph api",
"og tags api",
"video url parser api",
"bad word filter api"

],
"author": "Matsukii",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion src/blacklist.js → src/blacklists.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* @description blacklisted og get urls
*/
module.exports = {
items = [
urls = [

],
words = [

]
}
14 changes: 13 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@
* pks:
* * 0ac6kh
* * 1abz19
* ! unused at the moment
*
*
*/
module.exports = {
ogTags: {
defaultResponse: {
name: "",
title: "",
desc: "",
type: "",
url: "",
img: ""
}
},
pk: 'dd6e53fcf2a246b6e5ebba8527408efedab32e35',
pk2: 'a8c47e9311d2ba1964b91c91fe75b3ff1f6c6537',
codestorage:{
Expand All @@ -13,5 +26,4 @@ module.exports = {
pass: '',
usr: ''
}

}
3 changes: 2 additions & 1 deletion src/codedb-private.js → src/deprecated/codedb-private.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let cfg = require('./config');
let cfg = require('../config');
var mysql = require('mysql');
var c = mysql.createConnection({
host : cfg.codestorage.host,
Expand All @@ -10,6 +10,7 @@ var c = mysql.createConnection({

/**
* !DEPRECATED
* !IGNORE
* @deprecated unused module
* @param {String} key private keys to send use this code
* @param {Array/object} data data
Expand Down
File renamed without changes.
File renamed without changes.
36 changes: 30 additions & 6 deletions src/loadingMessages.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/**
* @author Matsukii
*
* @description random loading message generator
*/
module.exports = () => {
let loadingMessages = new loadingMessages();

let resp = {
allMsgs: loadingMessages.msgs,
genNorm: loadingMessages.newm(),
genHTML: loadingMessages.newmHTML(),
genAll: loadingMessages.newMessageAllTypes(),
genNorm: genAll.norm,
genHTML: genAll.html,
}

return resp;
Expand All @@ -13,8 +19,6 @@ module.exports = () => {

class loadingMessages{

// not breaking the line...

msgs = [
'Loading',
'Opening inventory...',
Expand Down Expand Up @@ -122,8 +126,11 @@ class loadingMessages{
*/
static newm(){
// return (new loadingMessages).message;
let msg = (new loadingMessages).message
msg = msg.replace('/*/', '');
let msg = (new loadingMessages).message;
while(msg.lastIndexOf('/*/') > -1){
msg = msg.replace('/*/', '');
}
// msg = msg.replace('/*/', '');
return `${msg}`;
}
/**
Expand All @@ -136,4 +143,21 @@ class loadingMessages{
}
return `${msg}`;
}

/**
* @returns all types of avaliable (plain text, html ready...)
*/
static newMessageAllTypes(){
let msg = (new loadingMessages).message;
let norm = msg;
let html = msg;
while(norm.lastIndexOf('/*/') > -1){
norm = norm.replace('/*/', '');
}
while(html.lastIndexOf('/*/') > -1){
html = html.replace('/*/', '<br>');
}

return {plain: norm, html: html}
}
}
38 changes: 12 additions & 26 deletions src/qrgen.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
module.exports = (params, saveFile = false) => {
qrcode = require('qrcode-svg');

// url ? dat = dat.split('*').join('/') : null
// url ? console.log(dat) : null


let colod = '#646464';

if(params.dark){
colod = '#CCCCCC'
}
else{
if(params.color != undefined){
colod = `#${params.color}`;
}
else{
colod = '#222222';
}
params.color != undefined ? colod = `#${params.color}` : colod = '#222222';
}

let bcg = 'transparent';
if(params.bg != undefined){
bcg = `#${params.bg}`;
}
else{
bcg = 'transparent'
}

params.bg != undefined ? bcg = `#${params.bg}` : bcg = 'transparent';

let config = {
content: params.url,
padding: 1,
width: params.width || 100,
height: params.width || 100,
color: colod,
background: bcg,
content: params.url,
width: params.width || 100,
height: params.width || 100,
}

var qr = new qrcode(config);

// if(saveFile){
// qr.save("sample.svg", function(error) {
// if (error) throw error;
// console.log("Done!");
// });
// }
// only for test
if(saveFile){
qr.save("sample.svg", function(error) {
if (error) throw error;
console.log("Done!");
});
}

return qr.svg()
}
9 changes: 9 additions & 0 deletions src/responseMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @description returned messages if any parameter is sended,
* later should be converted to html and send file instead
*/
module.exports = {
qrNoParams: `<title>qr gen API - Please send the params!</title> Please send params:<br> (need url/data at least)<br> corection level = M, padding = 1 (unavaliable to set)<br> u: url<br> d: dark (color = #cccccc, overrides color and bg param)<br> w: width and height<br> c: color (HEX, without the '#'), the default is #222222 and #CCCCCC<br> bg: background color (HEX, without the '#'), the default is transparent`,
filterNoMessage: 'No message given <br>use ?msg=(your_message_here)',

};
Loading

0 comments on commit f3a96dc

Please sign in to comment.