import path from 'path' ; import express from 'express' ; import prostgles from "prostgles-server" ; process . on ( 'unhandledRejection' , ( reason , p ) => { console . trace ( 'Unhandled Rejection at:' , p , 'reason:' , reason ) ; process . exit ( 1 ) ; } ) ; const app = express ( ) ; app . use ( express . json ( ) ) ; app . use ( express . urlencoded ( { extended : true } ) ) ; const _http = require ( "http" ) ; const http = _http . createServer ( app ) ; const io = require ( "socket.io" ) ( http , { path : "/teztz/s" , } ) ; http . listen ( process . env . NPORT || 3000 ) ; const log = ( msg , extra ? ) => { console . log ( ... [ "(server): " + msg , extra ] . filter ( v => v ) ) ; } ; import { DBObj } from "./DBoGenerated" ; prostgles < DBObj > ( { dbConnection : { host : process . env . POSTGRES_HOST || "localhost" , port : + process . env . POSTGRES_PORT || 5432 , database : process . env . POSTGRES_DB || "postgres" , user : process . env . POSTGRES_USER || "api" , password : process . env . POSTGRES_PASSWORD || "api" , application_name : "hehe" + Date . now ( ) } , io , tsGeneratedTypesDir : path . join ( __dirname + '/' ) , sqlFilePath : path . join ( __dirname + '/init.sql' ) , publishRawSQL : async ( params ) => { return true ; } , publish : async ( params ) => { return { items_with_one_media : { insert : "*" } , media : "*" , uuid_text : { insert : { fields : "*" , forcedData : { id : 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' } } } } ; } , joins : "inferred" , fileTable : { localConfig : { localFolderPath : path . join ( __dirname + '/media' ) , } , expressApp : app , referencedTables : { various : "one" , items_m1 : "many" , items_with_one_media : "one" , items_with_media : "one" , skills : "many" , } } , transactions : true , tableConfig : { uuid_text : { columns : { name : { info : { min : 1 , max : 3 , hint : "hiint" } } } } } , onReady : async ( db , _db ) => { app . get ( '*' , function ( req , res ) { log ( req . originalUrl ) ; res . sendFile ( path . join ( __dirname + '/index.html' ) ) ; } ) ; setTimeout ( async ( ) => { try { console . log ( await db . uuid_text . getColumns ( ) ) ; } catch ( e ) { console . error ( e ) ; } } , 2000 ) ; try { } catch ( e ) { console . error ( e ) ; } } , } ) ;