commit
95d34d6ad3
@ -0,0 +1,7 @@
|
||||
DATON_LOGGING_LEVEL=6
|
||||
APP_NAME="My First Daton App!"
|
||||
|
||||
DB_USERNAME=garrettmills
|
||||
DB_PASSWORD=garrettmills
|
||||
DB_DATABASE=garrettmills
|
||||
|
@ -0,0 +1 @@
|
||||
.idea*
|
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
@ -0,0 +1,27 @@
|
||||
import { Daton } from '../../bundle/daton.ts'
|
||||
const { env, ViewEngine } = Daton
|
||||
|
||||
export default {
|
||||
name: env('APP_NAME', 'Daton'),
|
||||
|
||||
views: {
|
||||
/*
|
||||
* View engine that should be used to render templates.
|
||||
* Options are Handlebars, Ejs, or Denjuck.
|
||||
*/
|
||||
engine: ViewEngine.Handlebars,
|
||||
|
||||
/*
|
||||
* Relative path from the app directory to the base directory where
|
||||
* view files should be looked up.
|
||||
*/
|
||||
base_dir: 'http/views',
|
||||
|
||||
/*
|
||||
* If using Handlebars, optionally, the path to the directory within the
|
||||
* base_dir that contains the partials. They will be automatically registered
|
||||
* with Handlebars.
|
||||
*/
|
||||
partials_dir: 'partials',
|
||||
},
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { Daton } from '../../bundle/daton.ts'
|
||||
const { env } = Daton
|
||||
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
export default {
|
||||
port: 8080,
|
||||
use_ssl: false,
|
||||
prefix: '/',
|
||||
allow_mount_without_prefix: false,
|
||||
|
||||
request_timeout: 15000, // 15 seconds
|
||||
|
||||
powered_by: {
|
||||
enable: true,
|
||||
text: 'Daton',
|
||||
},
|
||||
|
||||
session: {
|
||||
driver: 'database', // memory | database
|
||||
model: 'http:Session', // required for database
|
||||
},
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import {Controller, Request, view, Injectable} from '../../../bundle/daton.ts'
|
||||
|
||||
@Injectable()
|
||||
export default class HomeController extends Controller {
|
||||
|
||||
async get_home(request: Request) {
|
||||
return view('home', { greeting: 'Hello' })
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { Middleware, Request, http, HTTPStatus } from '../../../bundle/daton.ts'
|
||||
|
||||
export default class TestMiddleware extends Middleware {
|
||||
public async handleRequest(request: Request) {
|
||||
if ( Math.random() >= 0.5 ) {
|
||||
return http(HTTPStatus.FORBIDDEN, 'Well, you were unlucky.')
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { RouterDefinition } from '../../../bundle/daton.ts'
|
||||
|
||||
export default {
|
||||
prefix: '/',
|
||||
middleware: [],
|
||||
get: {
|
||||
'/': 'controller::Home.get_home',
|
||||
'/maybe': ['middleware::Test', 'controller::Home.get_home'],
|
||||
'/statics/**': { handler: 'daton::static', arg: 'assets' },
|
||||
},
|
||||
} as RouterDefinition
|
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
{{> header }}
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Welcome to Daton</h1>
|
||||
<h2>Daton is an opinionated application framework for Deno</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,37 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Daton</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Quicksand:300,500" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #F2F4FF;
|
||||
color: #36453B;
|
||||
font-family: 'Quicksand', sans-serif;
|
||||
font-weight: 500;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.container h1 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.container h2 {
|
||||
font-weight: 300;
|
||||
}
|
||||
</style>
|
||||
</head>
|
@ -0,0 +1,24 @@
|
||||
import { Model, Type, Field, Relation } from '../../bundle/daton_orm.ts'
|
||||
import User from "./User.model.ts";
|
||||
|
||||
export default class LoginAttempt extends Model<LoginAttempt> {
|
||||
protected static table = 'daton_login_attempts'
|
||||
protected static key = 'daton_login_attempt_id'
|
||||
|
||||
protected static readonly CREATED_AT = 'attempt_date'
|
||||
protected static readonly UPDATED_AT = null
|
||||
|
||||
@Field(Type.int)
|
||||
protected daton_login_attempt_id?: number
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id!: number
|
||||
|
||||
@Field(Type.timestamp)
|
||||
protected attempt_date!: Date
|
||||
|
||||
@Relation()
|
||||
public user() {
|
||||
return this.belongs_to_one(User, 'login_attempts')
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
import { Model, Type, Field, Relation } from '../../bundle/daton_orm.ts'
|
||||
import LoginAttemptModel from './LoginAttempt.model.ts'
|
||||
|
||||
export default class User extends Model<User> {
|
||||
protected static table = 'daton_users'
|
||||
protected static key = 'user_id'
|
||||
|
||||
protected static readonly CREATED_AT = 'created_at'
|
||||
protected static readonly UPDATED_AT = 'updated_at'
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id?: number
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected first_name!: String
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected last_name!: String
|
||||
|
||||
@Field(Type.bool)
|
||||
protected active!: Boolean
|
||||
|
||||
@Relation()
|
||||
public login_attempts() {
|
||||
return this.has_many(LoginAttemptModel)
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
import { SessionModel } from '../../../bundle/daton.ts'
|
||||
import { Field, Type } from '../../../bundle/daton_orm.ts'
|
||||
|
||||
export default class Session extends SessionModel {
|
||||
protected static table = 'sessions'
|
||||
protected static key = 'session_key'
|
||||
|
||||
protected static readonly CREATED_AT = 'start_time'
|
||||
protected static readonly UPDATED_AT = null // No updated at
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected session_key!: string
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id?: number
|
||||
|
||||
@Field(Type.timestamp)
|
||||
protected start_time!: Date
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
export * from 'daton-lib/module.ts'
|
||||
export * from 'daton/di/module.ts'
|
||||
|
||||
import * as std from 'daton-external/std.ts'
|
||||
export { std }
|
||||
|
||||
export * as Daton from 'daton-lib/mod.ts'
|
@ -0,0 +1 @@
|
||||
export * from 'daton-orm/module.ts'
|
@ -0,0 +1,14 @@
|
||||
export { default as ConfigUnit } from 'daton-lib/unit/Config.ts'
|
||||
export { DatabaseUnit } from 'daton-orm/DatabaseUnit.ts'
|
||||
export { default as ControllerUnit } from 'daton-lib/unit/Controllers.ts'
|
||||
export { default as MiddlewareUnit } from 'daton-lib/unit/Middlewares.ts'
|
||||
export { default as RoutesUnit } from 'daton-lib/unit/Routes.ts'
|
||||
export { default as HttpKernelUnit } from 'daton-lib/unit/HttpKernel.ts'
|
||||
export { default as ModelsUnit } from 'daton-orm/ModelsUnit.ts'
|
||||
export { default as HttpServerUnit } from 'daton-lib/unit/HttpServer.ts'
|
||||
export { default as RoutingUnit } from 'daton-lib/unit/Routing.ts'
|
||||
export { default as ServicesUnit } from 'daton-lib/unit/Services.ts'
|
||||
export { default as ViewEngineUnit } from 'daton-lib/unit/ViewEngine.ts'
|
||||
export { default as DatonMiddlewareUnit } from 'daton-lib/unit/DatonMiddleware.ts'
|
||||
export { default as CLIAppUnit } from 'daton-cli/CLIAppUnit.ts'
|
||||
export { default as CLIUnit } from 'daton-cli/CLIUnit.ts'
|
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env -S deno run -c ./tsconfig.json --unstable --allow-read --allow-env --allow-net --importmap=./import-map.json
|
||||
/* Main executable for the Daton app. */
|
||||
|
||||
import { make, Scaffolding, Application } from './bundle/daton.ts'
|
||||
import { CLIAppUnit } from './bundle/daton_units.ts'
|
||||
import units from './units.ts'
|
||||
|
||||
units.pop()
|
||||
units.push(CLIAppUnit)
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Daton will automatically load and process application resources, which is
|
||||
* why we need to pass in the base path of this script.
|
||||
*/
|
||||
const scaffolding = make(Scaffolding, import.meta.url)
|
||||
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()
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"imports": {
|
||||
"daton/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/",
|
||||
"daton-lib/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/lib/src/",
|
||||
"daton-di/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/di/src/",
|
||||
"daton-orm/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/orm/src/",
|
||||
"daton-cli/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/cli/src/",
|
||||
"daton-external/": "https://code.garrettmills.dev/garrettmills/daton/raw/branch/master/lib/src/external/"
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"imports": {
|
||||
"daton/": "file:///home/garrettmills/Projects/daton/",
|
||||
"daton-lib/": "file:///home/garrettmills/Projects/daton/lib/src/",
|
||||
"daton-di/": "file:///home/garrettmills/Projects/daton/di/src/",
|
||||
"daton-orm/": "file:///home/garrettmills/Projects/daton/orm/src/",
|
||||
"daton-cli/": "file:///home/garrettmills/Projects/daton/cli/src/",
|
||||
"daton-external/": "file:///home/garrettmills/Projects/daton/lib/src/external/"
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env -S deno run -c ./tsconfig.json --unstable --allow-read --allow-env --allow-net --importmap=./import-map.json
|
||||
/* 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.
|
||||
*
|
||||
* Daton will automatically load and process application resources, which is
|
||||
* why we need to pass in the base path of this script.
|
||||
*/
|
||||
const scaffolding = make(Scaffolding, import.meta.url)
|
||||
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()
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
import {
|
||||
ConfigUnit,
|
||||
DatabaseUnit,
|
||||
ControllerUnit,
|
||||
MiddlewareUnit,
|
||||
RoutesUnit,
|
||||
HttpKernelUnit,
|
||||
ModelsUnit,
|
||||
HttpServerUnit,
|
||||
RoutingUnit,
|
||||
ServicesUnit,
|
||||
ViewEngineUnit,
|
||||
DatonMiddlewareUnit,
|
||||
CLIUnit,
|
||||
} from './bundle/daton_units.ts'
|
||||
|
||||
export default [
|
||||
ServicesUnit,
|
||||
ConfigUnit,
|
||||
CLIUnit,
|
||||
DatabaseUnit,
|
||||
ModelsUnit,
|
||||
ViewEngineUnit,
|
||||
HttpKernelUnit,
|
||||
DatonMiddlewareUnit,
|
||||
MiddlewareUnit,
|
||||
ControllerUnit,
|
||||
RoutesUnit,
|
||||
RoutingUnit,
|
||||
HttpServerUnit,
|
||||
]
|
Loading…
Reference in new issue