-
Notifications
You must be signed in to change notification settings - Fork 534
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
Showing
4 changed files
with
94 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,2 @@ | ||
.DS_Store | ||
node_modules |
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 |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# Study-Saturday-Week2 | ||
Express and Sequelize Review | ||
|
||
## Objective: Build a fully-functioning CRUD API for 2 models, Students and Tests. Test specs are provided to guide development. | ||
|
||
### Details | ||
|
||
- Necessary Models: | ||
- Student | ||
- Test | ||
|
||
- Necessary routes: | ||
|
||
- Get all students | ||
|
||
- Get all test scores | ||
|
||
- Update student name | ||
|
||
- Update test score | ||
|
||
- Get mean test score by student ID | ||
|
||
- Get top scoring student | ||
|
||
- Delete Student | ||
|
||
- Delete Score | ||
|
||
- Add Student | ||
|
||
- Add Score | ||
|
||
|
||
|
||
### How to test routes with specs | ||
- `npm t` |
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,29 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser = require('body-parser'); | ||
const morgan = require('morgan'); | ||
const db = require('./db/db'); | ||
|
||
app.use(bodyParser.json()); | ||
|
||
app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
app.use(morgan('dev')); | ||
|
||
app.use(function(err, req, res, next) { | ||
console.error(err.stack); | ||
res.status(500).send('Something broke!'); | ||
}); | ||
|
||
if (require.main === module) { | ||
//will only run when run with npm start and not with npm test to avoid db syncing in multiple threads when running tests | ||
db.sync() | ||
.then(() => | ||
app.listen(3000, function() { | ||
console.log('Server is listening on port 3000!'); | ||
}) | ||
) | ||
.catch(console.error); | ||
} | ||
|
||
module.exports = app; |
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,28 @@ | ||
{ | ||
"name": "study-staturday-week-2", | ||
"version": "1.0.0", | ||
"description": "fun w express and sequelize!", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "nodemon --exec 'mocha --reporter spec --timeout 1000 test/*.test.js || true'", | ||
"start": "nodemon app.js" | ||
}, | ||
"author": "myself", | ||
"license": "ISC", | ||
"dependencies": { | ||
"body-parser": "^1.18.2", | ||
"express": "^4.16.2", | ||
"morgan": "^1.9.0", | ||
"nodemon": "^1.17.1", | ||
"pg": "^7.4.1", | ||
"pg-hstore": "^2.3.2", | ||
"sequelize": "^4.32.2" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"mocha": "^5.0.0", | ||
"sinon": "^4.2.2", | ||
"sinon-chai": "^2.14.0", | ||
"supertest": "^3.0.0" | ||
} | ||
} |