@destinationstransfers/ntp

    2.0.0 • Public • Published

    NTP Client CircleCI styled with prettier

    Lightweight (no dependencies) modern Javascript (Node 8 LTS or later) implementation of the NTP Client Protocol. Based on node-ntp-client and NTPServer.

    We use it in production at https://transfers.do for webhooks timestamps checking (like Stripe and so on) where VM time is not reliable enough.

    Usage

    Add the module to your project with npm install @destinationstransfers/ntp.

    const NTPClient = require('@destinationstransfers/ntp)';
    
    const date = await NTPClient.getNetworkTime();
    console.log(date) // 2017-09-20T15:29:09.443Z

    API

    getNetworkTime accepts hash of parameters, below they are with default values:

    const { getNetworkTime } = require('@destinationstransfers/ntp)';
    
    const date = await getNetworkTime({
      timeout = 10000, // timeout in ms, default is 10sec
      server = 'time.google.com', // ntp server address
      port = 123, // NTP server port
    })

    You also can override default values using env variables NPT_PORT, NTP_SERVER and NTP_REPLY_TIMEOUT.

    Keywords

    none

    Install

    npm i @destinationstransfers/ntp

    DownloadsWeekly Downloads

    347

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    6.85 kB

    Total Files

    5

    Last publish

    Collaborators

    • tinovyatkin