File tree 6 files changed +52
-27
lines changed
6 files changed +52
-27
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ gulp.task('scripts', () => {
9
9
return tsResult . js . pipe ( gulp . dest ( 'dist' ) ) ;
10
10
} ) ;
11
11
12
- gulp . task ( 'watch' , [ 'scripts' , 'cp' ] , ( ) => {
12
+ gulp . task ( 'watch' , [ 'scripts' ] , ( ) => {
13
13
gulp . watch ( '**/*.ts' , [ 'scripts' ] ) ;
14
14
} ) ;
15
15
Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
var express = require ( 'express' ) ;
3
3
var logger = require ( 'morgan' ) ;
4
- var routes_1 = require ( '../modules/User/routes' ) ;
5
- var routes_2 = require ( '../modules/auth/routes' ) ;
6
4
var auth_1 = require ( '../auth' ) ;
5
+ var routes_1 = require ( './routes/routes' ) ;
7
6
var bodyParser = require ( 'body-parser' ) ;
8
7
var Api = ( function ( ) {
9
8
function Api ( ) {
10
9
this . express = express ( ) ;
11
10
this . middleware ( ) ;
12
- this . router = new routes_1 [ "default" ] ( ) ;
13
- this . routes ( ) ;
11
+ this . router ( this . express ) ;
14
12
}
15
13
Api . prototype . middleware = function ( ) {
16
14
this . express . use ( logger ( 'dev' ) ) ;
@@ -19,13 +17,8 @@ var Api = (function () {
19
17
this . auth = auth_1 [ "default" ] ( ) ;
20
18
this . express . use ( this . auth . initialize ( ) ) ;
21
19
} ;
22
- Api . prototype . routes = function ( ) {
23
- this . express . route ( '/api/users/all' ) . get ( this . router . index ) ;
24
- this . express . route ( '/api/users/create' ) . post ( this . router . create ) ;
25
- this . express . route ( '/api/users/:id' ) . get ( this . router . findOne ) ;
26
- this . express . route ( '/api/users/:id/update' ) . put ( this . router . update ) ;
27
- this . express . route ( '/api/users/:id/destroy' ) . delete ( this . router . destroy ) ;
28
- this . express . use ( '/token' , routes_2 [ "default" ] ( this . auth ) ) ;
20
+ Api . prototype . router = function ( app ) {
21
+ new routes_1 [ "default" ] ( app ) ;
29
22
} ;
30
23
return Api ;
31
24
} ( ) ) ;
Original file line number Diff line number Diff line change 1
1
import * as express from 'express' ;
2
2
import * as path from 'path' ;
3
3
import * as logger from 'morgan' ;
4
- import UserRoutes from '../modules/User/routes' ;
5
- import tokenRoute from '../modules/auth/routes' ;
6
4
import authConfig from '../auth' ;
5
+ import Routes from './routes/routes' ;
7
6
8
7
const bodyParser = require ( 'body-parser' ) ;
9
8
10
9
class Api {
11
10
12
11
public express : express . Application ;
13
12
public auth ;
14
- public router : UserRoutes ;
15
-
13
+
16
14
constructor ( ) {
17
15
this . express = express ( ) ;
18
16
this . middleware ( ) ;
19
- this . router = new UserRoutes ( ) ;
20
- this . routes ( ) ;
17
+ this . router ( this . express ) ;
21
18
}
22
19
23
20
middleware ( ) : void {
@@ -28,15 +25,9 @@ class Api {
28
25
this . express . use ( this . auth . initialize ( ) ) ;
29
26
}
30
27
31
- private routes ( ) : void {
32
- this . express . route ( '/api/users/all' ) . get ( this . router . index ) ;
33
- this . express . route ( '/api/users/create' ) . post ( this . router . create ) ;
34
- this . express . route ( '/api/users/:id' ) . get ( this . router . findOne ) ;
35
- this . express . route ( '/api/users/:id/update' ) . put ( this . router . update ) ;
36
- this . express . route ( '/api/users/:id/destroy' ) . delete ( this . router . destroy ) ;
37
- this . express . use ( '/token' , tokenRoute ( this . auth ) ) ;
28
+ private router ( app : express . Application ) : void {
29
+ new Routes ( app ) ;
38
30
}
39
-
40
31
}
41
32
42
33
export default new Api ( ) . express ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var routes_1 = require ( '../../modules/User/routes' ) ;
3
+ var Routes = ( function ( ) {
4
+ function Routes ( app ) {
5
+ this . router = new routes_1 [ "default" ] ( ) ;
6
+ this . getRoutes ( app ) ;
7
+ }
8
+ Routes . prototype . getRoutes = function ( app ) {
9
+ app . route ( '/api/users/all' ) . get ( this . router . index ) ;
10
+ app . route ( '/api/users/create' ) . post ( this . router . create ) ;
11
+ app . route ( '/api/users/:id' ) . get ( this . router . findOne ) ;
12
+ app . route ( '/api/users/:id/update' ) . put ( this . router . update ) ;
13
+ app . route ( '/api/users/:id/destroy' ) . delete ( this . router . destroy ) ;
14
+ } ;
15
+ return Routes ;
16
+ } ( ) ) ;
17
+ exports . __esModule = true ;
18
+ exports [ "default" ] = Routes ;
Original file line number Diff line number Diff line change
1
+ import { Application } from 'express' ;
2
+ import UserRoutes from '../../modules/User/routes' ;
3
+ import tokenRoute from '../../modules/auth/routes' ;
4
+
5
+ class Routes {
6
+
7
+ private router : UserRoutes ;
8
+
9
+ constructor ( app : Application ) {
10
+ this . router = new UserRoutes ( ) ;
11
+ this . getRoutes ( app ) ;
12
+ }
13
+
14
+ getRoutes ( app : Application ) : void {
15
+ app . route ( '/api/users/all' ) . get ( this . router . index ) ;
16
+ app . route ( '/api/users/create' ) . post ( this . router . create ) ;
17
+ app . route ( '/api/users/:id' ) . get ( this . router . findOne ) ;
18
+ app . route ( '/api/users/:id/update' ) . put ( this . router . update ) ;
19
+ app . route ( '/api/users/:id/destroy' ) . delete ( this . router . destroy ) ;
20
+ }
21
+ }
22
+
23
+ export default Routes ;
Original file line number Diff line number Diff line change 1
1
import { app , req , expect , Chai } from '../../config/tests/functional/helpers' ;
2
2
import * as jwt from 'jwt-simple' ;
3
3
import * as _ from 'lodash' ;
4
- const config = require ( '../../config/config' ) ;
4
+ const config = require ( '../../config/env/ config' ) ;
5
5
let id ;
6
6
const userDefault = {
7
7
id : 1 ,
You can’t perform that action at this time.
0 commit comments