Skip to content

Commit 590a124

Browse files
committed
Organise files around components instead of roles. Inspired from https://blog.risingstack.com/node-hero-node-js-project-structure-tutorial/
1 parent 2aea61c commit 590a124

File tree

10 files changed

+9
-7
lines changed

10 files changed

+9
-7
lines changed

config/express.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import expressWinston from 'express-winston';
1010
import expressValidation from 'express-validation';
1111
import helmet from 'helmet';
1212
import winstonInstance from './winston';
13-
import routes from '../server/routes/index.route';
13+
import routes from '../index.route';
1414
import config from './config';
1515
import APIError from '../server/helpers/APIError';
1616

server/routes/index.route.js renamed to index.route.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import express from 'express';
2-
import userRoutes from './user.route';
3-
import authRoutes from './auth.route';
2+
import userRoutes from './server/user/user.route';
3+
import authRoutes from './server/auth/auth.route';
44

55
const router = express.Router(); // eslint-disable-line new-cap
66

7+
// TODO: use glob to match *.route files
8+
79
/** GET /health-check - Check service health */
810
router.get('/health-check', (req, res) =>
911
res.send('OK')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"lint": "esw *.js server config --color",
1818
"lint:watch": "yarn lint -- --watch",
1919
"precommit": "yarn lint && yarn test",
20-
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors --compilers js:babel-core/register server/tests --recursive",
20+
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors --compilers js:babel-core/register server --recursive",
2121
"test:watch": "yarn test -- --watch",
2222
"test:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/istanbul cover _mocha -- --ui bdd --reporter spec --colors --compilers js:babel-core/register server/tests --recursive",
2323
"test:check-coverage": "yarn test:coverage && istanbul check-coverage",
File renamed without changes.

server/routes/auth.route.js renamed to server/auth/auth.route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import express from 'express';
22
import validate from 'express-validation';
33
import expressJwt from 'express-jwt';
44
import paramValidation from '../../config/param-validation';
5-
import authCtrl from '../controllers/auth.controller';
5+
import authCtrl from './auth.controller';
66
import config from '../../config/config';
77

88
const router = express.Router(); // eslint-disable-line new-cap
File renamed without changes.

server/controllers/user.controller.js renamed to server/user/user.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import User from '../models/user.model';
1+
import User from './user.model';
22

33
/**
44
* Load user and append to req.
File renamed without changes.

server/routes/user.route.js renamed to server/user/user.route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
import validate from 'express-validation';
33
import paramValidation from '../../config/param-validation';
4-
import userCtrl from '../controllers/user.controller';
4+
import userCtrl from './user.controller';
55

66
const router = express.Router(); // eslint-disable-line new-cap
77

File renamed without changes.

0 commit comments

Comments
 (0)