Initial commit
This commit is contained in:
10
app/http/controllers/Home.controller.ts
Normal file
10
app/http/controllers/Home.controller.ts
Normal 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' })
|
||||
}
|
||||
|
||||
}
|
||||
9
app/http/middleware/Test.middleware.ts
Normal file
9
app/http/middleware/Test.middleware.ts
Normal 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.')
|
||||
}
|
||||
}
|
||||
}
|
||||
11
app/http/routes/home.routes.ts
Normal file
11
app/http/routes/home.routes.ts
Normal 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
9
app/http/views/home.hbs
Normal 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>
|
||||
37
app/http/views/partials/header.hbs
Normal file
37
app/http/views/partials/header.hbs
Normal 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>
|
||||
Reference in New Issue
Block a user