Skip to content

Commit 07cd208

Browse files
committed
sequelize added
1 parent c784ba7 commit 07cd208

File tree

9 files changed

+247
-21
lines changed

9 files changed

+247
-21
lines changed

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"env": {
33
"mocha": true,
4-
"node": true
4+
"node": true,
5+
"es6": true
56
},
67
"globals": {
78
"connect": true
@@ -27,5 +28,9 @@
2728
"functions": "ignore"
2829
}],
2930
"max-len": 0
31+
},
32+
"parserOptions": {
33+
"sourceType": "module",
34+
"ecmaVersion": 2018
3035
}
3136
}

.sequelizerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const path = require('path')
2+
module.exports = {
3+
"config": path.resolve('./src/config', 'config.json'),
4+
"models-path": path.resolve('./src/models'),
5+
"seeders-path": path.resolve('./src/seeders'),
6+
"migrations-path": path.resolve('./src/migrations')
7+
};

package-lock.json

Lines changed: 147 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"express-error-handler": "^1.1.0",
2222
"joi": "^14.3.1 ",
2323
"morgan": "~1.9.1",
24+
"path": "^0.12.7",
25+
"pg": "^7.18.2",
26+
"pg-hstore": "^2.3.3",
2427
"request": "^2.88.0",
2528
"request-promise": "^4.2.4",
2629
"sequelize": "^5.21.5",

src/app.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ router.get('/:uid', async (req, res) => {
3434
});
3535
app.use('/users/', router);
3636

37-
// catch 404 and forward to error handler
37+
// catch 404 and forwarded to error handler
3838
app.use((req, res, next) => {
3939
const err = new Error('Not Found');
4040
err.status = 404;
4141
next(err);
4242
});
4343

44+
// Log the error
45+
app.use((err, req, res, next) => {
46+
// eslint-disable-next-line no-console
47+
console.log(err);
48+
next(err);
49+
});
50+
51+
4452
/**
4553
* Get port from environment and store in Express.
4654
*/
@@ -52,14 +60,8 @@ app.set('port', port);
5260
*/
5361
const server = http.createServer(app);
5462

55-
// Log the error
56-
app.use((err, req, res, next) => {
57-
// eslint-disable-next-line no-console
58-
console.log(err);
59-
next(err);
60-
});
63+
app.use(errorHandler({ server }));
6164

62-
app.use(errorHandler());
6365

6466
/**
6567
* Listen on provided port, on all network interfaces.

src/config/config.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"development": {
3+
"username": "root",
4+
"password": null,
5+
"database": "database_development",
6+
"host": "127.0.0.1",
7+
"dialect": "mysql",
8+
"operatorsAliases": false
9+
},
10+
"test": {
11+
"username": "root",
12+
"password": null,
13+
"database": "database_test",
14+
"host": "127.0.0.1",
15+
"dialect": "mysql",
16+
"operatorsAliases": false
17+
},
18+
"production": {
19+
"username": "root",
20+
"password": null,
21+
"database": "database_production",
22+
"host": "127.0.0.1",
23+
"dialect": "mysql",
24+
"operatorsAliases": false
25+
}
26+
}
File renamed without changes.

src/models-sqllite/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const path = require('path');
2+
const Sequelize = require('sequelize');
3+
const config = require('../../config').database;
4+
5+
const sequelize = new Sequelize('rostereditor', null, null, config);
6+
const db = {
7+
User: sequelize.import(path.join(__dirname, 'User.js')),
8+
sequelize,
9+
};
10+
11+
// associations
12+
13+
module.exports = db;

0 commit comments

Comments
 (0)