Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Beta Version
Browse files Browse the repository at this point in the history
  • Loading branch information
Yovangga Anandhika committed Oct 19, 2022
1 parent 50bbc16 commit 1602467
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 38 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dkaframework/server",
"description": "The Multi Framework Server Function. Part Module Of DKAFramework",
"version": "1.0.39",
"version": "1.0.46",
"main": "dist/index.js",
"homepage": ".",
"types": "dist/index.d.ts",
Expand All @@ -15,7 +15,10 @@
"dev-fastify": "ts-node test/index.fastify.ts",
"dev-client": "ts-node test/index-client.ts",
"test:react": "ts-node test/REACT/index.ts",
"build": "tsc --build && tscp"
"action:clean": "tsc --build --clean",
"action:compile": "tsc --build",
"action:copy" : "tscp",
"build": "yarn run action:clean && yarn run action:compile && yarn run action:copy"
},
"dependencies": {
"@babel/core": "^7.19.3",
Expand Down
10 changes: 2 additions & 8 deletions src/Component/REACTJS/Component/Webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import {ConfigReactJSOptionsWebpackConfiguration} from "../../../Interfaces/Conf
export async function Webpack(config : ConfigReactJSOptionsWebpackConfiguration) : Promise<Compiler> {
let mCompiler : Compiler;
return new Promise(async (resolve, rejected) => {

mCompiler = await webpack(config, async (error,stats) => {
if (!error){
resolve(mCompiler);
}else{
rejected({ status : false, code : 500, msg : `error processing stats Webpack compile`, error : error});
}
})
mCompiler = await webpack(config)
resolve(mCompiler);
})
}
9 changes: 9 additions & 0 deletions src/Component/REACTJS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ export const REACTJS = async (config : ConfigReactJS) : Promise<webpackDev>=> {
infrastructureLogging: {
level: "error"
},
performance : {
hints: false
},
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000,
}
},
stats: "errors-only",
output: {
publicPath: "/",
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Config/Fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ConfigFastify {
* The State Development or Production
* **/
state ?: State,
engine : EngineFastify,
engine ?: EngineFastify | undefined,
host ?: string | undefined,
port ?: number | string | undefined,
app ?: FastifyInstances,
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Config/ReactJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface ConfigReactJS {
state? : State,
host ?: string | undefined,
port ?: number | undefined,
engine : EngineReactJS,
engine ?: EngineReactJS | undefined,
entry ?:
| string
| (() => string | WebpackEntryObject | string[] | Promise<string | WebpackEntryObject | string[]>)
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Config/SocketIO/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ConfigSocketIOClient {
* The State Development or Production
* **/
state? : State,
engine : EngineSocketIOClient,
engine ?: EngineSocketIOClient | undefined,
host ?: string | undefined,
port ?: number | undefined,
io ?: SocketIOInstancesClient | undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Config/SocketIO/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface ConfigSocketIO {
* The State Development or Production
* **/
state? : State,
engine : EngineSocketIO,
engine ?: EngineSocketIO | undefined,
port? : number | Server,
io? : SocketIOInstances,
onConnection ?: (io : SocketIOInstanceSocket) => Promise<void> | void | undefined,
Expand Down
24 changes: 4 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,10 @@ let mTempSocketIO : ConfigSocketIO = { engine : "SOCKET.IO" };
let mTempSocketIOClient : ConfigSocketIOClient = { engine : "SOCKET.IO-CLIENT"};
let mTempReactJS : ConfigReactJS = { engine : "REACTJS" };
let logger : Logger = mLogger.logger;
function checkModuleExist(name : string){
try {
require.resolve(name);
return true;
}catch (e) {
return false;
}
}
/**
* @function Server
* @typedef { Config }
* @return Promise<ServerCallback>
*
*/

export async function Server(config : ConfigFastify | ConfigSocketIO | ConfigReactJS = FastifyConfigurationDefault) : Promise<DKAServerCallback> {
return new Promise(async (resolve, rejected) => {
switch (config.engine) {
case "FASTIFY":
break;
case "SOCKET.IO":
break;
case "REACTJS":
break;
case Options.Server.Engine.FASTIFY :
//## Set Configuration merger
mTempFastify = await merge(FastifyConfigurationDefault, config);
Expand Down Expand Up @@ -411,6 +391,10 @@ export async function Client(config : ConfigSocketIOClient = SocketIOClientConfi
}, 2000);
})
break;
default :
await rejected({ status : false, code : 500, msg : `illegal method unknown or not available`});
//await process.exit(0)
break;
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion test/REACT/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import {createRoot} from 'react-dom/client';

let DOM = createRoot(document.getElementById('dka'))
let container = document.getElementById('dka');
let DOM = createRoot(container!)
DOM.render(<h1>Halo Dunia</h1>)

4 changes: 2 additions & 2 deletions test/REACT/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Options, Server} from "../../src";
import {Options, Server} from "../..";
import path from "path";

(async () => {

let io = await Server({
await Server({
state : Options.Server.State.SERVER_STATE_DEVELOPMENT,
engine : Options.Server.Engine.REACTJS,
entry : path.join(__dirname, "./app.tsx"),
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"lib": ["es2017", "es7", "es5", "es6", "dom"],
// Tells TypeScript to read JS files, as
// Generate d.ts files
"removeComments": false,
"declaration": true,
"jsx": "react",
"rootDir": "src",
Expand Down

0 comments on commit 1602467

Please sign in to comment.