Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

jeonghyeon-net-archive/commonly-used-kanji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript + Kysely one-off scripts (SQLite)

Overview

  • Run ad-hoc, type-safe scripts against a local sqlite.db.
  • Uses Kysely with better-sqlite3 for fast, synchronous SQLite access.

Requirements

  • Node.js 18+

Install

  1. Install dependencies:

    npm install

    If you cloned only the files, you may need to initialize first:

    npm install kysely better-sqlite3 npm install -D typescript tsx @types/better-sqlite3

  2. Optionally adjust the DB path via env var DB_PATH (default: ./sqlite.db).

Project structure

  • src/db.ts: Creates a Kysely instance for SQLite.
  • src/types.ts: DB table typings for Kysely.
  • src/tasks.ts: Discovers tasks by filename order.
  • src/tasks/*: Task files (use numeric prefixes for order).
  • src/index.ts: Minimal CLI to list/run tasks.

Usage

  • List tasks:

    npm run tasks

  • Run all tasks:

    npm run run:all

  • Run specific tasks (comma-separated):

    npm run run -- run 01_create_people_table,03_print_people_summary

Environment

  • .env is auto-loaded (via dotenv). Create a .env file with:

    MOCHI_DECK_ID=yourDeckId MOCHI_TEMPLATE_ID=yourTemplateId MOCHI_BASIC_AUTH=yourUsernameOrToken DB_PATH=./sqlite.db

  • Basic Auth rule: the Mochi API uses HTTP Basic with an empty password. The code constructs the header as Basic base64(username:). You only need to provide the username/token via MOCHI_BASIC_AUTH; the script handles the base64 encoding with the trailing colon.

  • DB_PATH: path to your SQLite file (default ./sqlite.db).

Notes

  • Tasks are discovered dynamically; execution order is filename order. Name files like 01_do_this.ts, 02_do_that.ts.
  • The example people table includes a unique index on name so demo inserts are idempotent.
  • Add your own tasks under src/tasks (no registry needed).

About

상용한자 2136자와 그 사용 예시를 mochi로 옮겨주는 스크립트 (feat. gpt-oss 20b)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors