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 fs = require('fs/promises'); | |
(async () => { | |
const data = await fs.readFile('LICENSE.md'); | |
try { | |
await fs.writeFile('README.md', 'This is awesome!'); | |
} catch (err) { | |
// ... | |
} |
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 fs = require('fs/promises'); | |
fs.readFile('LICENSE.md') | |
.then(data => { | |
// ... | |
}) | |
.catch(err => { | |
// ... | |
}); |
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 fs = require('fs'); | |
const data = fs.readFileSync('LICENSE.md'); | |
try { | |
fs.writeFileSync('README.md', 'This is awesome!'); | |
} catch (err) { | |
// ... | |
} |
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 fs = require('fs'); | |
fs.readFile('LICENSE.md', (err, data) => { | |
// ... | |
}); | |
fs.writeFile('README.md', 'This is awesome!' (err) => { | |
// ... | |
}); |
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 redis = require('redis'); | |
const publisher = redis.createClient(); | |
publisher.publish('my channel', 'hi'); | |
publisher.publish('my channel', 'hello world'); |
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
upstream nodes { | |
ip_hash; | |
server 127.0.0.1:8000; | |
server 127.0.0.1:8001; | |
server 127.0.0.1:8002; | |
} |
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
<!Doctype html> | |
<html> | |
<head> | |
<title>Hello World</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script> | |
<script> | |
const socket = io('http://0.0.0.0:3000', { | |
transports: ['polling'] | |
// transports: ['websocket'] | |
}); |
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
upstream nodes { | |
server 127.0.0.1:8000; | |
server 127.0.0.1:8001; | |
server 127.0.0.1:8002; | |
} | |
server { | |
listen 3000; | |
location / { |
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 app = express(); | |
app.get('/', (req, res) => { | |
res.end(`Hi, PID: ${process.pid}`); | |
}); | |
app.listen(process.env.PORT); | |
console.log(`Server running on ${process.env.PORT} port, PID: ${process.pid}`); |
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
<html> | |
<head> | |
<title>Store</title> | |
<link rel="stylesheet" href="./style.css"> | |
</head> | |
<body> | |
<div id="StoreItems"></div> | |
<div id="User"></div> | |
</body> | |
<script src="./user.js"></script> |
NewerOlder