Giter Site home page Giter Site logo

boiler-plate's Introduction

Hi there πŸ‘‹

boiler-plate's People

Contributors

btiac1129 avatar

Watchers

 avatar

boiler-plate's Issues

mongooseμ—μ„œ arrow function을 μ‚¬μš©ν•  λ•Œ /api/users/register post μš”μ²­μ΄ μ‹€νŒ¨ν•˜λŠ” 이유

userSchema.pre("save", function(next) {
    var user = this;

    if (user.isModified("password")) {
        // λΉ„λ°€λ²ˆν˜Έλ₯Ό μ•”ν˜Έν™” μ‹œν‚¨λ‹€.
        bcrypt.genSalt(saltRounds, function(err, salt) {
            if (err) return next(err);

            bcrypt.hash(user.password, salt, function(err, hash) {
                if (err) return next(err);
                user.password = hash;
                next();
            });
        });
    } else {
        next();
    }
});

μžλ°”μŠ€ν¬λ¦½νŠΈ μ½”λ“œμ—μ„œ arrow function은 function ν‘œν˜„μ‹κ³Ό λ‹€λ₯΄κ²Œ thisλ₯Ό λ°”μΈλ”©ν•˜μ§€ μ•ŠλŠ”λ‹€. λ‹€μ‹œ λ§ν•΄μ„œ ν™”μ‚΄ν‘œ ν•¨μˆ˜λŠ” μžμ‹ μ˜ thisλ₯Ό 가지고 μžˆμ§€ μ•Šλ‹€. (= λ°”μΈλ“œ ν•˜μ§€ μ•ŠλŠ”λ‹€.)

그리고 ν™”μ‚΄ν‘œ ν•¨μˆ˜λŠ” 항상 읡λͺ…이며, 이 ν•¨μˆ˜ ν‘œν˜„μ€ λ©”μ†Œλ“œ ν•¨μˆ˜κ°€ μ•„λ‹Œ 곳에 κ°€μž₯ μ ν•©ν•˜λ‹€.

μœ„μ˜ μ½”λ“œλ₯Ό ν™”μ‚΄ν‘œ ν•¨μˆ˜λ‘œ μž‘μ„±ν–ˆλ‹€κ°€ function ν‘œν˜„μ‹μœΌλ‘œ λ°”κΏ”μ£Όλ‹ˆ post μš”μ²­μ΄ μ„±κ³΅ν–ˆλ‹€.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.