This file contains hidden or 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
| // Dependencies | |
| const express = require('express'); | |
| const proxy = require('http-proxy-middleware'); | |
| // Config | |
| const { routes } = require('./config.json'); | |
| const app = express(); | |
| for (route of routes) { |
This file contains hidden or 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
| { | |
| "routes": [ | |
| { | |
| "route": "/project1", | |
| "address": "http://localhost:1001" | |
| }, | |
| { | |
| "route": "/project2", | |
| "address": "http://localhost:1002" | |
| } |
This file contains hidden or 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
| // Dependencies | |
| const fs = require('fs'); | |
| const http = require('http'); | |
| const https = require('https'); | |
| const express = require('express'); | |
| const app = express(); | |
| // Certificate | |
| const privateKey = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/privkey.pem', 'utf8'); |
This file contains hidden or 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
| // Dependencies | |
| const express = require('express'); | |
| // Configure & Run the http server | |
| const app = express(); | |
| app.use(express.static(__dirname, { dotfiles: 'allow' } )); | |
| app.listen(80, () => { | |
| console.log('HTTP server running on port 80'); |
This file contains hidden or 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
| // Dependencies | |
| const express = require('express'); | |
| const bodyparser = require('body-parser'); | |
| // Configuration | |
| const app = express(); | |
| app.use(bodyparser.json()); | |
| // Webhook route | |
| app.post('/webhook', (req, res) => { |
This file contains hidden or 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
| // Dependencies and stuff, who cares ? | |
| // ES6 way | |
| (async () => { | |
| // Browser launched | |
| const browser = await puppeteer.launch(); | |
| // New tab created | |
| const tab = await browser.newPage(); |
This file contains hidden or 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
| <?php | |
| // Could have broken request clauses line by line | |
| // SELECT X FROM Y WHERE Z | |
| // -> | |
| // SELECT X | |
| // FROM Y | |
| // WHERE Z | |
| final class RequestHolder { | |
| // Query a list of users without ordering |
This file contains hidden or 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
| <?php | |
| // CodeIgniter coding style with plain queries, easy to read | |
| $users = $this->db->query('SELECT * FROM Users')->result(); | |
| $cities = $this->db->query('SELECT * FROM Cities')->result(); | |
| $usersWithCity = $this->db->query('SELECT U.*, C.city_name FROM Users U LEFT JOIN Cities C ON U.id_user = C.id_user')->result(); |
This file contains hidden or 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
| // A dead-easy data structure representing a database | |
| let ArticlesDatabase = { | |
| content: [ | |
| { | |
| 'id': 1, | |
| 'title': 'Insane prank, I broke my leg watch this' | |
| }, | |
| { | |
| 'id': 2, | |
| 'title': 'Cops arrested me, discover why' |
This file contains hidden or 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
| // A dead-easy data structure representing a database | |
| let ArticlesDatabase = { | |
| articles: [ | |
| { | |
| 'id': 1, | |
| 'title': 'Insane prank, I broke my leg watch this' | |
| }, | |
| { | |
| 'id': 2, | |
| 'title': 'Cops arrested me, discover why' |