Add view engine unit - handlebars - and response helpers
This commit is contained in:
@@ -8,3 +8,4 @@ export { default as ModelsUnit } from '../../orm/src/ModelsUnit.ts'
|
||||
export { default as HttpServerUnit } from '../../lib/src/unit/HttpServer.ts'
|
||||
export { default as RoutingUnit } from '../../lib/src/unit/Routing.ts'
|
||||
export { default as ServicesUnit } from '../../lib/src/unit/Services.ts'
|
||||
export { default as ViewEngineUnit } from '../../lib/src/unit/ViewEngine.ts'
|
||||
|
||||
11
app/http/controllers/Home.controller.ts
Normal file
11
app/http/controllers/Home.controller.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import Controller from '../../../lib/src/http/Controller.ts'
|
||||
import {Request} from '../../../lib/src/http/Request.ts'
|
||||
import {view} from '../../../lib/src/http/response/helpers.ts'
|
||||
|
||||
export default class HomeController extends Controller {
|
||||
|
||||
get_home(request: Request) {
|
||||
return view('home', { request })
|
||||
}
|
||||
|
||||
}
|
||||
9
app/http/routes/home.routes.ts
Normal file
9
app/http/routes/home.routes.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { RouterDefinition } from '../../../lib/src/http/type/RouterDefinition.ts'
|
||||
|
||||
export default {
|
||||
prefix: '/',
|
||||
middleware: [],
|
||||
get: {
|
||||
'/': 'controller::Home.get_home',
|
||||
},
|
||||
} as RouterDefinition
|
||||
1
app/http/views/home.hbs
Normal file
1
app/http/views/home.hbs
Normal file
@@ -0,0 +1 @@
|
||||
<h1>Welcome to Daton!</h1>
|
||||
0
app/http/views/layouts/.gitkeep
Normal file
0
app/http/views/layouts/.gitkeep
Normal file
14
app/http/views/layouts/main.hbs
Normal file
14
app/http/views/layouts/main.hbs
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{{#if title}}
|
||||
<title>{{ title }} | Daton</title>
|
||||
{{else}}
|
||||
<title>Daton</title>
|
||||
{{/if}}
|
||||
</head>
|
||||
<body>
|
||||
{{{ body }}}
|
||||
</body>
|
||||
</html>
|
||||
0
app/http/views/partials/.gitkeep
Normal file
0
app/http/views/partials/.gitkeep
Normal file
@@ -9,6 +9,7 @@ import {
|
||||
HttpServerUnit,
|
||||
RoutingUnit,
|
||||
ServicesUnit,
|
||||
ViewEngineUnit,
|
||||
} from './bundle/daton_units.ts'
|
||||
|
||||
export default [
|
||||
@@ -19,6 +20,7 @@ export default [
|
||||
HttpKernelUnit,
|
||||
MiddlewareUnit,
|
||||
ControllerUnit,
|
||||
ViewEngineUnit,
|
||||
RoutesUnit,
|
||||
RoutingUnit,
|
||||
HttpServerUnit,
|
||||
|
||||
Reference in New Issue
Block a user