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

View File

@@ -10,9 +10,11 @@
"description": "Quasar es una aplicación web para al gestión de una biblioteca personal de videjuegos. Permite a los usuarios catalogar, organizar y buscar sus juegos de manera eficiente. Se pueden agregar videjuegos físicos, digitales y roms de emuladores.",
"main": "index.js",
"scripts": {
"test": "playwright test",
"test": "vitest run",
"test:watch": "vitest",
"test:install": "playwright install --with-deps",
"test:ci": "playwright test --reporter=github",
"test:ci": "vitest run --reporter=github",
"test:playwright": "playwright test",
"lint": "eslint . --ext .js,.ts",
"format": "prettier --write .",
"start": "node src/index.js"
@@ -31,7 +33,8 @@
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.5",
"prettier": "^3.8.1",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"vitest": "^0.34.1"
},
"packageManager": "yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8"
}

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');
});
});
});

10
vitest.config.ts Normal file
View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
testDir: 'tests',
include: ['**/*.spec.ts'],
},
});

View File

@@ -5464,6 +5464,7 @@ __metadata:
eslint-plugin-prettier: "npm:^5.5.5"
prettier: "npm:^3.8.1"
typescript: "npm:^5.9.3"
vitest: "npm:^0.34.1"
languageName: unknown
linkType: soft