unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
3.99k stars 467 forks source link

The error code types are not exported #1124

Closed multiplehats closed 5 months ago

multiplehats commented 7 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

The error code types are not exported in the sdk:

"NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS" | undefined;.

I manually copied them because I'm trying to remap them to the http-status pkg.

import httpStatus from 'http-status';

type UnkeyResponses =
    | 'NOT_FOUND'
    | 'FORBIDDEN'
    | 'USAGE_EXCEEDED'
    | 'RATE_LIMITED'
    | 'UNAUTHORIZED'
    | 'DISABLED'
    | 'INSUFFICIENT_PERMISSIONS'
    | undefined;

const getHttpErrCodeFromUnkeyErr = (error: UnkeyResponses) => {
    switch (error) {
        case 'NOT_FOUND':
            return httpStatus.NOT_FOUND;
        case 'FORBIDDEN':
            return httpStatus.FORBIDDEN;
        case 'USAGE_EXCEEDED':
            return httpStatus.TOO_MANY_REQUESTS;
        case 'RATE_LIMITED':
            return httpStatus.TOO_MANY_REQUESTS;
        case 'UNAUTHORIZED':
            return httpStatus.UNAUTHORIZED;
        case 'DISABLED':
            return httpStatus.FORBIDDEN;
        case 'INSUFFICIENT_PERMISSIONS':
            return httpStatus.FORBIDDEN;
        default:
            return httpStatus.INTERNAL_SERVER_ERROR;
    }
};

Steps to Reproduce

  1. There's no explicit export for these types.

Expected behavior

Ability to import it

Other information

No response

Screenshots

No response

Version info

- OS:
- Node:
- npm:
linear[bot] commented 7 months ago

ENG-632 The error code types are not exported

ikbalarslandev commented 7 months ago

i can take this

chronark commented 5 months ago

fixed and released today