(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| FROM ubuntu:16.04 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ca-certificates \ | |
| apt-transport-https \ | |
| openjdk-8-jre-headless \ | |
| curl \ | |
| xz-utils \ | |
| unzip \ | |
| bzip2 \ |
| /* | |
| * Handling Errors using async/await | |
| * Has to be used inside an async function | |
| */ | |
| try { | |
| const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
| // Success 🎉 | |
| console.log(response); | |
| } catch (error) { | |
| // Error 😨 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| Secure sessions are easy, but not very well documented. | |
| Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy: | |
| The desired configuration for using NginX as an SSL proxy is to offload SSL processing | |
| and to put a hardened web server in front of your Node.js application, like: | |
| [NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT] | |
| Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now. |
| // program | |
| package main | |
| import "os/signal" | |
| import "os" | |
| import "fmt" | |
| import "syscall" | |
| import "time" | |
| This playbook has been removed as it is now very outdated. |
| // This code is fallback for https://github.com/Worlize/WebSocket-Node | |
| // add the broadcast to https://gist.github.com/1219165 | |
| // 2011.11.30 tato@http://www.facebook.com/javascripting | |
| // Example of how to fallback to alternative websocket library for old protocol clients | |
| // see https://gist.github.com/1148686 | |
| var http = require('http'), | |
| WebSocketRequest = require('websocket').request, |
| /* Kosso : March 12th 2011 | |
| This the only way I managed to do this without the app crashing on resume. | |
| Done slightly differently to the KS example, since they unregister the service and | |
| do not use a setInterval timer. | |
| */ | |
| //############ in app.js : | |
| // test for iOS 4+ |
| // Target API: | |
| // | |
| // var s = require('net').createStream(25, 'smtp.example.com'); | |
| // s.on('connect', function() { | |
| // require('starttls')(s, options, function() { | |
| // if (!s.authorized) { | |
| // s.destroy(); | |
| // return; | |
| // } | |
| // |