Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 83ab913

Browse files
committed
Update types
1 parent 1487fbd commit 83ab913

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

server/aleph.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ export class Aleph implements IAleph {
172172
}, undefined, 2))
173173
}
174174

175+
// load .env.* files
176+
for await (const { path: p, } of walk(this.workingDir, { match: [/(^|\/|\\)\.env(\.|$)/i], maxDepth: 1 })) {
177+
const text = await Deno.readTextFile(p)
178+
text.split('\n').forEach(line => {
179+
let [key, value] = util.splitBy(line, '=')
180+
key = key.trim()
181+
if (key) {
182+
Deno.env.set(key, value.trim())
183+
}
184+
})
185+
log.info('load env from', basename(p))
186+
}
187+
175188
ms.stop(`init env`)
176189

177190
// apply plugins
@@ -193,9 +206,6 @@ export class Aleph implements IAleph {
193206
ms.stop(`load API middlewares (${middlewares.length}) from 'api/${basename(mwsFile)}'`)
194207
}
195208

196-
// apply custom env
197-
Object.entries(this.#config.env).forEach(([key, value]) => Deno.env.set(key, value))
198-
199209
// init framework
200210
const { init } = await import(`../framework/${this.#config.framework}/init.ts`)
201211
await init(this)

server/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export function defaultConfig(): Readonly<RequiredConfig> {
4242
middlewares: [],
4343
compress: true,
4444
},
45-
env: {},
4645
react: {
4746
version: defaultReactVersion,
4847
esmShBuildVersion: 43,
@@ -140,9 +139,6 @@ export async function loadConfig(specifier: string): Promise<Config> {
140139
if (util.isFilledArray(plugins)) {
141140
config.plugins = plugins.filter(v => util.isPlainObject(v) && util.isFunction(v.setup))
142141
}
143-
if (util.isPlainObject(env)) {
144-
config.env = toStringMap(env)
145-
}
146142

147143
return config
148144
}

types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ export type Config = {
3232
ssr?: boolean | GlobalSSROptions
3333
/** `plugins` specifies some plugins to extend Aleph runtime. */
3434
plugins?: Plugin[]
35-
/** `env` appends system env variables. */
36-
env?: Record<string, string>
3735
/** `server` specifies the options for **Server**. */
3836
server?: ServerOptions
3937
}

0 commit comments

Comments
 (0)