Express Gateway: Tips

Configuration: Order of Policies Matter

When working on Auth0, make sure that the order in which you set the pipelines’ policies matches the order in which the policies are listed:
Order of policies matter

Metrics: Use epimetheus or prom-client Package

You can use either prom-client or epimetheus.
Personally, I found easier to use the epimetheus package in Gateway Express:

'use strict';

const epimetheus = require('epimetheus');

module.exports = function (gatewayExpressApp) {
  epimetheus.instrument(gatewayExpressApp, {url: '/metrics'});

Something to considered is that some of the metrics display by epimetheus and prom-client differ.
For example, with epimetheus the http request duration are in milliseconds:

http_request_duration_milliseconds{quantile="0.01",method="get",path="/api/",cardinality="one",status="200"} 1

while in prom-client, the http request duration are in seconds:

http_request_duration_seconds_bucket{service="api",instance="api-3432dc43c4-h3eeg",le="0.005",path="/metrics",method="GET",apiVersion="1.0.0",status="200"} 466081


Express Gateway use express. I tried different swagger packages; however, the closest results was to display all the endpoints from the admin side of Express Gateway.
Then, I decided to check the code implemented in the restify-swagger-jsdoc and it did the trick. Here is the modified code:

'use strict';

const swaggerJSDoc = require("swagger-jsdoc");
const path = require("path");
const fs = require("fs");
const mime = require("mime-types");
const swaggerUiPath = path.dirname(require.resolve('swagger-ui'));
const publicPath = '/api'.replace(/\/+$/, '');

const swaggerSpec = swaggerJSDoc({
	swaggerDefinition: {
		info: {
			title: 'API documentation',
			version: '0.0.1',
			description: 'API documentation'
		host: undefined,
		basePath: '/',
		schemes: undefined,
		tags: []
	apis: [

module.exports = function (gatewayExpressApp) {

	gatewayExpressApp.get(`${publicPath}/swagger.json`, (req, res) => {
		res.setHeader('Content-type', 'application/json');

	gatewayExpressApp.get(new RegExp(publicPath + '\/?$'), (req, res) => {
		res.setHeader('Location', `${publicPath}/index.html`);

	gatewayExpressApp.get(new RegExp(publicPath + '\/(.*)$'), (req, res) => {
		fs.readFile(path.resolve(swaggerUiPath, req.params[0]), (err, content) => {
			if (err) {
				res.send(`File ${req.params[0]} does not exist`);
			if (req.params[0] === 'index.html') {
				let jsonFileUrl =  `${ ? 'https' : 'http'}`.concat('://').concat(`${}${publicPath}/swagger.json`); 
				content = new Buffer(content.toString().replace('url = ""', `url = "${jsonFileUrl}"`)); 
			const contentType = mime.lookup(req.params[0]); 
			if (contentType !== false) { 
				res.setHeader('Content-Type', contentType); 


Leave a comment

Using Acoustic Levitation to “Fake Gravity” in Space Stations

Last night, I got an idea while sleeping. How about using Acoustic Levitation to fake gravity in Space Stations.
Acoustic levitation is also known as ultrasonic levitation, acoustic tractors, and ultrasonic tractors.

The reason I said “fake” is that we are not really creating a gravity field but instead we are using the principle of acoustic levitation to  push the astronaut towards one direction (which would be considered the floor).

Note: I don’t know if this is a good idea since I don’t have the budget, the knowledge, the time or the way to experiment this concept; however, if this is actually plausible, then I think it would be interesting to experiment and find out.

I am not going to over over the details of Acoustic Levitation in this post since there are many places where its explained such as HowStuffWorks (check link here).

I leave you with some videos below showing how acoustic levitation works.










This is a video made by Argonne National Laboratory:

And here is a video of BristoLIG showing how to make one at home:


Leave a comment

Amazon’s Alexa Dev Conference (Denver, CO)

On April 12 of 2018, I went to Amazon’s Alexa Dev Conference at the Denver Marriott Tech Center in 4900 S Syracuse St., Denver, Colorado.

I meet with my friend and co-worker Matt Reddick.

The conference was nice. After doing the checking and obtained our badges, we got greeted by substantial breakfast which consisted of cooked ham, sausage, scramble eggs, and french toasts made with raising bread (I think).

We went over:

  • Introduction, a future projection and a general overview of Alexa’s related product and services.
  • Skill building basics such as Intent, Slots, handling request, AWS Lambda, and NodeJS.
  • AMAZON.LITERAL vs. AMAZON.SearchQuery Slot
  • Voice Design, conversation flow diagrams vs. frame diagrams, and Session Attributes.
  • New Alexa Skills Kit features, APIs, calling public APIs and Calling cloud services
  • Using AWS DynamoDB (vs. Session Attributes) and AWS IOT.

Part of the presentation required the participation of the audience which I found interesting.

At the end, there was a competition based on the Skill all participant created. The participation was optional.


ask new --template
ask deploy
ask simulate -l "EN-US" -t "start quiz game"

Skill Code Generator for Skill Builder Language Models

GitHub Links

Other Links


Leave a comment

Kubectl: Bash Commands

The following are some bash commands I made on the rush to make my life easier when working with Kubernetes.
These files have the extension TXT to prevent any possible issues in downloading them.
Note: Only for Linux/Unix bash

createtemp: Create a temporary deployment (with a pod) based on the name provided.

  • Equivalent to run: kubectl run -it –rm=true <name>–image=tutum/curl –namespace <environment>

deldeploy: Delete deployment in environment.

  • Equivalent to run: kubectl –namespace=<environment> delete deployment <deployment name>

descpod: Describe pod for specific environment.

  • Equivalent to run: kubectl –namespace=<environment> describe pods/<pod name>

lsconfigmaps: List configmap(s) available based on environment provided.

  • Equivalent to run: kubectl –namespace=<environment> get configmaps

lsdeploys: List deployments(s) based on environment provided.

  • Equivalent to run: kubectl –namespace=<environment> get deployments

lspods: List pod(s) based on environment provided.

  • Equivalent to run: kubectl –namespace=<namespace> get pods

podcp: Copy files from/to pod in an environment.

  • Equivalent to run: kubectl cp <source> <destination> <flags>

podenv: Show pod environment variables.

  • Equivalent to run: kubectl –namespace=<environment> exec -it <pod name> env

podlog: Show pod log.

  • Equivalent to run: kubectl logs <flags> <pod name> –namespace=<environment>

podterm: Open a Shell for a pod in a specific environment.

  • Equivalent to run: kubectl –namespace=<environment> exec -it <pod name> sh

restartpod: Restart pod in environment.

  • Equivalent to run: kubectl –namespace=<environment> delete pods/<pod name>

showconfigmap: Show specific configmap based on specific environment.

  • Equivalent to run: kubectl –namespace=<environment> get configmaps/<pod name> -o=yaml

shpod: Run a command line in the pod’s shell.

  • Equivalent to run: kubectl exec <pod name> –namespace=<environment> — <command line(s)>


Leave a comment