feat: add .env.example templates for development setup

- Create .env.example with database and API key placeholders
- Add backend/.env.example for backend development
- Add frontend/.env.example for Vite frontend config
- Add tests/env-example.spec.ts with 13 validation tests
- Verify .gitignore correctly ignores .env files
This commit is contained in:
2026-02-12 20:10:26 +01:00
parent 571ac97f00
commit 2609d156cb
4 changed files with 106 additions and 3 deletions

89
tests/env-example.spec.ts Normal file
View File

@@ -0,0 +1,89 @@
import { describe, it, expect } from 'vitest';
import { readFileSync, existsSync } from 'fs';
import { resolve } from 'path';
describe('Environment Example Files', () => {
describe('Root .env.example', () => {
const rootEnvPath = resolve(__dirname, '..', '.env.example');
it('should exist and contain DATABASE_URL', () => {
expect(existsSync(rootEnvPath)).toBe(true);
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('DATABASE_URL');
});
it('should contain IGDB_CLIENT_ID and IGDB_CLIENT_SECRET', () => {
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('IGDB_CLIENT_ID');
expect(content).toContain('IGDB_CLIENT_SECRET');
});
it('should contain RAWG_API_KEY', () => {
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('RAWG_API_KEY');
});
it('should contain THEGAMESDB_API_KEY', () => {
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('THEGAMESDB_API_KEY');
});
it('should contain NODE_ENV', () => {
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('NODE_ENV');
});
it('should contain PORT and LOG_LEVEL', () => {
const content = readFileSync(rootEnvPath, 'utf-8');
expect(content).toContain('PORT');
expect(content).toContain('LOG_LEVEL');
});
});
describe('Backend .env.example', () => {
const backendEnvPath = resolve(__dirname, '..', 'backend', '.env.example');
it('should exist', () => {
expect(existsSync(backendEnvPath)).toBe(true);
});
it('should contain DATABASE_URL', () => {
const content = readFileSync(backendEnvPath, 'utf-8');
expect(content).toContain('DATABASE_URL');
});
it('should contain all API keys', () => {
const content = readFileSync(backendEnvPath, 'utf-8');
expect(content).toContain('IGDB_CLIENT_ID');
expect(content).toContain('IGDB_CLIENT_SECRET');
expect(content).toContain('RAWG_API_KEY');
expect(content).toContain('THEGAMESDB_API_KEY');
});
});
describe('Frontend .env.example', () => {
const frontendEnvPath = resolve(__dirname, '..', 'frontend', '.env.example');
it('should exist', () => {
expect(existsSync(frontendEnvPath)).toBe(true);
});
it('should contain VITE_API_URL', () => {
const content = readFileSync(frontendEnvPath, 'utf-8');
expect(content).toContain('VITE_API_URL');
});
it('should contain VITE_APP_NAME', () => {
const content = readFileSync(frontendEnvPath, 'utf-8');
expect(content).toContain('VITE_APP_NAME');
});
});
describe('Git Ignore Configuration', () => {
it('should ignore .env files', () => {
const gitignorePath = resolve(__dirname, '..', '.gitignore');
const content = readFileSync(gitignorePath, 'utf-8');
expect(content).toContain('.env');
});
});
});