rajt 0.0.36 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rajt",
3
3
  "description": "A serverless bundler layer, fully typed for AWS Lambda (Node.js and LLRT) and Cloudflare Workers.",
4
- "version": "0.0.36",
4
+ "version": "0.0.37",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
@@ -10,7 +10,9 @@
10
10
  "./dynamodb": "./src/dynamodb/index.ts",
11
11
  "./dynamodb/types": "./src/dynamodb/types.ts",
12
12
  "./http": "./src/http.ts",
13
- "./types": "./src/types.ts"
13
+ "./types": "./src/types.ts",
14
+ "./env": "./src/utils/environment.ts",
15
+ "./length": "./src/utils/length.ts"
14
16
  },
15
17
  "files": [
16
18
  "src"
package/src/create-app.ts CHANGED
@@ -9,7 +9,7 @@ import type { Routes } from './types'
9
9
  import { BadRequest, Unauthorized } from './exceptions'
10
10
  import { resolve, resolveMiddleware } from './utils/resolve'
11
11
  import { getMiddlewares, getHandler } from './register'
12
- import env from './utils/environment'
12
+ import { isDev } from './utils/environment'
13
13
  import { Auth } from './auth'
14
14
  import response from './response'
15
15
  import cx from './context'
@@ -25,7 +25,6 @@ export type ServerOptions<E extends Env = Env> = Partial<{
25
25
  init?: InitFunction<E>,
26
26
  }>
27
27
 
28
- const isDev = env() === 'dev'
29
28
  const NFHandler = () => response.notFound()
30
29
  const EHandler = async (e: Error | HTTPResponseError) => {
31
30
  console.error(e)
@@ -43,7 +42,7 @@ const EHandler = async (e: Error | HTTPResponseError) => {
43
42
  default:
44
43
  return response.internalError(
45
44
  // @ts-ignore
46
- isDev
45
+ isDev()
47
46
  ? e.stack?.split('\n').map(line =>
48
47
  line.replace(
49
48
  /at (.+ )?\(?([^)]+)\)?/g,
@@ -67,12 +66,12 @@ const EHandler = async (e: Error | HTTPResponseError) => {
67
66
 
68
67
  // return json.internalError(
69
68
  // // @ts-ignore
70
- // isDev ? e.stack?.split('\n at ').map() : undefined,
69
+ // isDev() ? e.stack?.split('\n at ').map() : undefined,
71
70
  // e.message || 'Internal Error'
72
71
  // )
73
72
  // error: e.message,
74
73
  // cause: e.cause || '???',
75
- // stack: isDev ? e.stack : undefined
74
+ // stack: isDev (? e.stack : undefined
76
75
  }
77
76
 
78
77
  export const createApp = <E extends Env>(options?: ServerOptions<E>) => {
@@ -13,3 +13,7 @@ export default function getEnvironment() {
13
13
 
14
14
  return 'prod'
15
15
  }
16
+
17
+ export const isDev = () => getEnvironment() === 'dev'
18
+ export const isProd = () => getEnvironment() === 'prod'
19
+ export const isPrd = isProd