Shared DTOs, test utilities, and E2E tests for WXYC services.
This repository includes a setup script to quickly bootstrap the entire WXYC development environment.
flowchart TB
subgraph Frontend
DJ[dj-site<br/>localhost:3000]
end
subgraph Backend-Service
API[Backend API<br/>localhost:8080]
Auth[Auth Service<br/>localhost:8082]
end
subgraph Database
PG[(PostgreSQL<br/>localhost:5432)]
end
DJ --> API
DJ --> Auth
API --> PG
Auth --> PG
# Clone this repository
git clone [email protected]:WXYC/wxyc-shared.git
cd wxyc-shared
# Run the setup script
./scripts/setup-dev-environment.shThe script will:
- Check for required dependencies (Docker, Node.js, npm, git)
- Clone Backend-Service and dj-site repositories (if not present)
- Install npm dependencies
- Start PostgreSQL database
- Start backend and auth services
- Start the frontend
- Verify all services with health checks
# Show help
./scripts/setup-dev-environment.sh --help
# Skip repository cloning (if already cloned)
./scripts/setup-dev-environment.sh --skip-clone
# Skip npm install (if dependencies are current)
./scripts/setup-dev-environment.sh --skip-deps
# Start only backend services
./scripts/setup-dev-environment.sh --backend-only
# Start only frontend (assumes backend is running)
./scripts/setup-dev-environment.sh --frontend-only| Variable | Default | Description |
|---|---|---|
WXYC_DEV_ROOT |
.. |
Directory containing/for WXYC repositories |
BACKEND_BRANCH |
main |
Backend-Service branch to checkout |
FRONTEND_BRANCH |
main |
dj-site branch to checkout |
| Service | URL | Expected Response |
|---|---|---|
| Backend | http://localhost:8080/healthcheck | 200 OK |
| Auth | http://localhost:8082/auth/ok | 200 OK |
| Frontend | http://localhost:3000 | 200 OK |
Once running, log in with any of these accounts (password: testpassword123):
| Username | Role |
|---|---|
| test_member | member |
| test_dj1 | dj |
| test_dj2 | dj |
| test_music_director | musicDirector |
| test_station_manager | stationManager |
This package serves as the single source of truth for:
- DTOs: TypeScript interfaces for all API request/response types
- Test Utilities: Shared fixtures, factories, and assertions
- E2E Tests: End-to-end tests that verify full-stack integration
npm install @wxyc/sharedimport {
FlowsheetEntryResponse,
AlbumSearchResult,
isFlowsheetSongEntry,
} from '@wxyc/shared/dtos';
// Type your API responses
const entries: FlowsheetEntryResponse[] = await fetchFlowsheet();
// Use type guards
for (const entry of entries) {
if (isFlowsheetSongEntry(entry)) {
console.log(`${entry.artist_name} - ${entry.track_title}`);
}
}import {
createTestAlbum,
createTestFlowsheetEntry,
assertValidFlowsheetEntry,
resetIdCounter,
} from '@wxyc/shared/test-utils';
describe('MyComponent', () => {
beforeEach(() => {
resetIdCounter();
});
it('should display album', () => {
const album = createTestAlbum({ album_title: 'Custom Title' });
// ...
});
});| Module | Description |
|---|---|
flowsheet.dto |
Flowsheet entries, shows, on-air status |
catalog.dto |
Albums, artists, search results |
rotation.dto |
Rotation entries and frequencies |
schedule.dto |
DJ schedule and shifts |
dj.dto |
DJ profiles, bins, playlists |
request.dto |
Song requests, device auth |
metadata.dto |
External metadata (Discogs, Spotify) |
common.dto |
Shared types (errors, pagination, genres) |
| Module | Description |
|---|---|
fixtures |
Static test data for common entities |
factories |
Factory functions with override support |
assertions |
Custom assertion helpers |
# Install dependencies
npm install
# Build
npm run build
# Run unit tests
npm test
# Run E2E tests (requires running services)
npm run test:e2e
# Type check
npm run lintSee e2e/README.md for details on running E2E tests.
- Add new DTOs in
src/dtos/ - Export them from
src/dtos/index.ts - Add corresponding test fixtures/factories
- Run
npm run lintto verify types