Skip to content

Commit

Permalink
Start
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Jun 20, 2024
1 parent 3aeb75e commit d9f985c
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 3 deletions.
29 changes: 28 additions & 1 deletion src/Front/Library/Crazyrequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Crazyrequest{
method: "get",
header: {},
cache: false,
responseType: "json",
responseType: "*",
responseEncoding: "utf8",
from: "internal"
};
Expand Down Expand Up @@ -304,6 +304,33 @@ export default class Crazyrequest{

}

// Check responseType
if(this.options.responseType && typeof this.options.responseType === "string"){

// Set accept header
let acceptHeaderValues = "";

// Check if all
if(this.options.responseType === "*")

// Set accept
acceptHeaderValues = "*/*";

else
// Check if json
if(this.options.responseType === "json")

// Set accept
acceptHeaderValues = "application/json";

// Check acceptHeaderValues
if(acceptHeaderValues)

// Push into header
this.requestOptions.headers.set("Accept", acceptHeaderValues);

}

// Check cache
if(this.options.cache === false){

Expand Down
28 changes: 27 additions & 1 deletion src/Front/Library/Utility/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Dependances
*/
import {default as NavigatorClient} from "./../Navigator/Client";
import {default as UtilityProcess} from "./Process";
import {default as UtilityProcess} from "./Process"

/**
* Runner
Expand Down Expand Up @@ -306,6 +306,32 @@ export default class Runner {

}

/** Public methods | Errors
******************************************************
*/

public checkQueryError = async (data:any, options:RunnerOption):Promise<RunnerOption> => {

// Check data
if(typeof data === "object" && "errors" in data && Object.keys(data.errors).length){

// Check viewer
if(this.viewer)

// Share error with viewer
// @ts-ignore
this.viewer.errors(data.errors);

// Reject the promise chain
throw 'Runner failed';

}

// Return object
return options;

}

/** Public methods | Options
******************************************************
*/
Expand Down
57 changes: 56 additions & 1 deletion src/Front/Types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare global {
method?: "get"|"GET"|"post"|"POST"|"put"|"PUT"|"delete"|"DELETE",
header?: object,
cache?: "local"|"session"|boolean,
responseType?: "arraybuffer"|"document"|"json"|"text"|"stream"|boolean,
responseType?: "arraybuffer"|"document"|"json"|"text"|"stream"|false|"*",
responseEncoding?: "utf8",
from?: "internal"|"external",
ignoreHash?: boolean
Expand Down Expand Up @@ -302,6 +302,61 @@ declare global {
}
}

/** Interface | Crazy Runner Viewer
******************************************************
*/

/**
* Crazy Runner Viewer
*/
interface CrazyRunnerViewer {

/** Public methods
******************************************************
*/

/**
* Open Viewer
*
* @param data:string
* @returns {void}
*/
public open(data?:CrazyRunnerViewerOptions):void;

/**
* Close Viewer
*
* @param data:string
* @returns {void}
*/
public close(data?:CrazyRunnerViewerOptions):void;

/**
* Update Viewer
*
* @param data:string
* @returns {void}
*/
public update(data?:CrazyRunnerViewerOptions):void;

/**
* Errors
*
* @param errors:string
* @param data:string
* @returns {void}
*/
public errors(errors:Array<object>, data?:CrazyRunnerViewerOptions):void;

}

/**
* Crazy Runner Viewer Options
*/
interface CrazyRunnerViewerOptions {

};



}

0 comments on commit d9f985c

Please sign in to comment.