Yes, of course, this is possible. Technically, you will first write generated OTP to DB and then you will send it to the user. However, form a performance point of view, I will suggest you, use in-memory databases like Redis. Alternatively, you can store OTPs in your program variables, depending on your need. I published a module named in-memory-otp at NPM for this functionality. You can also take help from there too.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…