Necessitates Proper Modularity

    automapper

    1.0.0 • Public • Published

    # Automapper clone for NodeJs # License goes to http://johnkalberer.com/?p=47

    # Usage

    1- Require mapper module

    const mapper = require('automapper');
    

    2- Define mapping

     mapper.createMap("body", "user")
           .forMember("userName", function () { this.mapFrom("username"); });
    

    3- Using mapper

    //could be actual body from req object
    var body = {
        username: 'ahmed'
    };
    
    var user = {
      userName: null
    };
    
    mapper.map("body", "user", body, user);
    
    now user.userName has the value 'ahmed'
    

    Install

    npm i automapper

    DownloadsWeekly Downloads

    227

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • mustafamagdy