Year: 2016

  • How to use transactions with node postgres

    Transactions in computer programming are essential for data integrity. Transactions provide primitives for guaranteeing your query logic succeeds or fails gracefully. A transaction contains any number of statements. At any point you can rollback if an error occurs or your logic fail conditions trigger. A RDBMS like PostgreSQL gives you an amazing set of properties…

  • Node Postgres Example

    This tutorial shows how to connect and query Postgres using Node. For this project we assume you have a Mac or Linux machine, know git, know node.js, and some SQL. Contents Setup Create Database Connections Query Advanced Queries Setup Project Clone Example Project git clone git@github.com:wlaurance/node-postgresql-example.git The example code is available at the Github repo…

  • NGINX Rewrite Subdomain to Path

    In this post I show you how to rewrite subdomain requests to a path. This is a common requirement if a client or business wants to change a blog or API domain name scheme. We will change blog.mydomain.com and api.mydomain.com to mydomain.com/blog and mydomain.com/api respectively. | Old Route | ==> | New Route | |————-|—–|—————————————-| | blog.mydomain.com | ==> | mydomain.com/blog | | api.mydomain.com | ==> | mydomain.com/api | #This server…

  • How To NGINX reverse proxy to another server

    Why would you want to use the proxy_pass directive? You are a high school student. Your school blocks access to social networks. You want to sell Facebook.com proxy access to your classmates for five dollars a month. You can use NGINX to proxy HTTP traffic from an IP address you control to the Facebook.com domain. Make sure…