This repository was archived by the owner on Aug 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-32
lines changed Expand file tree Collapse file tree 4 files changed +28
-32
lines changed Original file line number Diff line number Diff line change 4
4
'use strict' ;
5
5
6
6
module . exports = function ( CoffeeShop ) {
7
- CoffeeShop . status = function ( cb ) {
8
- var currentDate = new Date ( ) ;
9
- var currentHour = currentDate . getHours ( ) ;
10
- var OPEN_HOUR = 6 ;
11
- var CLOSE_HOUR = 20 ;
7
+ CoffeeShop . status = async function ( ) {
8
+ const currentDate = new Date ( ) ;
9
+ const currentHour = currentDate . getHours ( ) ;
10
+ const OPEN_HOUR = 6 ;
11
+ const CLOSE_HOUR = 20 ;
12
12
console . log ( 'Current hour is %d' , currentHour ) ;
13
- var response ;
13
+ let response ;
14
14
if ( currentHour > OPEN_HOUR && currentHour < CLOSE_HOUR ) {
15
15
response = 'We are open for business.' ;
16
16
} else {
17
17
response = 'Sorry, we are closed. Open daily from 6am to 8pm.' ;
18
18
}
19
- cb ( null , response ) ;
19
+ return response ;
20
20
} ;
21
21
CoffeeShop . remoteMethod (
22
22
'status' , {
Original file line number Diff line number Diff line change 3
3
4
4
'use strict' ;
5
5
6
- module . exports = function ( app ) {
7
- app . dataSources . mysqlDs . automigrate ( 'CoffeeShop' , function ( err ) {
8
- if ( err ) throw err ;
6
+ module . exports = async function ( app ) {
7
+ await app . dataSources . mysqlDs . automigrate ( 'CoffeeShop' ) ;
8
+ const coffeeShops = await app . models . CoffeeShop . create ( [ {
9
+ name : 'Bel Cafe' ,
10
+ city : 'Vancouver' ,
11
+ } , {
12
+ name : 'Three Bees Coffee House' ,
13
+ city : 'San Mateo' ,
14
+ } , {
15
+ name : 'Caffe Artigiano' ,
16
+ city : 'Vancouver' ,
17
+ } ,
18
+ ] ) ;
9
19
10
- app . models . CoffeeShop . create ( [ {
11
- name : 'Bel Cafe' ,
12
- city : 'Vancouver' ,
13
- } , {
14
- name : 'Three Bees Coffee House' ,
15
- city : 'San Mateo' ,
16
- } , {
17
- name : 'Caffe Artigiano' ,
18
- city : 'Vancouver' ,
19
- } ] , function ( err , coffeeShops ) {
20
- if ( err ) throw err ;
21
-
22
- console . log ( 'Models created: \n' , coffeeShops ) ;
23
- } ) ;
24
- } ) ;
20
+ console . log ( 'Models created: \n' , coffeeShops ) ;
25
21
} ;
Original file line number Diff line number Diff line change 5
5
"remoting" : {
6
6
"context" : false ,
7
7
"rest" : {
8
+ "handleErrors" : false ,
8
9
"normalizeHttpPath" : false ,
9
10
"xml" : false
10
11
},
16
17
"extended" : true ,
17
18
"limit" : " 100kb"
18
19
},
19
- "cors" : false ,
20
- "handleErrors" : false
20
+ "cors" : false
21
21
}
22
22
}
Original file line number Diff line number Diff line change 3
3
4
4
'use strict' ;
5
5
6
- var loopback = require ( 'loopback' ) ;
7
- var boot = require ( 'loopback-boot' ) ;
6
+ const loopback = require ( 'loopback' ) ;
7
+ const boot = require ( 'loopback-boot' ) ;
8
8
9
- var app = module . exports = loopback ( ) ;
9
+ const app = module . exports = loopback ( ) ;
10
10
11
11
app . start = function ( ) {
12
12
// start the web server
13
13
return app . listen ( function ( ) {
14
14
app . emit ( 'started' ) ;
15
- var baseUrl = app . get ( 'url' ) . replace ( / \/ $ / , '' ) ;
15
+ const baseUrl = app . get ( 'url' ) . replace ( / \/ $ / , '' ) ;
16
16
console . log ( 'Web server listening at: %s' , baseUrl ) ;
17
17
if ( app . get ( 'loopback-component-explorer' ) ) {
18
- var explorerPath = app . get ( 'loopback-component-explorer' ) . mountPath ;
18
+ const explorerPath = app . get ( 'loopback-component-explorer' ) . mountPath ;
19
19
console . log ( 'Browse your REST API at %s%s' , baseUrl , explorerPath ) ;
20
20
}
21
21
} ) ;
You can’t perform that action at this time.
0 commit comments