MCPcopy Create free account
hub / github.com/easydiffusion/easydiffusion / checkReqBody

Method checkReqBody

ui/media/js/engine.js:850–882  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

848 }
849
850 checkReqBody() {
851 for (const key in TASK_DEFAULTS) {
852 if (typeof this._reqBody[key] === "undefined") {
853 this._reqBody[key] = TASK_DEFAULTS[key]
854 }
855 }
856 for (const key in TASK_REQUIRED) {
857 if (typeof this._reqBody[key] !== TASK_REQUIRED[key]) {
858 throw new Error(
859 `${key} need to be of type ${TASK_REQUIRED[key]} but ${typeof this._reqBody[key]} was found.`
860 )
861 }
862 }
863 for (const key in this._reqBody) {
864 if (key in TASK_REQUIRED) {
865 continue
866 }
867 if (key in TASK_OPTIONAL) {
868 if (typeof this._reqBody[key] == "undefined") {
869 delete this._reqBody[key]
870 console.warn(`reqBody[${key}] was set to undefined. Removing optional key without value...`)
871 continue
872 }
873 if (typeof this._reqBody[key] !== TASK_OPTIONAL[key]) {
874 throw new Error(
875 `${key} need to be of type ${TASK_OPTIONAL[key]} but ${typeof this._reqBody[
876 key
877 ]} was found.`
878 )
879 }
880 }
881 }
882 }
883
884 /** Send current task to server.
885 * @param {*} [timeout=-1] Optional timeout value in ms

Callers 2

constructorMethod · 0.95
postMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected