From 90ded11faee40793953002991d905b17896b23ee Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sat, 5 Sep 2020 10:52:01 -0500 Subject: [PATCH] remove example app --- app/assets/.gitignore | 2 -- app/bundle/daton.ts | 5 ----- app/bundle/daton_units.ts | 12 ---------- app/configs/app.config.ts | 27 ---------------------- app/configs/db.config.ts | 16 ------------- app/configs/server.config.ts | 18 --------------- app/http/controllers/Api.controller.ts | 25 --------------------- app/http/controllers/Home.controller.ts | 13 ----------- app/http/controllers/Test.controller.ts | 18 --------------- app/http/middleware/Test.middleware.ts | 12 ---------- app/http/routes/home.routes.ts | 11 --------- app/http/views/home.hbs | 6 ----- app/http/views/partials/header.hbs | 3 --- app/index.ts | 23 ------------------- app/models/LoginAttempt.model.ts | 27 ---------------------- app/models/User.model.ts | 30 ------------------------- app/models/http/Session.model.ts | 20 ----------------- app/tsconfig.json | 8 ------- app/units.ts | 29 ------------------------ 19 files changed, 305 deletions(-) delete mode 100644 app/assets/.gitignore delete mode 100644 app/bundle/daton.ts delete mode 100644 app/bundle/daton_units.ts delete mode 100644 app/configs/app.config.ts delete mode 100644 app/configs/db.config.ts delete mode 100644 app/configs/server.config.ts delete mode 100644 app/http/controllers/Api.controller.ts delete mode 100644 app/http/controllers/Home.controller.ts delete mode 100644 app/http/controllers/Test.controller.ts delete mode 100644 app/http/middleware/Test.middleware.ts delete mode 100644 app/http/routes/home.routes.ts delete mode 100644 app/http/views/home.hbs delete mode 100644 app/http/views/partials/header.hbs delete mode 100755 app/index.ts delete mode 100644 app/models/LoginAttempt.model.ts delete mode 100644 app/models/User.model.ts delete mode 100644 app/models/http/Session.model.ts delete mode 100755 app/tsconfig.json delete mode 100644 app/units.ts diff --git a/app/assets/.gitignore b/app/assets/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/assets/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/app/bundle/daton.ts b/app/bundle/daton.ts deleted file mode 100644 index a7dbf5b..0000000 --- a/app/bundle/daton.ts +++ /dev/null @@ -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 } diff --git a/app/bundle/daton_units.ts b/app/bundle/daton_units.ts deleted file mode 100644 index 47d00e8..0000000 --- a/app/bundle/daton_units.ts +++ /dev/null @@ -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' diff --git a/app/configs/app.config.ts b/app/configs/app.config.ts deleted file mode 100644 index 8a1b5f8..0000000 --- a/app/configs/app.config.ts +++ /dev/null @@ -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', - }, -} diff --git a/app/configs/db.config.ts b/app/configs/db.config.ts deleted file mode 100644 index 983fa12..0000000 --- a/app/configs/db.config.ts +++ /dev/null @@ -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), - } - } - -} diff --git a/app/configs/server.config.ts b/app/configs/server.config.ts deleted file mode 100644 index 3ad5062..0000000 --- a/app/configs/server.config.ts +++ /dev/null @@ -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 - }, -} diff --git a/app/http/controllers/Api.controller.ts b/app/http/controllers/Api.controller.ts deleted file mode 100644 index 9908d19..0000000 --- a/app/http/controllers/Api.controller.ts +++ /dev/null @@ -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') - } - -} diff --git a/app/http/controllers/Home.controller.ts b/app/http/controllers/Home.controller.ts deleted file mode 100644 index ae1ddf8..0000000 --- a/app/http/controllers/Home.controller.ts +++ /dev/null @@ -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' }) - } - -} diff --git a/app/http/controllers/Test.controller.ts b/app/http/controllers/Test.controller.ts deleted file mode 100644 index ab393a0..0000000 --- a/app/http/controllers/Test.controller.ts +++ /dev/null @@ -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('

Hi!

') - } - - get_user_home(request: Request) { - return http(401, 'You should not be here!') - } - - create_user_home(request: Request) { - return http(401) - } -} diff --git a/app/http/middleware/Test.middleware.ts b/app/http/middleware/Test.middleware.ts deleted file mode 100644 index 0a5c949..0000000 --- a/app/http/middleware/Test.middleware.ts +++ /dev/null @@ -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.') - } - } -} diff --git a/app/http/routes/home.routes.ts b/app/http/routes/home.routes.ts deleted file mode 100644 index 230c34e..0000000 --- a/app/http/routes/home.routes.ts +++ /dev/null @@ -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 diff --git a/app/http/views/home.hbs b/app/http/views/home.hbs deleted file mode 100644 index ca7dadb..0000000 --- a/app/http/views/home.hbs +++ /dev/null @@ -1,6 +0,0 @@ - - {{> header }} - -

{{ greeting }} from Daton!

- - \ No newline at end of file diff --git a/app/http/views/partials/header.hbs b/app/http/views/partials/header.hbs deleted file mode 100644 index 444e9b8..0000000 --- a/app/http/views/partials/header.hbs +++ /dev/null @@ -1,3 +0,0 @@ - - Daton - diff --git a/app/index.ts b/app/index.ts deleted file mode 100755 index adfc2ae..0000000 --- a/app/index.ts +++ /dev/null @@ -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() diff --git a/app/models/LoginAttempt.model.ts b/app/models/LoginAttempt.model.ts deleted file mode 100644 index 6ef3867..0000000 --- a/app/models/LoginAttempt.model.ts +++ /dev/null @@ -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 { - 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') - } -} diff --git a/app/models/User.model.ts b/app/models/User.model.ts deleted file mode 100644 index ec0f0b4..0000000 --- a/app/models/User.model.ts +++ /dev/null @@ -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 { - 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) - } -} diff --git a/app/models/http/Session.model.ts b/app/models/http/Session.model.ts deleted file mode 100644 index 76286c2..0000000 --- a/app/models/http/Session.model.ts +++ /dev/null @@ -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 -} diff --git a/app/tsconfig.json b/app/tsconfig.json deleted file mode 100755 index 04073ec..0000000 --- a/app/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "emitDecoratorMetadata": true - } -} - - diff --git a/app/units.ts b/app/units.ts deleted file mode 100644 index a21750d..0000000 --- a/app/units.ts +++ /dev/null @@ -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, -]