Refactor units to be generic; start bundles; start app index.ts

This commit is contained in:
garrettmills
2020-07-20 22:54:25 -05:00
parent c0777f77b5
commit 60bb9afa29
22 changed files with 163 additions and 110 deletions

2
app/bundle/daton.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from '../../lib/src/module.ts'
export * from '../../di/module.ts'

View File

@@ -0,0 +1,4 @@
export { default as ConfigUnit } from '../../lib/src/unit/Config.ts'
export { DatabaseUnit } from '../../orm/src/DatabaseUnit.ts'
export { default as ControllerUnit } from '../../lib/src/unit/Controllers.ts'
export { default as MiddlewareUnit } from '../../lib/src/unit/Middlewares.ts'

View File

@@ -0,0 +1,5 @@
import { env } from '../../lib/src/unit/Scaffolding.ts';
export default {
name: env('APP_NAME', 'Daton'),
}

View File

@@ -1,5 +0,0 @@
import { env } from '../../../lib/src/unit/Scaffolding.ts';
export default {
name: env('APP_NAME', 'Daton'),
}

16
app/configs/db.config.ts Normal file
View File

@@ -0,0 +1,16 @@
import {env} from "../../lib/src/unit/Scaffolding.ts";
export default {
connections: {
default: {
type: env('DB_TYPE', 'postgres'),
user: env('DB_USERNAME', 'daton'),
password: env('DB_PASSWORD'),
database: env('DB_DATABASE', 'daton'),
hostname: env('DB_HOSTNAME', 'localhost'),
port: env('DB_PORT', 5432),
}
}
}

20
app/index.ts Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env -S deno run -c ./tsconfig.json --unstable --allow-read --allow-env --allow-net
/* Main executable for the Daton app. */
import { make, Scaffolding, Application } from './bundle/daton.ts'
import units from './units.ts'
/*
* Let's get up and running. The scaffolding provides the bare minimum
* amount of support required to get Daton up and running. The app handles
* the rest.
*/
const scaffolding = make(Scaffolding)
await scaffolding.up()
/*
* Now, import the units and start the application. The units define each
* modular piece of functionality that is managed by the Daton app.
*/
const app = make(Application, units)
await app.run()

8
app/tsconfig.json Executable file
View File

@@ -0,0 +1,8 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

8
app/units.ts Normal file
View File

@@ -0,0 +1,8 @@
import {ConfigUnit, DatabaseUnit, ControllerUnit, MiddlewareUnit} from './bundle/daton_units.ts'
export default [
ConfigUnit,
DatabaseUnit,
MiddlewareUnit,
ControllerUnit,
]