Node.js
requires a custom https-loader
: https://nodejs.org/api/esm.html#https-loader
The loader (https-loader.js
):
The sample file (sample.js
):
export const example = () => ({ foo: "bar" });
# replace CHANNEL_ID and BOT_SECRET with your values | |
curl --include \ | |
--request POST "https://discord.com/api/channels/CHANNEL_ID/messages" \ | |
--header "Content-Type: application/json" \ | |
--header "Authorization: Bot BOT_SECRET" \ | |
--data '{ "content": "lorem ipsum" }' |
const { emit: originalEmit } = process; | |
/** | |
* @param {string} event | |
* @param {{ name: string; }} error | |
*/ | |
function suppresser(event, error) { | |
return event === "warning" && error.name === "ExperimentalWarning" | |
? false | |
: originalEmit.apply(process, arguments); |
function perf {: | |
curl --silent \ | |
--url "$1" \ | |
--output /dev/null \ | |
--write-out "\n%{time_total} sec\n%{size_download} bytes\n" | |
} | |
/** | |
* @param ms milliseconds to sleep | |
* @returns void | |
*/ | |
export function sleep(ms: number): void { | |
/** | |
* In some environments such as Cloudflare Workers, Atomics is not defined | |
* setTimeout is used as a fallback | |
*/ | |
if (typeof Atomics === 'undefined') { |
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"type": "object", | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The name of the project" | |
}, | |
"main": { | |
"type": "string", |
/** | |
* Wrap any complex and hard to read type with this | |
* and it'll magically be a lot simpler on hover. | |
*/ | |
export type Pretty<T> = { [K in keyof T]: T[K] } & {}; |
const promise1 = Promise.resolve(1); | |
const promise2 = Promise.reject(2); | |
/** | |
* Promise.all() example | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all | |
*/ | |
Promise.all([promise1, promise2]) | |
.then((value) => console.log({ value })) | |
.catch((error) => console.log({ error })); |
<!doctype html> | |
<html lang='en'> | |
<head> | |
<meta charset='UTF-8' /> | |
<title>_TITLE_</title> | |
<link rel='stylesheet' type='text/css' href='https://unpkg.com/swagger-ui-dist/swagger-ui.css' /> | |
<style> | |
*, | |
*:before, |
Node.js
requires a custom https-loader
: https://nodejs.org/api/esm.html#https-loader
The loader (https-loader.js
):
The sample file (sample.js
):
export const example = () => ({ foo: "bar" });
curl --silent --location \
--request POST \
--url 'https://spacex-production.up.railway.app' \
--header 'Content-Type: application/json' \
--data '{"query":"query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }","variable":{}}'