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
| let Hedgehog = (function () { | |
| const speed = Symbol(); | |
| class Hedgehog { | |
| constructor(name) { | |
| this.name = name; | |
| this[speed] = 1000; // this is not directly accessible | |
| } | |
| zoom() { | |
| console.log(`${this.name} zooms with the speed of ${this[speed]} miles per second!`); |
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
| const { Client } = require('pg'); | |
| const client = new Client({ | |
| user: 'dbuser', | |
| host: 'database.server.com', | |
| database: 'mydb', | |
| password: 'secretpassword', | |
| port: 3211, | |
| }) | |
| client.connect(); |
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
| const client = require('./db'); | |
| exports.listSuggestions = (username, callback) => { | |
| client.query(`select * from suggestions where username = '${username}'`, (err, res) => { | |
| //... | |
| }); | |
| } | |
| exports.newSuggestion = (username, callback) => { |
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
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const { | |
| newSuggestion, | |
| listSuggestions, | |
| } = require('./movies'); | |
| const app = express() | |
| app.use(bodyParser.json()) | |
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
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const { | |
| newSuggestion, | |
| listSuggestions, | |
| } = require('./movies'); | |
| const app = express() | |
| app.use(bodyParser.json()) | |
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
| const { Client } = require('pg'); | |
| module.exports = (settings) => { | |
| const client = new Client(settings) | |
| client.connect(); | |
| return client; | |
| } |
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
| module.exports = (db) => { | |
| const movieSuggestion = {}; | |
| movieSuggestion.listSuggestions = (username, callback) => { | |
| db.query(`select * from suggestions where username = '${username}'`, (err, res) => { | |
| //... | |
| }); | |
| } | |
| movieSuggestion.newSuggestion = (username, callback) => { |
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
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const dbFactory = require('./db'); | |
| const movieFactory = require('./movies'); | |
| const app = express() | |
| app.use(bodyParser.json()) | |
| const dbSettings = { |
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
| const suggestion = new MovieSuggestion(db); |
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
| const suggestion = new MovieSuggestion(); | |
| suggestion.db = db; |