express.js official migration guide is not sufficient yet.
- Check manually in your RequestHandler
- Be careful declaration order
// users.router.ts
import { Router } from "express";
/** | |
* @example | |
* ```ts | |
* const POST_STATE = { | |
* DRAFT: 0, | |
* PUBLISHED: 1, | |
* // ... | |
* } as const; | |
* type PostState = (typeof POST_STATE)[keyof typeof POST_STATE]; | |
* |
express.js official migration guide is not sufficient yet.
// users.router.ts
import { Router } from "express";
import { assertEquals } from "jsr:@std/assert"; | |
import { paginate } from "./pagination.ts"; | |
Deno.test(function paginateTest() { | |
assertEquals(paginate(1, 1), [1]); | |
assertEquals(paginate(1, 2), [1, 2]); | |
assertEquals(paginate(2, 2), [1, 2]); |
#!/bin/bash | |
function print_multiline() { | |
local text=$(cat <<'EOF' | |
``` | |
# Markdown Text | |
- one | |
- two | |
``` |
[email protected]
const { Sequelize, DataTypes, literal } = require("sequelize");
const sequelize = new Sequelize({/* ... */});
/** | |
* ref: https://www.freecodecamp.org/news/javascript-range-create-an-array-of-numbers-with-the-from-method/ | |
* | |
* # Example | |
* | |
* ```ts | |
* import { range } from "./main.ts"; | |
* | |
* range(1, 5); | |
* // [1, 2, 3, 4, 5] |
/** | |
* LCM ... Least Common Multiple (最小公倍数) | |
* GCD ... Greatest Common Divisor (最大公約数) | |
* | |
* LCM = (A * B) / GCD | |
*/ | |
function _findGCD(a: number, b: number): number { | |
if (a === 0) return b; | |
if (b === 0) return a; |
// https://deno.com/blog/queues | |
function listenQueue<T>(fn: (msg: T) => Promise<void>) { | |
// | |
} | |
// lib/kv/queue/_core.ts | |
const messageTypes = { | |
foo: "foo", |
// see https://deno.land/std/datetime/constants.ts?source | |
const MILLISECOND = 1; | |
const SECOND = MILLISECOND * 1e3; | |
const MINUTE = SECOND * 60; | |
const HOUR = MINUTE * 60; | |
const DAY = HOUR * 24; | |
const WEEK = DAY * 7; | |
type Unit = | |
| "milliseconds" |