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 / 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 / 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 / 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
*/
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 / 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
@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 / index.html
Created February 20, 2018 22:09
Contains a reference index.html for the Red Hat & RapID blogpost
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Hello World</title>
<link rel="stylesheet" href="css/app.css">
</head>
<body>
@evanshortiss
evanshortiss / sample-list-handler.js
Created November 2, 2017 18:20
Example of a custom list handler for use with FeedHenry Node.js Data Sync
const sync = require('fh-mbaas-api').sync
const workorders = require('lib/sql/workorders')
// Typical init code etc...
// Example of getting work orders for a specific user
sync.handleList('workorders', function(datasetId, query, metadata, done) {
// Getting by the userId passed to the sync framework and the region they are in
workorders.getDataForUserInRegion(query.userId, query.region, (err, specificUserWorkOrders) => {
if (err) {
@evanshortiss
evanshortiss / rhmap-ip-filter.js
Last active October 25, 2017 18:44
An express middleware function that ensures requests are coming from the IP addresses defined in IP_ALLOWED_ADDRESSES
'use strict'
// Ensure you run "npm install env-var@3 --save"
const env = require('env-var')
// Used to bypass check when running locally
const isLocal = env.get('FH_USE_LOCAL_DB').asBool()
// Valid mbaas IP(s) that can be in the "x-forwarded-for" header
// This must be set or app will not start (required() call) and must be comma separated
@evanshortiss
evanshortiss / rhmap-service-ip-filter-application.js
Last active October 25, 2017 22:19
A sample application.js file that uses the IP Filter from my previous Gist
'use strict'
const express = require('express')
const cors = require('cors')
const app = express()
// Enable CORS for all requests
app.use(cors())