@nan0web/core
v1.0.3
Published
Core application framework for nan0web with database handling, internationalization, and interface connectivity
Maintainers
Readme
@nan0web/core
Core application framework for nan0web providing a lightweight DB‑backed state container with built‑in internationalisation.
|Package name|Status|Documentation|Test coverage|Features|Npm version|
|---|---|---|---|---|---|
|@nan0web/core |🟢 99.1% |🧪 English 🏴Українською 🇺🇦 |🟢 95.3% |✅ d.ts 📜 system.md 🕹️ playground |1.0.1 |
Installation
How to install with npm?
npm install @nan0web/coreHow to install with pnpm?
pnpm add @nan0web/coreHow to install with yarn?
yarn add @nan0web/coreBasic usage – AppCore
Create an AppCore instance with a mock DB and inspect its state.
How to instantiate AppCore?
import { AppCore } from "@nan0web/core"
const db = new DB()
const core = new AppCore({ db, title: "Demo", uri: "/demo", locale: "en" })
console.info(core.title) // ← Demo
console.info(core.uri) // ← /demoInternationalisation bootstrap
Load translation JSON from the DB and obtain a translation function.
How does bootstrapI18n load translations?
const db = new DB({
predefined: [
["i18n/uk.json", { "hello": "Вітаю!" }]
]
})
await db.connect()
const core = new AppCore({ db, locale: "uk" })
await core.init()
const result = core.t("hello")
console.info(result) // ← Вітаю!State inspection
How to retrieve current state?
const db = new DB()
const core = new AppCore({ db })
const state = core.state()AppResult helper
How to create an AppResult instance?
import { AppResult } from "@nan0web/core"
const res = new AppResult({ content: "Done", priority: 2, meta: { ok: true } })
console.info(res.content[0]) // ← Donerun() contract
The base run method throws an error – subclasses must implement it.
How does run() behave when not overridden?
const db = new DB()
const core = new AppCore({ db })
await core.run() // ← throws an error → AppCore: run() must be implementedContributing
How to contribute? - check here
License
How to license ISC? - check here
