0.3.1 • Published 6 years ago

@augmt/timestamp-microservice v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Timestamp Microservice

Convert date strings to Unix timestamps and a natural language (RFC-1123) format.

How it Works

This microservice uses Moment to validate input and format output and koa-router to capture path parameters and, along with Koa, serve requests.

Valid Formats

FormatExample
Unix Timestamp1450137600
ISO-86012015-12-25

Note: Unix timestamps have precedence over the ISO-8601 format, so a string such as "20130208" will be parsed as a unix timestamp.

How to Use

app.js exports a Koa app. Koa apps have an app.listen() method that is identical to Node's http.Server.listen().

Import app.js and call app.listen() to start up the microservice.

API Resources

GET /

Returns a Timestamp object based on the current time.

REQUEST

Sample: https://timestamp-microservice.example.com/

RESPONSE

Status: 200 - application-json

Response:

{
  "unix": 1498953600,
  "natural": "Sun, 02 Jul 2017 00:00:00 GMT"
}

GET /:date

Returns a Timestamp object based on date.

REQUEST

Sample: https://timestamp-microservice.example.com/1450137600

RESPONSE

Status: 200 - application-json

Response:

{  
  "unix": 1450137600,
  "natural": "Tue, 15 Dec 2015 00:00:00 GMT"
}
0.3.1

6 years ago

0.3.0

7 years ago

0.2.4

8 years ago

0.2.3

8 years ago