specs for donors model
This commit is contained in:
@@ -18,10 +18,7 @@ exports.create = (req, res) => {
|
||||
});
|
||||
} else {
|
||||
// hash and store
|
||||
bcrypt.hash(req.body.password, null, null, function(
|
||||
error,
|
||||
hash
|
||||
) {
|
||||
bcrypt.hash(req.body.password, null, null, function(error, hash) {
|
||||
// Store hash in your password DB.
|
||||
if (error) {
|
||||
return res.status(500).json({
|
||||
@@ -49,8 +46,6 @@ exports.create = (req, res) => {
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
|
||||
return res.status(500).json({
|
||||
error
|
||||
});
|
||||
@@ -60,8 +55,6 @@ exports.create = (req, res) => {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
|
||||
return res.status(500).json({
|
||||
error
|
||||
});
|
||||
|
||||
+39
-24
@@ -1,25 +1,40 @@
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Donors = sequelize.define('donors', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
first_name: DataTypes.STRING,
|
||||
middle_name: DataTypes.STRING,
|
||||
last_name: DataTypes.STRING,
|
||||
email: DataTypes.STRING,
|
||||
password: DataTypes.STRING,
|
||||
age: DataTypes.INTEGER,
|
||||
phone: DataTypes.BIGINT,
|
||||
address: DataTypes.STRING,
|
||||
city: DataTypes.STRING,
|
||||
state: DataTypes.STRING,
|
||||
country: DataTypes.STRING
|
||||
},
|
||||
{
|
||||
freezeTableName: true,
|
||||
}
|
||||
);
|
||||
return Donors;
|
||||
}
|
||||
const Donors = sequelize.define(
|
||||
'donors',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
first_name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
middle_name: DataTypes.STRING,
|
||||
last_name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
isEmail: true,
|
||||
allowNull: false
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
age: DataTypes.INTEGER,
|
||||
phone: DataTypes.BIGINT,
|
||||
address: DataTypes.STRING,
|
||||
city: DataTypes.STRING,
|
||||
state: DataTypes.STRING,
|
||||
country: DataTypes.STRING
|
||||
},
|
||||
{
|
||||
freezeTableName: true
|
||||
}
|
||||
);
|
||||
return Donors;
|
||||
};
|
||||
|
||||
@@ -17,10 +17,7 @@ app.use((req, res, next) => {
|
||||
);
|
||||
|
||||
if (req.method == 'OPTIONS') {
|
||||
res.header(
|
||||
'Access-Control-Allow-Methods',
|
||||
'PUT, POST, GET, DELETE, PATCH'
|
||||
);
|
||||
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, PATCH');
|
||||
return res.status(200).json({});
|
||||
}
|
||||
|
||||
@@ -52,6 +49,21 @@ app.get('/', function(req, res, next) {
|
||||
app.use('/api/donors', require('./app/routes/donors.route.js'));
|
||||
app.use('/api/auth', require('./app/routes/auth.route.js'));
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const error = new Error('Not found');
|
||||
error.status = 404;
|
||||
next(error);
|
||||
});
|
||||
|
||||
app.use((error, req, res, next) => {
|
||||
res.status(error.status || 500);
|
||||
res.json({
|
||||
error: {
|
||||
message: error.message
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Create a Server
|
||||
var server = app.listen(port, function() {
|
||||
var host = server.address().address;
|
||||
|
||||
Reference in New Issue
Block a user