-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from joshuaisaact/pino
feat: implemented pino for logging and errors. full refactor. need to update tests before merge
- Loading branch information
Showing
104 changed files
with
4,593 additions
and
3,028 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Integration Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
integration-tests: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: testuser | ||
POSTGRES_PASSWORD: testpassword | ||
POSTGRES_DB: testdb | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'npm' | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
id: npm-cache | ||
with: | ||
path: | | ||
**/node_modules | ||
~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Set environment variables | ||
env: | ||
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
TEST_DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }} | ||
TEST_USER_UUID: ${{ secrets.TEST_USER_UUID }} | ||
run: | | ||
echo "SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}" >> $GITHUB_ENV | ||
echo "SUPABASE_URL=${SUPABASE_URL}" >> $GITHUB_ENV | ||
echo "TEST_DATABASE_URL=${TEST_DATABASE_URL}" >> $GITHUB_ENV | ||
echo "DATABASE_URL=${TEST_DATABASE_URL}" >> $GITHUB_ENV | ||
echo "TEST_USER_UUID=${TEST_USER_UUID}" >> $GITHUB_ENV | ||
- name: Generate test migrations | ||
run: npm run drizzle:generate:test | ||
env: | ||
NODE_ENV: test | ||
|
||
- name: Run test migrations | ||
run: npm run drizzle:migrate:test | ||
env: | ||
NODE_ENV: test | ||
DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb | ||
|
||
- name: Run integration tests with coverage | ||
run: | | ||
npm run test:integration -- --coverage --verbose --runInBand --detectOpenHandles | ||
env: | ||
NODE_ENV: test | ||
DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'npm' | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
id: npm-cache | ||
with: | ||
path: | | ||
**/node_modules | ||
~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Set environment variables | ||
env: | ||
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
TEST_DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }} | ||
run: | | ||
echo "SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}" >> $GITHUB_ENV | ||
echo "SUPABASE_URL=${SUPABASE_URL}" >> $GITHUB_ENV | ||
echo "TEST_DATABASE_URL=${TEST_DATABASE_URL}" >> $GITHUB_ENV | ||
echo "DATABASE_URL=${TEST_DATABASE_URL}" >> $GITHUB_ENV | ||
- name: Run unit tests with coverage | ||
run: npm run test:unit -- --coverage | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
services: | ||
postgres: | ||
image: postgres:latest | ||
container_name: test_postgres | ||
environment: | ||
POSTGRES_USER: testuser | ||
POSTGRES_PASSWORD: testpassword | ||
POSTGRES_DB: testdb | ||
ports: | ||
- '5432:5432' | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
export default defineConfig({ | ||
out: './drizzle', // Directory to output the migration files | ||
schema: './src/db/tables/*.ts', // Path to your test schema (same as production schema) | ||
dialect: 'postgresql', // Use PostgreSQL since you're using pgmem (in-memory PostgreSQL) | ||
dbCredentials: { | ||
url: | ||
process.env.TEST_DATABASE_URL || | ||
'postgres://testuser:testpassword@localhost:5432/testdb', // Connection string (pgmem creates an in-memory PostgreSQL database) | ||
}, | ||
verbose: true, | ||
strict: false, | ||
migrations: { | ||
prefix: 'timestamp', // Migration file prefix | ||
table: '__drizzle_migrations__', // Table to track migrations | ||
schema: 'public', // Schema to use for migrations | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
CREATE TABLE `activities` ( | ||
`activity_id` integer AUTOINCREMENT, | ||
`activity_name` text, | ||
`description` text, | ||
`location` text, | ||
`latitude` real, | ||
`longitude` real, | ||
`created_at` text DEFAULT CURRENT_TIMESTAMP, | ||
`price` text, | ||
`location_id` integer, | ||
`duration` text, | ||
`difficulty` text, | ||
`category` text, | ||
`best_time` text | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `destinations` ( | ||
`destination_id` integer AUTOINCREMENT, | ||
`destination_name` text, | ||
`normalized_name` text, | ||
`latitude` real, | ||
`longitude` real, | ||
`description` text, | ||
`country` text, | ||
`created_at` text DEFAULT CURRENT_TIMESTAMP, | ||
`best_time_to_visit` text, | ||
`average_temperature_low` text, | ||
`average_temperature_high` text, | ||
`popular_activities` text, | ||
`travel_tips` text, | ||
`nearby_attractions` text, | ||
`transportation_options` text, | ||
`accessibility_info` text, | ||
`official_language` text, | ||
`currency` text, | ||
`local_cuisine` text, | ||
`cost_level` text, | ||
`safety_rating` text, | ||
`cultural_significance` text, | ||
`user_ratings` text | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX `destinations_normalized_name_unique` ON `destinations` (`normalized_name`);--> statement-breakpoint | ||
CREATE TABLE `itinerary_days` ( | ||
`day_id` integer AUTOINCREMENT, | ||
`created_at` text DEFAULT CURRENT_TIMESTAMP, | ||
`trip_id` integer, | ||
`day_number` integer, | ||
`activity_id` integer | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `saved_destinations` ( | ||
`id` integer AUTOINCREMENT, | ||
`user_id` text, | ||
`destination_id` integer, | ||
`created_at` text DEFAULT CURRENT_TIMESTAMP, | ||
`notes` text, | ||
`is_visited` integer DEFAULT false, | ||
FOREIGN KEY (`destination_id`) REFERENCES `destinations`(`destination_id`) ON UPDATE no action ON DELETE cascade | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `trips` ( | ||
`trip_id` integer AUTOINCREMENT, | ||
`user_id` text, | ||
`destination_id` integer, | ||
`start_date` text, | ||
`created_at` text DEFAULT CURRENT_TIMESTAMP, | ||
`num_days` integer | ||
); |
Oops, something went wrong.