Last active
March 31, 2020 22:53
-
-
Save iMichaelOwolabi/040e32c9508f8b8f9507ec82dfca5b40 to your computer and use it in GitHub Desktop.
User registration
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 app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
const port = 3000; | |
const userDatabase = []; | |
// Create user endpoint | |
app.post('/users', (req, res) => { | |
const { email, password, phone } = req.body; | |
const user = { | |
email, | |
password, | |
phone | |
}; | |
userDatabase.push(user); | |
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