forked from the-creature/RESTful-API
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit d969c77
Showing
5 changed files
with
85 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,4 @@ | ||
DS_Store | ||
node_modules | ||
bower_components | ||
nbproject |
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,21 @@ | ||
//Dependencies | ||
var restful = require('node-restful'); | ||
var mongoose = restful.mongoose; | ||
|
||
//Schema | ||
var productSchema = new mongoose.Schema({ | ||
courses:[{ | ||
name:String, | ||
courseid: Number, | ||
status: String, | ||
sections:[{ | ||
name: String, | ||
sectionid: Number, | ||
sectioncode: Number, | ||
status: String | ||
}] | ||
}] | ||
}); | ||
|
||
//Return model | ||
module.exports = restful.model('Products', productSchema); |
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,27 @@ | ||
{ | ||
"name": "RESTful-API", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/the-creature/RESTful-API.git" | ||
}, | ||
"author": "Liccy Fuentes", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/the-creature/RESTful-API/issues" | ||
}, | ||
"homepage": "https://github.com/the-creature/RESTful-API", | ||
"dependencies": { | ||
"express": "^4.10.0", | ||
"mongoose": "^3.8.18", | ||
"node-restful": "^0.1.17", | ||
"body-parser": "^1.9.1", | ||
"nodemon": "^1.2.1", | ||
"mongodb": "^1.4.19" | ||
} | ||
} |
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,13 @@ | ||
//Dependencies | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
//Models | ||
var Product = require('../models/product'); | ||
|
||
//Routes | ||
Product.methods(['get', 'put', 'post', 'delete']); | ||
Product.register(router, '/products'); | ||
|
||
//Return Router | ||
module.exports = router; |
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,20 @@ | ||
//Dependencies | ||
var express = require('express'); | ||
var mongoose = require('mongoose'); | ||
var bodyParser = require('body-parser'); | ||
|
||
//MongoDB | ||
mongoose.connect('mongodb://localhost/rest_test'); | ||
|
||
|
||
//Express | ||
var app = express(); | ||
app.use(bodyParser.urlencoded({extended: true})); | ||
app.use(bodyParser.json()); | ||
|
||
//Routes | ||
app.use('/api', require('./routes/api')); | ||
|
||
//Start server | ||
app.listen(3000); | ||
console.log('API is working on port 3000'); |