October 2017
Intermediate to advanced
326 pages
7h 20m
English
The ISO date service simply takes a timestamp and returns the equivalent date using the ISO format. Let's take a look at its code:
const Hapi = require('hapi')const server = new Hapi.Server()const moment = require('moment')server.connection({port: 3000})server.route({ method: 'GET', path: '/isodate/{timestamp}', handler: (request, reply) => { reply({date: moment.unix(request.params.timestamp).toISOString()}) }})server.start((err) => { if (err) { throw err } console.log('isodate-service started on port 3000')})
This service itself is very simple: it uses a library called moment and a framework called hapi to provide the ISO Date equivalent to a timestamp passed as a URL parameter. The language used to write the ...
Read now
Unlock full access