Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
panktip15 committed Aug 29, 2018
1 parent a439c2b commit 50d3e5c
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
node_modules
35 changes: 35 additions & 0 deletions README.md
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`
29 changes: 29 additions & 0 deletions app.js
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;
28 changes: 28 additions & 0 deletions package.json
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"
}
}

0 comments on commit 50d3e5c

Please sign in to comment.