Skip to content

Instantly share code, notes, and snippets.

@iMichaelOwolabi
Last active March 31, 2020 22:53
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/040e32c9508f8b8f9507ec82dfca5b40 to your computer and use it in GitHub Desktop.
Save iMichaelOwolabi/040e32c9508f8b8f9507ec82dfca5b40 to your computer and use it in GitHub Desktop.
User registration
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