Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const bodyParser = require('body-parser');
- const app = express();
- app.use(bodyParser.json());
- const database = {
- users: [
- {
- id: 1,
- name: 'John',
- email: 'john@gmail.com',
- password: 'password123',
- entries: 0,
- joined: new Date()
- },
- {
- id: 2,
- name: 'Sally',
- email: 'sally@gmail.com',
- password: 'password321',
- entries: 0,
- joined: new Date()
- }
- ]
- }
- app.get('/', (req, res) => {
- res.send('this is working');
- })
- app.post('/signin', (req, res) => {
- if(req.body.email === database.users[0].email &&
- req.body.password === database.users[0].password) {
- res.json('success');
- } else {
- res.status(400).json('error');
- }
- })
- app.listen(3001, () => {
- console.log("App is running on port 3001!");
- })
- /*
- / --> res = this is working
- /signin --> POST = success/fail
- /register --> POST = new user
- /profile/:userID --> GET = user profile
- /image --> PUT = updated user object
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement