The Dito.js Application class inherits from the Koa Application class.
Normally, a simple Dito.js Server creates only one Application
instance and
exports it:
import { Application } from '@ditojs/server'
import mount from 'koa-mount'
import serve from 'koa-static'
import config from '../config.js'
import * as models from './models/index.js'
import * as controllers from './controllers/index.js'
const app = new Application({
config,
models,
controllers
})
// Static Assets:
app.use(mount('/assets', serve('assets')))
export default app
Then, in the application's main file, all it takes to start the server is the following statement:
import app from './app/index.js'
app.execute()
Dito.js applications can register custom keywords and formats for JSON schema
validation. In order to do so, a Validator
instance needs to be provided.
See Validator and Model Properties for more information on JSON schema validation.