Initial commit

This commit is contained in:
2020-10-05 11:44:05 -05:00
commit 5917935505
29 changed files with 385 additions and 0 deletions

View File

@@ -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' })
}
}

View File

@@ -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.')
}
}
}

View File

@@ -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

9
app/http/views/home.hbs Normal file
View File

@@ -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>

View File

@@ -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>