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";
services: | |
db: | |
image: mysql:8.0 | |
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_bin | |
environment: | |
- MYSQL_ALLOW_EMPTY_PASSWORD=yes | |
- MYSQL_DATABASE=app_development | |
ports: | |
- "3306:3306" |
import { Suspense, use } from 'react'; | |
function Messages({ fetchMessages }: { fetchMessages: Promise<string[]> }) { | |
// Promise must be initialized outside the component currently. | |
// see: https://react.dev/blog/2024/12/05/react-19#new-feature-use | |
// | |
// This doesn't work; | |
// ``` | |
// const messages = use(new Promise<string[]>((resolve) => { | |
// setTimeout(() => { |
/** | |
* @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", |