1+ /*
2+ * Copyright The OpenTelemetry Authors
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117'use strict' ;
218
319const api = require ( '@opentelemetry/api' ) ;
@@ -28,27 +44,26 @@ const BlogPostPlugin = {
2844 method : 'GET' ,
2945 path : '/post/{id}' ,
3046 handler : showNewPost ,
31- } ] ) ;
47+ } ,
48+ ] ) ;
3249 } ,
3350} ;
3451
3552async function setUp ( ) {
36- await server . register (
37- { plugin : BlogPostPlugin } ,
38- ) ;
53+ await server . register ( { plugin : BlogPostPlugin } ) ;
3954
40- server . route (
41- {
42- method : 'GET' ,
43- path : '/run_test' ,
44- handler : runTest ,
45- } ,
46- ) ;
55+ server . route ( {
56+ method : 'GET' ,
57+ path : '/run_test' ,
58+ handler : runTest ,
59+ } ) ;
4760
4861 server . ext ( 'onRequest' , async ( request , h ) => {
4962 console . log ( 'No-op Hapi lifecycle extension method' ) ;
5063 const syntheticDelay = 50 ;
51- await new Promise ( ( r ) => setTimeout ( r , syntheticDelay ) ) ;
64+ await new Promise ( r => {
65+ setTimeout ( r , syntheticDelay ) ;
66+ } ) ;
5267 return h . continue ;
5368 } ) ;
5469
@@ -59,7 +74,7 @@ async function setUp() {
5974
6075/**
6176 * Blog Post functions: list, add, or show posts
62- */
77+ */
6378const posts = [ 'post 0' , 'post 1' , 'post 2' ] ;
6479
6580function addPost ( _ , h ) {
@@ -77,7 +92,9 @@ async function showNewPost(request) {
7792 const post = posts [ id ] ;
7893 if ( ! post ) throw new Error ( 'Invalid post id' ) ;
7994 const syntheticDelay = 200 ;
80- await new Promise ( ( r ) => setTimeout ( r , syntheticDelay ) ) ;
95+ await new Promise ( r => {
96+ setTimeout ( r , syntheticDelay ) ;
97+ } ) ;
8198 return post ;
8299}
83100
@@ -91,7 +108,7 @@ function runTest(_, h) {
91108}
92109
93110setUp ( ) ;
94- process . on ( 'unhandledRejection' , ( err ) => {
111+ process . on ( 'unhandledRejection' , err => {
95112 console . log ( err ) ;
96113 process . exit ( 1 ) ;
97114} ) ;
0 commit comments