TwinePlatform / twine-monolith

⬛️ Monorepo for the Twine platform
https://twine-together.com
GNU Affero General Public License v3.0
5 stars 3 forks source link

🗜 create types library #306

Open astroash opened 5 years ago

astroash commented 5 years ago

Proposal:

// types for /community-business

namespace CommunityBusinesses = {
    export type get = ...
    export type post = ...
    export namespace Visitors {
        get: type ...
    }
}

// use case 
...
    handler: async (request: CommunityBusinesses.Visitors.get, h: Hapi.ResponseToolkit) => {
...

part of #12

eliasmalik commented 5 years ago

Is this just request types or also response types?

Also, I like namespaces to keep things clean, but worth investigating whether they'll work on the dashboard because of this (check the caveat section)

astroash commented 5 years ago

Is this just request types or also response types?

Yeah should be both. I guess it will look more like:

// types for /community-business

namespace CommunityBusinesses = {
    export namespace Visitors {
        getRequest: type ...
        getResponse: type ...
    }
}

// use case 
...
    handler: async (request: CommunityBusinesses.Visitors.getRequest, h: Hapi.ResponseToolkit) => {
...

I like namespaces to keep things clean, but worth investigating whether they'll work on the dashboard

I'll double check. I believe that we don't need namespaces to actually be compiled, we can confirm these type constraints with a linter...

eliasmalik commented 5 years ago

OK sounds good.