-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Contra
committed
Jun 7, 2013
1 parent
fa557bb
commit 6cd1767
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var mongoose = require('mongoose'); | ||
var express = require('express'); | ||
var crudify = require('../'); | ||
|
||
// Create the db connection | ||
var db = mongoose.createConnection('mongodb://localhost/business'); | ||
|
||
// Create our schema | ||
var EmployeeSchema = new mongoose.Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
status: { | ||
type: String, | ||
enum: ['online','away','offline'], | ||
default: 'offline' | ||
} | ||
}); | ||
|
||
// Add the model into db | ||
var Employee = db.model('Employee', EmployeeSchema); | ||
|
||
// Create the HTTP server | ||
var app = express(); | ||
app.use(express.bodyParser()); | ||
|
||
// Expose our models from the database and add it to the HTTP server | ||
var api = crudify(db); | ||
api.expose('Employee'); | ||
api.hook(app); | ||
|
||
// Listen to port 8080 | ||
app.listen(8080); | ||
|
||
console.log("Server listening on 8080"); |