This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { strict as assert } from "node:assert/strict"; | |
// just test the basics to aid debugging | |
import { test } from "node:test"; | |
import Fastify from "fastify"; | |
const opts = { | |
schema: { | |
querystring: { | |
type: "object", | |
properties: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncQueue { | |
#queue = []; | |
#maxQueueLength = Infinity; | |
#nextResolve = () => {}; | |
#hasNext = false; | |
constructor(maxQueueLength) { | |
if (maxQueueLength) { | |
this.#maxQueueLength = maxQueueLength; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"openapi": "3.1.0", | |
"info": { | |
"version": "1.0.0", | |
"title": "Swagger Petstore", | |
"license": { | |
"name": "MIT", | |
"url": "https://opensource.org/licenses/MIT" | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// small transformation utility to modify an openApi spec | |
// tested against: https://github.com/ringcentral/ringcentral-api-specifications/blob/master/ringcentral.spec.2019110220191017-1140.openapi3.yaml | |
const yaml = require('js-yaml'); | |
const fs = require('fs'); | |
const condition = 'x-auth-required'; | |
const filename = 'ringcentral.spec.openapi3.yaml'; | |
// Transformation function | |
function transform(spec) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parser.prototype.parse 6377 | |
BufferList.prototype.append 6200 | |
Buffer.isBuffer 225 | |
Parser.prototype._parseHeader 6387 | |
BufferList.prototype[m] 6325 | |
BufferList.prototype.slice 6228 | |
BufferList.prototype.copy 6231 | |
BufferList.prototype._offset 6189 | |
Buffer.prototype.slice 673 | |
Buffer._augment 1186 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"swagger": "2.0", | |
"info": { | |
"description": "Testlab user account api.", | |
"version": "1.0.0", | |
"title": "Testlab user account", | |
"termsOfService": "http://labmgmt.testlab.local/terms/", | |
"contact": { | |
"name": "Testlab Team", | |
"email": "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple script to monitor a docker engine | |
// 14 March 2016 | |
// https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/#monitor-docker-s-events | |
const https = require('https'); | |
const fs = require('fs'); | |
// for now we use a dummy registry, but we could link this to consul, etcd etc.. | |
var registry={}; | |
// setup TLS config to be able to talk to docker, when run in a container we |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rdb = require('rethinkdb'), | |
loki = require('lokijs'), | |
db, | |
connection; | |
function forwardInsert(db, connection, table, record, callback) { | |
var cb = callback || function (err, obj) { | |
if (err) { | |
throw err; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var defaultPersistence={ 'NODEJS': 'fs', 'BROWSER': 'localStorage', 'CORDOVA': null }; | |
if (this.persistenceMethod == null){ | |
this.persistenceMethod = defaultPersistence[this.ENV]; | |
if (! this.persistenceMethod){ | |
throw Error('unknown environment') | |
} | |
} | |
if (this.persistenceMethod === 'adapter') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cryptedFileAdapter = require('./lokiCryptedFileAdapter'); | |
cryptedFileAdapter.setSecret('mySecret'); | |
var loki=require('lokijs'); | |
var db = new loki('loki.json.crypted',{ adapter: cryptedFileAdapter }); | |
db.loadDatabase({},function(){ | |
var children = db.addCollection('children'); | |
children.insert({name:'Bleep', legs: 2}); | |
db.save(); |