NGROK, undocumentation

OpenCart on LocalHost via NGROK

OpenCart Ecommerce System has A LOT of flaws, apparently written by an army of unknown developers spread around the Russian OpenSource Community, it shows very little cohesion in the source-code (Read spaghetti).

One of the more tangible caveats of this is the way that everything is implemented multiple times and in different ways… and this leads me to this following issue:

It doesn’t observe the Host-Header HTTP parameter but instead uses a hard-coded configuration.

Since I have no interest and ambition in contributing to OpenCart, and to to get it to run through NGROK on the local-host, I found the easiest way was to change the configuration…

 

Docker, Gulp, Node-RED, undocumentation

Development of node-red nodes w. docker has one big issue

Its a common known design decision by the Docker team that they don’t want to have support for symbolic links in their volumes, which means that using the Node-RED docker images while developing Node-RED nodes has a critical flaw since it means that the approach recommended by the Node-RED team which involves creating symbolic links to the source directory from the root of the Node-RED runtime.

Gulp to the rescue… Just setup a pre-launch Gulp script to copy the contents into the root of the Node-RED instance.

import {Gulp} from "gulp";

let gulp:Gulp = require(‘gulp’);

gulp.task(‘default’, function () {
return gulp
.src([‘../../your_project/**/*’])
.pipe(gulp
.dest(‘./node_modules/your_project’));
});

Documentation, Uncategorized

Multiple Environments with Loopback 4

When configuring multiple environments for a Loopback 4 Application, it can appear less straight forward than with Loopback 3, so here is a quick fix for how to get over this obstacle as elegantly as possible in 5 minutes.

  1. Import dotenv and create a .env file in the root of the app.
  2. Put your database configuration in this file.
  3. Empty the existing datasource file so it contains an empty JSON (file is required by compiler and the bootstrapping).
  4. Add the code below to the application.ts file in the src directory.
  5. Don’t forget to require the dotenv from the run command.
this.bind('datasources.default').to(new DefaultDataSource());
this.dataSource(new DefaultDataSource());
this.bind('datasources.config.default').to({
  name: 'default',
  connector: 'mongodb',
  hostname: process.env.DB_DEFAULT_HOSTNAME,
  port: process.env.DB_DEFAULT_PORT,
  user: process.env.DB_DEFAULT_USER,
  password: process.env.DB_DEFAULT_PASSWORD,
  database: process.env.DB_DEFAULT_DATABASE,
  useNewUrlParser: process.env.DB_DEFAULT_USENEWURLPARSER,
  authSource: process.env.DB_DEFAULT_AUTHSOURCE
});
this.bind('datasources.default').toClass(DefaultDataSource);

This is a quick fix intended to help move on if in a pickle, I will refine this further so the application will check the process.env.NODE_ENV variable instead and load the corresponding file.

For the original inspiration to this post, head over here: https://medium.com/p/8f085399268/responses/show

 

Documentation

QuickFix how to deploy a Loopback 4 Application to Heroku

When you are prototyping, sometimes you just need something to work, this was my case with a new experiment I’m working using Loopback 4 which I wanted to deploy for to Heroku for some rapid testing.

Generally CLI generated App’s doesn’t like environments like Heroku too much and since I later will deploy to DigitalOcean through some Docker containers, I just needed a QuickFix.

Anyways, let’s get to the point… this is a very opiniated post which takes for granted you are using the exact same development workflow that I have, if not, post a comment and I will do my best to help you out.

  1. Remove the /dist entry from .gitignore so it will be committed to Git, and subsequently caught by the CD routine running on Heroku through the GitHub Webhook.
  2. Remove the prestart script entry from package.json.
  3. Remove the “-r source-map-support/register” from the start script entry in package.json.

Now you are good to deploy it to Heroku via GitHub, however don’t forget to build before you commit.