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
const renderHtml = (blocks) => { | |
var html = blocks.map(block => { | |
switch (block.type) { | |
case 'code': | |
return `<pre><code>${ block.data.code }</pre></code>` | |
/** | |
* Original type is 'header' but I renamed the block to follow correct terminology: | |
* https://github.com/editor-js/header/issues/21 | |
*/ |
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
const Printer = require('pdfmake') | |
const axios = require('axios') | |
const path = require('path') | |
module.exports.pdf = async (req, res, next) => { | |
var printer = new Printer({ | |
Roboto: { | |
normal: path.resolve('src', 'fonts', 'Roboto.ttf'), | |
bold: path.resolve('src', 'fonts', 'Roboto-Bold.ttf'), | |
} |
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
const util = require('util') | |
const mysql = require('mysql') | |
const pool = mysql.createPool({ | |
connectionLimit: 10, | |
host: 'localhost', | |
user: 'root', | |
password: 'password', | |
database: 'my_database' | |
}) |
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
{ | |
"AF": "Afghanistan", | |
"AX": "Åland Islands", | |
"AL": "Albania", | |
"DZ": "Algeria", | |
"AS": "American Samoa", | |
"AD": "Andorra", | |
"AO": "Angola", | |
"AI": "Anguilla", | |
"AQ": "Antarctica", |
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
function slugify(string) { | |
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;' | |
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------' | |
const p = new RegExp(a.split('').join('|'), 'g') | |
return string.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters | |
.replace(/&/g, '-and-') // Replace & with 'and' | |
.replace(/[^\w\-]+/g, '') // Remove all non-word characters |