Last active
September 13, 2020 20:52
-
-
Save iMichaelOwolabi/3e69629b5574a13b401e8c193b99b854 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const sendSms = require('./twilio'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
const port = 3000; | |
const userDatabase = []; | |
// Create users endpoint | |
app.post('/users', (req, res) => { | |
const { email, password, phone } = req.body; | |
const user = { | |
email, | |
password, | |
phone | |
}; | |
userDatabase.push(user); | |
const welcomeMessage = 'Welcome to Chillz! Your verification code is 54875'; | |
sendSms(user.phone, welcomeMessage); | |
res.status(201).send({ | |
message: 'Account created successfully, kindly check your phone to activate your account!', | |
data: user | |
}) | |
}); | |
app.listen(port, () => { | |
console.log(`Server running on port ${port}`); | |
}); | |
module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment