Skip to content

Instantly share code, notes, and snippets.

@iMichaelOwolabi
Last active September 13, 2020 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iMichaelOwolabi/3e69629b5574a13b401e8c193b99b854 to your computer and use it in GitHub Desktop.
Save iMichaelOwolabi/3e69629b5574a13b401e8c193b99b854 to your computer and use it in GitHub Desktop.
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