Skip to content

Instantly share code, notes, and snippets.

View evanshortiss's full-sized avatar
:octocat:
🇮🇪 🇺🇸

Evan Shortiss evanshortiss

:octocat:
🇮🇪 🇺🇸
View GitHub Profile
@evanshortiss
evanshortiss / hello.js
Created February 20, 2018 22:11
Contains a reference hello.js for the Red Hat & RapID blogpost
// If you're working with a local domain you can uncomment this
// or update your fhconfig.json according to the RHMAP local
// development guides
// $fh.getCloudUrl = function () {
// return 'https://nodejs-cloudappdevezqll-rhmap-rhmap-development.127.0.0.1.nip.io'
//}
// Let the code below initialise, then configure our UI
setTimeout(function () {
@evanshortiss
evanshortiss / httpd.conf
Created March 8, 2018 23:14
Contains a reference httpd.conf for the Red Hat & RapID blogpost
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
const supertest = require('supertest')
const express = require('express')
const router = require('lib/routes/some-router')
describe('#some-router tests', () => {
// temp express app. allows to tests routes in isolation from broader application
const app = express()
// app.use(router()) or whatever way works for your structure
app.use('/stuff', router)
@evanshortiss
evanshortiss / wss.js
Last active March 22, 2019 22:29
A quick web socket server setup in Node.js
/**
* Quick setup:
*
* $ mkdir /tmp/wss
* $ cd /tmp/wss
* $ npm init -f
* $ curl https://gist.githubusercontent.com/evanshortiss/83e63dc9cab83c7e7aba6780da3704bd/raw/ae5d532a371ef383d896f1663a454102cc1931c3/wss.js > wss.js
* $ node wss.js
*/
@evanshortiss
evanshortiss / fastify-hello-world.js
Created May 28, 2019 23:27
Fastify Hello World
const fastify = require('fastify')({
logger: false
})
// Declare a route
fastify.get('/hello', (request, reply) => {
reply.send('hello')
})
// Run the server!
@evanshortiss
evanshortiss / openshift-quarkus-deploy.sh
Last active May 29, 2019 16:36
Deploy a Quarkus Application on OpenShift
oc new-project quarkus-project --display-name="Quarkus Project"
oc new-build quay.io/redhat/ubi-quarkus-native-runner --binary --name=quarkus-quickstart -l app=quarkus-quickstart
# Replace filename with whatever your file is called, e.g quarkus-quickstart-1.0-SNAPSHOT-runner
# This command might report a file copy error - my build still worked despite this 👍
oc start-build quarkus-quickstart --from-file=target/$FILENAME-runner --follow
oc new-app quarkus-quickstart
oc expose service quarkus-quickstart
@evanshortiss
evanshortiss / with-env-var.example.js
Created June 11, 2019 16:42
Example of Code Using env-var
const env = require('env-var');
const MAX_BATCH_SIZE = env.get('MAX_BATCH_SIZE').required().asIntPositive();
@evanshortiss
evanshortiss / without-env-var.example.js
Last active October 14, 2021 16:30
Example code running without env-var. This is how you might implement env.get(MAX_BATCH_SIZE).required().asIntPositive()
/**
* All the assertion code below the line could be replaced with
* this single line by using env-var
*/
env.get(MAX_BATCH_SIZE).required().asIntPositive()
// -----------------------------------------------
const assert = require('assert');
@evanshortiss
evanshortiss / mqtt.dc.yml
Created July 11, 2019 23:03
#1 - create MQTT deployment for AeroGear Showcase deployed using the aerogear/mobile-services-installer setup script
kind: DeploymentConfig
apiVersion: v1
name: mosquitto-mqtt-broker
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
creationTimestamp: null
labels:
app: sync-app-showcase-server
name: mosquitto-mqtt-broker
@evanshortiss
evanshortiss / mqtt.service.yml
Last active July 16, 2019 16:33
#2- create MQTT service for AeroGear Showcase deployed using the aerogear/mobile-services-installer setup script
apiVersion: v1
kind: Service
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
creationTimestamp: null
labels:
app: sync-app-showcase-server
name: mosquitto-mqtt-broker
spec: