Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Including:

This project demonstrates the stack in action via a [RealWorld](https://github.com/gothinkster/realworld) example.

## Environment Configuration

Production and shared environment variables are defined in `src/core/env.ts`.

Test-specific environment variables are now defined in `src/core/test-env.ts` and are only used by test scripts and test runners. This keeps test configuration isolated from production config.

## Development

1. Install dependencies
Expand Down
17 changes: 9 additions & 8 deletions scripts/test/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { $ } from "bun";
import chalk from "chalk";
import newman from "newman";
import { debounce } from "radashi";
import { env } from "@/core/env";
import { testEnv } from "@/core/test-env";

const APIURL = env.APIURL;
const USERNAME = env.USERNAME;
const EMAIL = env.EMAIL;
const PASSWORD = env.PASSWORD;
const POSTMAN_COLLECTION = env.POSTMAN_COLLECTION;
const APIURL = testEnv.APIURL;
const USERNAME = testEnv.USERNAME;
const EMAIL = testEnv.EMAIL;
const PASSWORD = testEnv.PASSWORD;
const POSTMAN_COLLECTION = testEnv.POSTMAN_COLLECTION;

// Parse command line arguments
const { values } = parseArgs({
Expand All @@ -29,11 +29,12 @@ const { values } = parseArgs({
});

// check --skip-db-reset param
const shouldSkipDbReset = values["skip-db-reset"] || env.SKIP_DB_RESET;
const shouldSkipDbReset =
values["skip-db-reset"] ?? testEnv.SKIP_DB_RESET;
const isWatchMode = values.watch || false;

// Performance options
const DELAY_REQUEST = env.DELAY_REQUEST;
const DELAY_REQUEST = testEnv.DELAY_REQUEST;
// Note: Newman doesn't support parallel execution, but we can reduce delays

console.info(chalk.gray("Checking Bedstack health"));
Expand Down
10 changes: 0 additions & 10 deletions src/core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ export const envPlugin = elysiaEnv({
LOG_LEVEL: t.Union([t.Literal("debug"), t.Literal("info")], {
default: "info",
}),
APIURL: t.String({ default: "http://localhost:3000/api" }),
USERNAME: t.String({ default: "jake" }),
EMAIL: t.String({ default: "jake@jake.jake" }),
PASSWORD: t.String({ default: "hunter2A" }),
POSTMAN_COLLECTION: t.String({
default:
"https://raw.githubusercontent.com/gothinkster/realworld/refs/heads/main/api/Conduit.postman_collection.json",
}),
SKIP_DB_RESET: t.Boolean({ default: false }),
DELAY_REQUEST: t.Number({ default: 50 }),
});

export const { env } = envPlugin.decorator;
17 changes: 17 additions & 0 deletions src/core/test-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { env as elysiaEnv } from "@yolk-oss/elysia-env";
import { t } from "elysia";

export const testEnvPlugin = elysiaEnv({
APIURL: t.String({ default: "http://localhost:3000/api" }),
USERNAME: t.String({ default: "jake" }),
EMAIL: t.String({ default: "jake@jake.jake" }),
PASSWORD: t.String({ default: "hunter2A" }),
POSTMAN_COLLECTION: t.String({
default:
"https://raw.githubusercontent.com/gothinkster/realworld/refs/heads/main/api/Conduit.postman_collection.json",
}),
SKIP_DB_RESET: t.Boolean({ default: false }),
DELAY_REQUEST: t.Number({ default: 50 }),
});

export const { env: testEnv } = testEnvPlugin.decorator;
Loading