var express = require("express");
var app = express();
var morgan = require("morgan");
var mongoose = require("mongoose");
port = 8000;
var User = require("./app/models/user");
mongoose.connect("mongodb://localhost:27017/tutorial", function (err) {
if (err) {
console.log("Disconnected: " + err);
} else {
console.log("connected");
}
});
app.post("/users", function (req, res) {
var user = new User();
user.username = req.body.username;
user.email = req.body.email;
user.password = req.body.password;
user.save();
res.send("user created");
});
app.use(morgan("dev"));
app.listen(port, function () {
console.log("You are listen on port " + port);
});