Skip to content

Commit

Permalink
qr code generate as file, added response type set, moved logo to asse…
Browse files Browse the repository at this point in the history
…ts and added others
  • Loading branch information
Matheus Cesar C. - Matsukii committed Oct 28, 2019
1 parent 714b37e commit 28f6a10
Show file tree
Hide file tree
Showing 10 changed files with 706 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
desktop.ini
other
code.svg
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Polarpod is a set of useful APIs for data extraction and processing, with a litt
(caution, the next part may contain THE100 spoilers!) <br>
The name came from "Polaris", "Escape-pod" and a a bit of 'south/north pole signs', Polaris is a space station from THE100 series.


## this API uses

* open-graph-crapper
Expand Down Expand Up @@ -85,6 +84,16 @@ response:

* SVG document

### SVG file return

_same as above just add /file, the code will be saved and avaliable at ... .com/code.svg_

**this is for a specific use case that i needed**

```http
https://polarpod.herokuapp.com/apis/qr/file?u=[URL]&d=[true]/[false]&w=[width]&c=[color]&bg=[background]
```

## Video URL parser

``` http
Expand Down
File renamed without changes
Binary file added assets/logo/app_frame_icon-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 111 additions & 0 deletions assets/logo/icon_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
222 changes: 222 additions & 0 deletions code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ const hasher = require('object-hash');
console.log(hasher.sha1(''));



var app = express();
var port = process.env.PORT || 3001;

app.use(cors())
app.use(express.static('public'));
app.use(express.static('assets'));
app.use(express.urlencoded({ extended: true }));

//* call router
Expand Down
328 changes: 328 additions & 0 deletions public/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/qrgen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = (params, saveFile = false) => {
module.exports = async(params, saveFile = false) => {
qrcode = require('qrcode-svg');

let colod = '#646464';
Expand Down Expand Up @@ -26,9 +26,9 @@ module.exports = (params, saveFile = false) => {

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

Expand Down
28 changes: 27 additions & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,36 @@ module.exports = (app, dir) => {
}

if(params.url == undefined){ res.status(400).send(resMsgs.qrNoParams) }
else{ return res.status(200).send(qrc(params)) }
else{ qrc(params).then(r => {
res.setHeader('Content-Type', 'image/svg+xml');
return res.status(200).send(r);
})}
})


/**
* @description svg qr code generator api AS FILE RETURN
*/
app.get('/apis/qr/file', function(req, res){
params = {
url : req.query.u,
dark : req.query.d,
width : req.query.w,
color : req.query.c,
bg : req.query.bg
}

if(params.url == undefined){ res.status(400).send(resMsgs.qrNoParams) }
else{
qrc(params, true).then(r => {
return res.status(200).json({status: 200, success: true, url: `${dir}/code.svg`});
});
}
});





/**
* @deprecated this will not be suported on feature, use /apis/video/meta
Expand Down

0 comments on commit 28f6a10

Please sign in to comment.