remove example app
This commit is contained in:
parent
24762e4911
commit
90ded11fae
2
app/assets/.gitignore
vendored
2
app/assets/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
@ -1,5 +0,0 @@
|
|||||||
export * from '../../lib/src/module.ts'
|
|
||||||
export * from '../../di/module.ts'
|
|
||||||
|
|
||||||
import * as std from '../../lib/src/external/std.ts'
|
|
||||||
export { std }
|
|
@ -1,12 +0,0 @@
|
|||||||
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'
|
|
||||||
export { default as RoutesUnit } from '../../lib/src/unit/Routes.ts'
|
|
||||||
export { default as HttpKernelUnit } from '../../lib/src/unit/HttpKernel.ts'
|
|
||||||
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'
|
|
||||||
export { default as DatonMiddlewareUnit } from '../../lib/src/unit/DatonMiddleware.ts'
|
|
@ -1,27 +0,0 @@
|
|||||||
import { env } from '../../lib/src/unit/Scaffolding.ts'
|
|
||||||
import {ViewEngine} from '../../lib/src/const/view_engines.ts'
|
|
||||||
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
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
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import BaseApiController from "../../../lib/src/http/ApiController.ts";
|
|
||||||
import {Request} from "../../../lib/src/http/Request.ts";
|
|
||||||
import {redirect} from "../../../lib/src/http/response/helpers.ts";
|
|
||||||
|
|
||||||
export default class ApiController extends BaseApiController {
|
|
||||||
|
|
||||||
get_good(request: Request) {
|
|
||||||
return {
|
|
||||||
session_key: request.session.get_key(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get_arr(request: Request) {
|
|
||||||
return ['alpha', 'bravo', 'charlie', 'delta', 'echo']
|
|
||||||
}
|
|
||||||
|
|
||||||
get_msg(request: Request) {
|
|
||||||
return request.route.params
|
|
||||||
}
|
|
||||||
|
|
||||||
get_redirect(request: Request) {
|
|
||||||
return redirect('/home')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
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'
|
|
||||||
import {Injectable} from '../../../di/module.ts'
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export default class HomeController extends Controller {
|
|
||||||
|
|
||||||
async get_home(request: Request) {
|
|
||||||
return view('home', { greeting: 'Hello' })
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
import Controller from '../../../lib/src/http/Controller.ts'
|
|
||||||
import {Request} from '../../../lib/src/http/Request.ts'
|
|
||||||
import {error, html, http, redirect} from '../../../lib/src/http/response/helpers.ts'
|
|
||||||
|
|
||||||
export default class TestController extends Controller {
|
|
||||||
|
|
||||||
get_home(request: Request) {
|
|
||||||
return html('<h1>Hi!</h1>')
|
|
||||||
}
|
|
||||||
|
|
||||||
get_user_home(request: Request) {
|
|
||||||
return http(401, 'You should not be here!')
|
|
||||||
}
|
|
||||||
|
|
||||||
create_user_home(request: Request) {
|
|
||||||
return http(401)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
import Middleware from '../../../lib/src/http/Middleware.ts'
|
|
||||||
import {Request} from '../../../lib/src/http/Request.ts'
|
|
||||||
import {http} from '../../../lib/src/http/response/helpers.ts'
|
|
||||||
import {HTTPStatus} from '../../../lib/src/const/http.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.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
import { RouterDefinition } from '../../../lib/src/http/type/RouterDefinition.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
|
|
@ -1,6 +0,0 @@
|
|||||||
<html>
|
|
||||||
{{> header }}
|
|
||||||
<body>
|
|
||||||
<h1>{{ greeting }} from Daton!</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,3 +0,0 @@
|
|||||||
<head>
|
|
||||||
<title>Daton</title>
|
|
||||||
</head>
|
|
23
app/index.ts
23
app/index.ts
@ -1,23 +0,0 @@
|
|||||||
#!/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.
|
|
||||||
*
|
|
||||||
* 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()
|
|
@ -1,27 +0,0 @@
|
|||||||
import {Model} from '../../orm/src/model/Model.ts'
|
|
||||||
import {Field} from '../../orm/src/model/Field.ts'
|
|
||||||
import {Type} from '../../orm/src/db/types.ts'
|
|
||||||
import UserModel from "./User.model.ts";
|
|
||||||
import {Relation} from "../../orm/src/model/relation/decorators.ts";
|
|
||||||
|
|
||||||
export default class LoginAttemptModel extends Model<LoginAttemptModel> {
|
|
||||||
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(UserModel, 'login_attempts')
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
import {Model} from '../../orm/src/model/Model.ts'
|
|
||||||
import {Type} from '../../orm/src/db/types.ts'
|
|
||||||
import {Field} from '../../orm/src/model/Field.ts'
|
|
||||||
import LoginAttemptModel from './LoginAttempt.model.ts'
|
|
||||||
import {Relation} from '../../orm/src/model/relation/decorators.ts'
|
|
||||||
|
|
||||||
export default class UserModel extends Model<UserModel> {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import {Field} from '../../../orm/src/model/Field.ts'
|
|
||||||
import {Type} from '../../../orm/src/db/types.ts'
|
|
||||||
import {SessionModel} from '../../../lib/src/module.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
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"emitDecoratorMetadata": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
29
app/units.ts
29
app/units.ts
@ -1,29 +0,0 @@
|
|||||||
import {
|
|
||||||
ConfigUnit,
|
|
||||||
DatabaseUnit,
|
|
||||||
ControllerUnit,
|
|
||||||
MiddlewareUnit,
|
|
||||||
RoutesUnit,
|
|
||||||
HttpKernelUnit,
|
|
||||||
ModelsUnit,
|
|
||||||
HttpServerUnit,
|
|
||||||
RoutingUnit,
|
|
||||||
ServicesUnit,
|
|
||||||
ViewEngineUnit,
|
|
||||||
DatonMiddlewareUnit,
|
|
||||||
} from './bundle/daton_units.ts'
|
|
||||||
|
|
||||||
export default [
|
|
||||||
ServicesUnit,
|
|
||||||
ConfigUnit,
|
|
||||||
DatabaseUnit,
|
|
||||||
ModelsUnit,
|
|
||||||
ViewEngineUnit,
|
|
||||||
HttpKernelUnit,
|
|
||||||
DatonMiddlewareUnit,
|
|
||||||
MiddlewareUnit,
|
|
||||||
ControllerUnit,
|
|
||||||
RoutesUnit,
|
|
||||||
RoutingUnit,
|
|
||||||
HttpServerUnit,
|
|
||||||
]
|
|
Loading…
Reference in New Issue
Block a user