Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const express = require('express'),
- bodyParser = require('body-parser'),
- morgan = require('morgan'),
- db = require('./db.js'),
- router = require('../routes/index');
- const app = express();
- const PORT = 7500;
- app.use(morgan('combined'));
- app.use(bodyParser.json());
- app.use((req, res, next) => {
- res.header('Content-Type', 'application/json');
- next();
- });
- router(app, db);
- //drop and resync with { force: true }
- db.sequelize.sync({
- force: false
- }).then(() => {
- app.listen(PORT, () => {
- console.log('We are live on port :', PORT);
- });
- });
- /* CREATE an account */
- app.post('/create_account', function (req, res) {
- // Grab data from http request
- const data = {
- username: req.body.username,
- name: req.body.name,
- firstname: req.body.firstname,
- email: req.body.email,
- location: req.body.location,
- type: req.body.type
- };
- db.users.create({
- username: data.username,
- name: data.name,
- firstname: data.firstname,
- email: data.email,
- location: data.location,
- type: data.type
- }).then(newUser => {
- res.json(newUser);
- });
- });
Add Comment
Please, Sign In to add comment