Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dev handler is library for handling the functions and controller with inbuilt fast testing with it.

Notifications You must be signed in to change notification settings

devjs1000/dev-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EXAMPLE

handleThis({
  name: "create user",
  errMsg: "failed to create user",
  type: "api",
  errorCode: 500,
  senders: { req, res },
  expectedOnPass: "ok",
  expectedOnFailed: 0,
  onSuccess: () => {
    console.log("yeah");
  },
  onFailed: () => {
    console.log("ops");
  },
  fn: async () => {
    const { userName, password } = req.body;
    const usr = new User({ userName, password });
    await usr.save();
    let data = {};
    res.send({ status: true, msg: "Success", data });
    return "ok";
  },
});

##OPTIONS

name : function name or use;
fn : main async fn;
type : api or fn;
note : default is fn;
errMsg : message on error;
note: this is required;
senders : {req, res};
note: only required in apis;
returnOnPass : value will be returned on pass;
note: this value  will be returned on pass of your fn;
returnOnFailed : value will be return on fail;
note: this value  will be returned on fail of your fn;
onSuccess : this function will be called on success;
note: this is optional;
onFailed : this function will be called on failure;
note: this is optional;
expectedOnPass: expected return value on success from your main fn;
note: this is optional but recommended;
expectedOnFailed: expected return value on failure from your main fn;
note: this is optional but recommended;

About

dev handler is library for handling the functions and controller with inbuilt fast testing with it.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published