orels1 / Red-Portal

A cog-listing project for Red-DiscordBot
http://cogs.red
MIT License
10 stars 1 forks source link

Api v0.2.0 changes #20

Closed orels1 closed 7 years ago

orels1 commented 7 years ago

Ok, so it is finally time to revisit the API structure and make some changes

Mainly, i will remove the list of cogs from the main /api/v1/repo endpoint, since it began to return too much data, and the whole structure is a bit annoying.

Also, I'm adding the username to the repo name as well, so we are safe from the same repo names from different users, so now the urls to the repo will look like this: /api/v1/repo/orels1/ORELS-Cogs

You can expect the new JSON for the repo to look like this

{
    "_id": "587d62b4c54cad51845ae101",
    "name": "ORELS-Cogs",
    "__v": 4,
    "description": "Repository of mainly gaming/data based cogs, with a bit of some fun stuff. Use as you like.",
    "short": "Data scraping cogs with a bit of extra",
    "links": {
        "_self": "/api/v1/repo/orels1/ORELS-Cogs", // notice the schema change
        "_update": "/api/v1/repo/orels1/ORELS-Cogs/fetch",
        "self": "/cogs/repo/orels/ORELS-Cogs/",
        "_cogs": "/api/v1/cogs/orels1/ORELS-Cogs", // new field with the link to Cogs list
        "github": {
            "self": "https://github.com/orels1/ORELS-Cogs",
            "_update": "https://api.github.com/repos/orels1/ORELS-Cogs/contents/info.json?ref=master"
        }
    },
    "type": "unapproved",
    "parsed": false,
    "cogs": [], // deprecated field, will be left in the API to bypass errors, will be removed later
    "author": {
        "name": "orels",
        "url": "https://github.com/orels1"
    }
}

Also, I'll move the cogs to their own Collection, which means faster search, better indexing and more reliable storage.

The next step will be to include pagination into the cogs response, will be introduced later in the v0.2.1

orels1 commented 7 years ago

Plus, two new utility enpoints will be added:

Just to make it easier for the frontend counter