Ship Novya PWA with backend for deployable production use.
Fix production TypeScript builds and add DEPLOY.md so the app can be hosted from this repo. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { EnvValidationError, parseEnv } from '../src/config/env.js';
|
||||
|
||||
describe('environment validation', () => {
|
||||
it('accepts a valid configuration', () => {
|
||||
const env = parseEnv({
|
||||
NODE_ENV: 'test',
|
||||
DATABASE_URL: 'mysql://user:pass@localhost:3306/novya_test',
|
||||
LOG_LEVEL: 'silent',
|
||||
});
|
||||
|
||||
assert.equal(env.NODE_ENV, 'test');
|
||||
assert.equal(env.DATABASE_URL, 'mysql://user:pass@localhost:3306/novya_test');
|
||||
assert.equal(env.PORT, 3001);
|
||||
assert.equal(env.OPENAI_BASE_URL, 'https://api.gapgpt.app/v1');
|
||||
assert.equal(env.OPENAI_MODEL, 'gpt-4o-mini');
|
||||
assert.equal(env.OPENAI_API_KEY, '');
|
||||
});
|
||||
|
||||
it('fails clearly when DATABASE_URL is missing', () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
parseEnv({
|
||||
NODE_ENV: 'test',
|
||||
}),
|
||||
(err: unknown) => {
|
||||
assert.ok(err instanceof EnvValidationError);
|
||||
assert.match(String(err.message), /DATABASE_URL.*Required/i);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('fails clearly when DATABASE_URL is not MySQL', () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
parseEnv({
|
||||
NODE_ENV: 'test',
|
||||
DATABASE_URL: 'postgres://user:pass@localhost/db',
|
||||
}),
|
||||
(err: unknown) => {
|
||||
assert.ok(err instanceof EnvValidationError);
|
||||
assert.match(String(err.message), /MySQL connection string/);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user