nkowaokwu / igbo_api

An API exposing Igbo words, definitions, and more
https://igboapi.com
Apache License 2.0
316 stars 141 forks source link

Word UpdatedOn type of Date Leads to inconsistent api response #440

Closed DCalliet closed 2 years ago

DCalliet commented 2 years ago

https://github.com/ijemmao/igbo_api/blob/2a4eefd5bc8fb2cb94f1493e3ded083b4710f6ea/src/models/Word.js#L48

curl --location --request GET 'igboapi.com/api/v1/words?keyword=health' \
--header 'X-API-Key: my-trusty-api-key'

response

[
    {
        "wordClass": "NNC",
        "definitions": [
            "health"
        ],
        "variations": [],
        "stems": [
            "ezi",
            "ndù"
        ],
        "word": "ezi ndù",
        "updatedOn": 1606015798051,
        "pronunciation": "",
        "isStandardIgbo": false,
        "antonyms": [],
        "hypernyms": [],
        "hyponyms": [],
        "synonyms": [],
        "nsibidi": "",
        "id": "5f90c35e49f7e863e92b7648"
    },
    {
        "wordClass": "NNC",
        "definitions": [
            "health;"
        ],
        "variations": [],
        "stems": [
            "àhụ",
            "ike"
        ],
        "word": "àhụikē",
        "updatedOn": "2021-11-21T00:07:33.620Z",
        "pronunciation": "https://igbo-api.s3.us-east-2.amazonaws.com/audio-pronunciations/5f90c35e49f7e863e92b7a08.webm",
        "isStandardIgbo": true,
        "antonyms": [],
        "hypernyms": [],
        "hyponyms": [],
        "synonyms": [],
        "nsibidi": "",
        "id": "5f90c35e49f7e863e92b7a08"
    }
]

The value coming in as either a string, or an integer is a headache or a types language to use like golang. I'm forced to ignore this field in my workflow unless the underlying type can be set to string or integer!

ijemmao commented 2 years ago

@DCalliet good catch! I can open a fix PR later this week to standardize the updatedOn field. The new format moving forward will be ISO 8601 since that's the format that's used by default in Mongoose across all projects.