typescript-class-helpers
Version:
Usefull helper to have in your typescript project
191 lines • 4.51 kB
JavaScript
// // @ts-nocheck
// //#region imports
// import * as os from 'os'; // @backend
// import { CommonModule } from '@angular/common'; // @browser
// import { NgModule, inject, Injectable } from '@angular/core'; // @browser
// import { Component, OnInit } from '@angular/core'; // @browser
// import { VERSION } from '@angular/core'; // @browser
// import Aura from '@primeng/themes/aura'; // @browser
// import { MaterialCssVarsModule } from 'angular-material-css-vars'; // @browser
// import { providePrimeNG } from 'primeng/config'; // @browser
// import { Observable, map } from 'rxjs';
// import { Taon, TaonBaseContext, TAON_CONTEXT } from 'taon/src';
// import { UtilsOs } from 'tnp-core/src';
// import { HOST_CONFIG } from './app.hosts';
// //#endregion
// console.log('hello world');
// console.log('Your backend host ' + HOST_CONFIG['MainContext'].host);
// console.log('Your frontend host ' + HOST_CONFIG['MainContext'].frontendHost);
// //#region typescript-class-helpers component
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
// //#endregion
// //#region typescript-class-helpers api service
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
// //#endregion
// //#region typescript-class-helpers module
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
// //#endregion
// //#region typescript-class-helpers entity
// @Taon.Entity({ className: 'User' })
// class User extends Taon.Base.AbstractEntity {
// //#region @websql
// @Taon.Orm.Column.String()
// //#endregion
// name?: string;
// }
// //#endregion
// //#region typescript-class-helpers controller
// @Taon.Controller({ className: 'UserController' })
// class UserController extends Taon.Base.CrudController<User> {
// // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
// entityClassResolveFn = () => User;
// @Taon.Http.GET()
// helloWorld(): Taon.Response<string> {
// //#region @websqlFunc
// return async (req, res) => 'hello world';
// //#endregion
// }
// @Taon.Http.GET()
// getOsPlatform(): Taon.Response<string> {
// //#region @websqlFunc
// return async (req, res) => {
// //#region @backend
// return os.platform(); // for normal nodejs backend return real value
// //#endregion
// return 'no-platform-inside-browser-and-websql-mode';
// };
// //#endregion
// }
// }
// //#endregion
// //#region typescript-class-helpers migration
// //#region @websql
// @Taon.Migration({
// className: 'UserMigration',
// })
// class UserMigration extends Taon.Base.Migration {
// userController = this.injectRepo(User);
// async up(): Promise<any> {
// const superAdmin = new User();
// superAdmin.name = 'super-admin';
// await this.userController.save(superAdmin);
// }
// }
// //#endregion
// //#endregion
// //#region typescript-class-helpers context
// var MainContext = Taon.createContext(() => ({
// ...HOST_CONFIG['MainContext'],
// contexts: { TaonBaseContext },
// //#region @websql
// /**
// * This is dummy migration - you DO NOT NEED need this migrations object
// * if you are using HOST_CONFIG['MainContext'] that contains 'migrations' object.
// * DELETE THIS 'migrations' object if you use taon CLI that generates
// * migrations automatically inside /src/migrations folder.
// */
// migrations: {
// UserMigration,
// },
// //#endregion
// controllers: {
// UserController,
// },
// entities: {
// User,
// },
// database: true,
// // disabledRealtime: true,
// }));
// //#endregion
// async function start(startParams?: Taon.StartParams): Promise<void> {
// await MainContext.initialize();
// //#region @backend
// if (
// startParams.onlyMigrationRun ||
// startParams.onlyMigrationRevertToTimestamp
// ) {
// process.exit(0);
// }
// //#endregion
// //#region @backend
// console.log(`Hello in NodeJs backend! os=${os.platform()}`);
// //#endregion
// if (UtilsOs.isBrowser) {
// const users = (
// await MainContext.getClassInstance(UserController).getAll().request()
// ).body?.json;
// console.log({
// 'users from backend': users,
// });
// }
// }
// export default start;
//# sourceMappingURL=app.js.map