Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env / config package #1136

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a9f9cdb
init env pkg
goastler Apr 4, 2024
09636fe
basic loadConfig fns
goastler Apr 4, 2024
966b616
logging and loading from default env/config.ts paths
goastler Apr 4, 2024
19c39c9
adjusted default path handling
goastler Apr 4, 2024
3160a9a
parse config using schema
goastler Apr 4, 2024
32e2588
load from env using dotenv
goastler Apr 4, 2024
a6b5880
load config from js
goastler Apr 4, 2024
ef82125
js should export fn to build config
goastler Apr 4, 2024
9a9f706
make a test config
goastler Apr 4, 2024
6b14672
specifying config.ts converts to config.js
goastler Apr 4, 2024
faded39
check for config file existence
goastler Apr 4, 2024
acfb34d
missing dep
goastler Apr 4, 2024
4b637fc
Merge branch 'main' into env
goastler Apr 4, 2024
c304d1f
fix deps
goastler Apr 4, 2024
58ff03e
move config type to own file
goastler Apr 4, 2024
a14821d
compile ts
goastler Apr 4, 2024
06d8cb1
fix generic typing
goastler Apr 4, 2024
b378beb
JSON stringify env variables when loading from config
goastler Apr 4, 2024
b9731ab
make a config schema
goastler Apr 4, 2024
e11ca36
example of loading config
goastler Apr 4, 2024
707f0a6
example config
goastler Apr 4, 2024
3ded955
fix tests
goastler Apr 4, 2024
274aa1e
load config using json
goastler Apr 4, 2024
616ead6
json config
goastler Apr 4, 2024
da6a4af
json config tests
goastler Apr 4, 2024
98b0015
rename example env
goastler Apr 4, 2024
52e3300
move config pkg to configure
goastler Apr 4, 2024
1b8cff3
disable ts/js/json type configs
goastler Apr 4, 2024
048973f
lint
goastler Apr 4, 2024
ac2a117
lint
goastler Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
js should export fn to build config
  • Loading branch information
goastler committed Apr 4, 2024
commit ef821253f38b05238d6ea09f06ff9716386b4f5a
9 changes: 8 additions & 1 deletion packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ const loadConfigFromJs = async (path: string): Promise<{

// dynamic import the js file
// this will have no typing!
const config = (await import(`../${path}`)).default
const buildConfig = (await import(`../${path}`)).default

// ensure the config is a function
if (typeof buildConfig !== 'function') {
throw new Error(`Config at '${path}' must export a function to build the config object.`)
}

const config = buildConfig()

return config
}

Expand Down
41 changes: 41 additions & 0 deletions packages/config/src/tests/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2021-2024 Prosopo (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { describe, expect, test, it } from 'vitest'

describe('config', () => {

it('should load config from env', async () => {

})

it('should load config from js', async () => {

})

it('should load config from default env location', async () => {

})

it('should load config from default js location', async () => {

})

it('should load config from ts', async () => {

})

it('should load into process.env', async () => {

})
})