1
- // Copyright 2015-2016, Google, Inc.
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
-
14
1
'use strict' ;
15
2
16
- // [START server]
17
3
var loopback = require ( 'loopback' ) ;
18
4
var boot = require ( 'loopback-boot' ) ;
19
5
@@ -23,20 +9,21 @@ app.start = function() {
23
9
// start the web server
24
10
return app . listen ( function ( ) {
25
11
app . emit ( 'started' ) ;
26
- console . log ( 'Web server listening at: %s' , app . get ( 'url' ) ) ;
12
+ var baseUrl = app . get ( 'url' ) . replace ( / \/ $ / , '' ) ;
13
+ console . log ( 'Web server listening at: %s' , baseUrl ) ;
14
+ if ( app . get ( 'loopback-component-explorer' ) ) {
15
+ var explorerPath = app . get ( 'loopback-component-explorer' ) . mountPath ;
16
+ console . log ( 'Browse your REST API at %s%s' , baseUrl , explorerPath ) ;
17
+ }
27
18
} ) ;
28
19
} ;
29
20
30
21
// Bootstrap the application, configure models, datasources and middleware.
31
22
// Sub-apps like REST API are mounted via boot scripts.
32
23
boot ( app , __dirname , function ( err ) {
33
- if ( err ) {
34
- throw err ;
35
- }
24
+ if ( err ) throw err ;
36
25
37
26
// start the server if `$ node server.js`
38
- if ( require . main === module ) {
27
+ if ( require . main === module )
39
28
app . start ( ) ;
40
- }
41
29
} ) ;
42
- // [START server]
0 commit comments