-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrite server js with typescript
- Loading branch information
Showing
26 changed files
with
1,864 additions
and
2,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"minify": false, | ||
"jsc": { | ||
"minify": { | ||
"compress": { | ||
"unused": true | ||
}, | ||
"mangle": true | ||
}, | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": false, | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"target": "es2022", | ||
"baseUrl": "." | ||
}, | ||
"module": { | ||
"type": "es6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import { logger } from './common' | |
const LogLevelSchema = v.picklist(['info', 'warn', 'error', 'debug', 'query'] as const) | ||
|
||
const EnvSchema = v.object({ | ||
NODE_ENV: v.picklist(['production', 'development', 'test'] as const), | ||
NODE_ENV: v.optional(v.picklist(['production', 'development', 'test'] as const), 'development'), | ||
APP_DOMAIN: v.string(), | ||
APP_BASE_URL: v.string(), | ||
APP_SECRET_KEY: v.string(), | ||
|
@@ -26,7 +26,16 @@ const EnvSchema = v.object({ | |
v.url('The url is badly formatted.') | ||
), | ||
SMTP_HOST: v.optional(v.string(), 'localhost'), | ||
SMTP_PORT: v.optional(v.number(), 1025), | ||
SMTP_PORT: v.nullable( | ||
v.pipe( | ||
v.string(), | ||
v.transform((input) => { | ||
const parsed = Number.parseInt(input.toString()) | ||
return Number.isNaN(parsed) ? 1025 : parsed | ||
}) | ||
), | ||
'1025' | ||
), | ||
SMTP_USERNAME: v.optional(v.string()), | ||
SMTP_PASSWORD: v.optional(v.string()), | ||
SMTP_EMAIL_FROM: v.optional(v.string(), 'Remix Mailer <[email protected]>'), | ||
|
@@ -40,7 +49,7 @@ declare global { | |
} | ||
} | ||
|
||
export function init() { | ||
export function initEnv() { | ||
try { | ||
const parsed = v.parse(EnvSchema, process.env) | ||
logger.debug('EnvSchema', parsed) | ||
|
@@ -59,7 +68,7 @@ export function init() { | |
* wish to be included in the client. | ||
* @returns all public ENV variables | ||
*/ | ||
export function getEnv() { | ||
export function getClientEnv() { | ||
return { | ||
NODE_ENV: process.env.NODE_ENV, | ||
APP_DOMAIN: process.env.APP_DOMAIN, | ||
|
@@ -68,7 +77,7 @@ export function getEnv() { | |
} | ||
} | ||
|
||
type ENV = ReturnType<typeof getEnv> | ||
type ENV = ReturnType<typeof getClientEnv> | ||
|
||
declare global { | ||
var ENV: ENV | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.