Skip to content

Instantly share code, notes, and snippets.

View kevinswiber's full-sized avatar
🍄
lizard person

Kevin Swiber kevinswiber

🍄
lizard person
View GitHub Profile
@kevinswiber
kevinswiber / import-external-dependencies.js
Created January 19, 2022 22:06
Import external dependencies into Postman
const CACHE_KEY = '__importCache'
const importCacheLayer = pm.environment.has(CACHE_KEY)
? pm.environment
: pm.collectionVariables.has(CACHE_KEY)
? pm.collectionVariables
: pm.globals.has(CACHE_KEY)
? pm.globals
: pm.variables;
const __import = (url, options = { timeout: 20_000}) => {
@kevinswiber
kevinswiber / websocket_handshake_probe.sh
Created November 12, 2021 21:13
A simple bash script for checking if a WebSocket endpoint is alive.
#!/bin/bash
self=`basename "$0"`
if (($# == 0)); then
cat <<EOF
Usage: $self url
Example: $self http://localhost:3000/echo
Check if a URL is returning a valid WebSocket handshake response.
@kevinswiber
kevinswiber / Basic Auth.postman_collection.json
Created August 26, 2020 19:31
Postman Basic Auth example
{
"info": {
"_postman_id": "f8ee6daf-36ee-404c-9c5b-107a9fbee6b6",
"name": "Basic Auth",
"description": "An example of using Basic Auth in Postman.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Basic Auth",
@kevinswiber
kevinswiber / Cargo.toml
Last active August 23, 2020 03:59
wasm wrapper around postman2openapi
[package]
name = "postman2openapi-wasm"
version = "0.1.0"
authors = ["Kevin Swiber <[email protected]>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[features]
@kevinswiber
kevinswiber / server.js
Created May 21, 2020 17:01
Twitch Webhook
const crypto = require('crypto');
const http = require('http');
const server = http.createServer(async (req, res) => {
if (req.method === 'GET') {
return handleSubscriptionVerification(req, res);
} else if (req.method === 'POST') {
return await handleEventNotification(req, res);
}
@kevinswiber
kevinswiber / server.js
Last active May 22, 2020 17:11
Reverse Proxy that passes through Postman's proxy to capture incoming HTTP traffic.
// A reverse proxy that captures incoming HTTP traffic and sends it
// through Postman's forward proxy, which forwards traffic to the
// specified target in process.env.TARGET.
// request
// client -> this-proxy -> postman-proxy --|
// |
// target
// response |
// client <- this-proxy <- postman-proxy --|
@kevinswiber
kevinswiber / postman.tmpl
Last active April 22, 2020 08:03
Go template for converting gRPC service proto files into a Postman Collection using `protoc-gen-doc`.
{{- $messages := (index .Files 0).Messages -}}
{{- if gt (len .Files) 1 -}}
{{- range $file := (slice .Files 1) -}}
{{- $messages = concat $messages $file.Messages -}}
{{- end -}}
{{- end -}}
{
"info": {
"name": "{{coalesce (env "POSTMAN_COLLECTION_NAME") "Imported gRPC JSON API"}}",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
@kevinswiber
kevinswiber / postman-external-require-browserify-cdn.js
Last active October 7, 2023 20:47
Postman pre-request script to set init and cleanup environment variables that pull down browserify bundles from the browserify service.
/*
This is a pre-request script for Postman collections, folders, or requests that imports
packages from npm after bundling them through [Browserify-CDN](https://wzrd.in/).
## Usage
In global, collection, or environment variables, define a variable named `dependencies`
that lists packages to import in the form `<package-name>@<version>`. To include
multiple packages, separate the package specs with commas
(e.g., `async@latest,[email protected]`).
@kevinswiber
kevinswiber / gateway.config.yml
Created June 20, 2018 17:07
Express Gateway with TLSv1 disabled
http:
port: 8080
https:
port: 9443
options:
secureOptions: 67108864 # node -p "require('constants').SSL_OP_NO_TLSv1"
tls:
"*.demo.io":
key: example/keys/demo.io.key.pem
cert: example/keys/demo.io.cert.pem
@kevinswiber
kevinswiber / express-gateway-configmap.yaml
Last active May 7, 2022 13:17
Files for Running Express Gateway in Kubernetes, Part 2
apiVersion: v1
kind: ConfigMap
metadata:
name: 'express-gateway-config'
data:
gateway.config.yml: |
http:
host: '*'
port: 8080
admin: