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 mysql = require("mysql"); | |
const async = require('async') | |
const dbConfig = require("./tables.js").tables; | |
const db = mysql.createPool({ | |
host: "localhost", | |
user: dbConfig.username, | |
password: dbConfig.password, | |
database: "click2magic", | |
multipleStatements:true | |
}); |
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 express = require('express'); | |
const path = require('path'); | |
const util = require('util'); | |
const fs = require('fs'); | |
const morgan = require('morgan') | |
const https = require('https') | |
const app = express(); | |
//static | |
app.use(express.static(path.join(__dirname,'./public'))); |
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
// Escapes HTML characters in a template literal string, to prevent XSS. | |
// See https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content | |
function sanitizeHTML(strings) { | |
const entities = {'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}; | |
let result = strings[0]; | |
for (let i = 1; i < arguments.length; i++) { | |
result += String(arguments[i]).replace(/[&<>'"]/g, (char) => { | |
return entities[char]; | |
}); | |
result += strings[i]; |
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 http = require('http'); | |
http.createServer((req,res)=>{ | |
let route = req.url; | |
if(route == '/'){ | |
res.end('root route.') | |
}else if(route == '/hello'){ | |
res.end('hello') | |
} | |
}).listen(3000,()=>{console.log('listening on a domain')}) |
NewerOlder