import { ContextTags , injectable } from '@loopback/core' ; import { promisify } from 'util' ; const sleep = promisify ( setTimeout ) ; @ injectable ( { tags : { [ ContextTags . NAMESPACE ] : 'services' } } ) export class GreetingService { async greet ( name ) { const ts = new Date ( ) . toISOString ( ) ; const delayInMs = Math . floor ( Math . random ( ) * 100 ) ; await sleep ( delayInMs ) ; return `[${ ts }: ${ delayInMs }] Hello, ${ name }` ; } }