Arcton
The factory function that creates an application instance
Every Arcton application starts with a single call to this function:
import { Arcton } from '@arcton/core'
const app = Arcton()
app.get('/', () => 'Hello, Arcton!')
app.listen()Arcton()
Purpose: creates a new application instance — an ArctonApp — that you register routes, middleware, and providers on.
Signature
import type { ArctonApp, ArctonConfig } from '@arcton/core'
declare function Arcton(config?: ArctonConfig): ArctonApp<{}>Parameters
Prop
Type
Return type: an ArctonApp<{}> with no provided context yet — provide() grows it as you register providers.
Behavior: each call to Arcton() creates an independent instance with its own route tree, global middleware, and body parsers. Calling it more than once — for example to build a module that gets mounted with app.use(module) — is the normal way to compose an application from smaller pieces.
Errors: none directly. A config.prefix that isn't a static path throws at construction time — see ArctonConfig below.
ArctonConfig
Purpose: the configuration object passed to Arcton().
Signature
interface ArctonConfig {
prefix?: string
}Parameters
Prop
Type
Behavior: prefix must be a static path — a :param or *wildcard segment throws when the instance is created. '/' and an omitted prefix are equivalent to no prefix at all. See App configuration for the full guide, including how prefixes compose across mounted modules.
Errors: a non-static prefix throws Prefix "<value>" must be a static path — dynamic/wildcard segments aren't supported (e.g. app.use('/api', mw), not app.use('/api/:id', mw)). See Registration errors.
Example
import { Arcton } from '@arcton/core'
const app = Arcton({ prefix: '/api' })
app.get('/users', () => [])
app.listen()