Skip to content

Commit

Permalink
Export ESM module. Fix backwards compatability issue. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
prettymuchbryce authored Aug 24, 2020
1 parent bf0b42d commit 492331d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"LICENSE",
"README.MD"
],
"main": "./build/index.js",
"main": "./build/cjs/index.js",
"module": "./build/es/index.js",
"keywords": [
"node",
"http",
Expand Down
8 changes: 6 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/bin/bash
rm -rf ./build
rm -rf ./build-tmp
tsc --project tsconfig-build.json
ncc build ./build-tmp/index.js -o ./build
ncc build ./build-tmp/index.js -o ./build/cjs
cat ./build-tmp/index.d.ts >> ./build-tmp/codes.d.ts
# Because we are concatting .d.ts files, we need to remove all imports of codes.ts from index.ts
sed -i.old '/^import/d' ./build-tmp/codes.d.ts
# as well as exports that already exist within codes.ts
sed -i.old '/^export { StatusCodes, ReasonPhrases, }/d;' ./build-tmp/codes.d.ts
mv ./build-tmp/codes.d.ts ./build/index.d.ts
mv ./build-tmp/codes.d.ts ./build/cjs/index.d.ts
rm -rf ./build-tmp
tsc --project tsconfig-build.json
mv ./build-tmp ./build/es/
58 changes: 58 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,61 @@ export const UNSUPPORTED_MEDIA_TYPE = 415;
*
* */
export const USE_PROXY = 305;

export default {
ACCEPTED,
BAD_GATEWAY,
BAD_REQUEST,
CONFLICT,
CONTINUE,
CREATED,
EXPECTATION_FAILED,
FORBIDDEN,
GATEWAY_TIMEOUT,
GONE,
HTTP_VERSION_NOT_SUPPORTED,
IM_A_TEAPOT,
INSUFFICIENT_SPACE_ON_RESOURCE,
INSUFFICIENT_STORAGE,
INTERNAL_SERVER_ERROR,
LENGTH_REQUIRED,
LOCKED,
METHOD_FAILURE,
METHOD_NOT_ALLOWED,
MOVED_PERMANENTLY,
MOVED_TEMPORARILY,
MULTI_STATUS,
MULTIPLE_CHOICES,
NETWORK_AUTHENTICATION_REQUIRED,
NO_CONTENT,
NON_AUTHORITATIVE_INFORMATION,
NOT_ACCEPTABLE,
NOT_FOUND,
NOT_IMPLEMENTED,
NOT_MODIFIED,
OK,
PARTIAL_CONTENT,
PAYMENT_REQUIRED,
PERMANENT_REDIRECT,
PRECONDITION_FAILED,
PRECONDITION_REQUIRED,
PROCESSING,
PROXY_AUTHENTICATION_REQUIRED,
REQUEST_HEADER_FIELDS_TOO_LARGE,
REQUEST_TIMEOUT,
REQUEST_TOO_LONG,
REQUEST_URI_TOO_LONG,
REQUESTED_RANGE_NOT_SATISFIABLE,
RESET_CONTENT,
SEE_OTHER,
SERVICE_UNAVAILABLE,
SWITCHING_PROTOCOLS,
TEMPORARY_REDIRECT,
TOO_MANY_REQUESTS,
UNAUTHORIZED,
UNPROCESSABLE_ENTITY,
UNSUPPORTED_MEDIA_TYPE,
USE_PROXY,
getStatusText,
getStatusCode,
};

0 comments on commit 492331d

Please sign in to comment.