We have the same code working using node
, deno
, and bun
.
E.g.,
bun run index.js
#!/usr/bin/env python | |
""" | |
pip install tiktoken requests | |
export OPENAI_API_KEY=<redact> | |
chmod +x prepare-commit-msg | |
mv prepare-commit-msg .git/hooks/ | |
""" | |
import math |
import fs from 'fs' | |
import vm from 'vm' | |
import path from 'path' | |
/* | |
* cli command | |
* node --experimental-vm-modules express-hot-reload.js | |
*/ | |
const ModuleCache = new Map() |
// Using: | |
// [email protected] | |
// [email protected] | |
import globby from 'globby'; | |
import { dirname } from 'path'; | |
import { fileURLToPath } from 'url'; | |
import chalk from 'chalk'; | |
async function main() { |
const { callbackify } = require("util"); | |
const { GracefulStopTimeoutError } = require("moleculer").Errors; | |
const { Message, Producer, Consumer } = require("redis-smq"); | |
const events = require("redis-smq/src/events"); | |
module.exports = function QueueMiddleware() { | |
const producers = new Map(); | |
const consumers = new Map(); | |
function gracefulShutdown(broker, items) { |
"use strict"; | |
const { MoleculerError } = require("moleculer").Errors; | |
const { Root, Namespace, Service, Method, Type, Field } = require("protobufjs"); | |
const gRPC = require("grpc"); | |
module.exports = { | |
name: "grpc", | |
settings: { | |
port: 50051, |
const Knex = require("knex"); | |
const { MoleculerServerError } = require("moleculer").Errors; | |
// const saveAsyncStack = require('knex/lib/util/save-async-stack'); | |
const { types } = require("pg"); | |
types.setTypeParser(20, (value) => +value); | |
types.setTypeParser(1700, (value) => +value); | |
module.exports = function KnexMiddleware(options) { | |
options = { |
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
version: '3' | |
services: | |
server: | |
image: "rancher/k3s:latest" | |
command: server | |
tmpfs: | |
- /run | |
- /var/run | |
privileged: true |
'use strict'; | |
const path = require('path'); | |
const fs = require('fs'); | |
const YAML = require('yaml'); | |
function WebpackMoleculerServicePlugin(options) { | |
options = options || {}; | |
if (typeof options === 'string') { | |
this.options = { output: options }; |