Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -36,7 +36,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -62,26 +62,4 @@ jobs:
frontend/dist
retention-days: 7

security:
name: Security Audit
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run security audit
run: npm audit --audit-level=moderate
continue-on-error: true

- name: Run npm audit fix
run: npm audit fix --dry-run
continue-on-error: true
# Security checks (npm audit) were removed after discussion to avoid frequent CI noise
4 changes: 3 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Extract version from package.json
id: package-version
Expand All @@ -44,6 +44,8 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
progress: plain
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
Expand Down
16 changes: 15 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
npx lint-staged
#!/bin/sh

# Run lint-staged to attempt auto-fixing staged files where possible
npx lint-staged || exit 1

echo "\n=== Running CI-like checks (format, lint, format:check, build, security audit) ==="

# Run formatting across the repo so code is auto-formatted and stage any changes
npm run format || exit 1
git add -A || true

# Run the centralized ci script (lint, format:check, build, security audit)
npm run ci || exit 1

exit 0
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COPY backend/tsconfig.json backend/build.js ./backend/
COPY backend/src ./backend/src
COPY backend/drizzle ./backend/drizzle
COPY backend/drizzle.config.ts ./backend/
COPY backend/scripts ./backend/scripts

COPY frontend/tsconfig*.json frontend/vite.config.ts frontend/components.json ./frontend/
COPY frontend/postcss.config.js frontend/tailwind.config.ts frontend/index.html ./frontend/
Expand Down
7 changes: 7 additions & 0 deletions backend/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@ await esbuild.build({
outfile: 'dist/database/seed.js',
});

// Build scripts (e.g., optional scripts/migrate-phone-hashes.ts)
await esbuild.build({
...sharedConfig,
entryPoints: ['scripts/migrate-phone-hashes.ts'],
outfile: 'dist/scripts/migrate-phone-hashes.js',
});

console.log('✅ Build complete!');
5 changes: 5 additions & 0 deletions backend/drizzle/migrations/0008_add_contact_name.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Add contact_name column to request_history table
ALTER TABLE request_history ADD COLUMN contact_name TEXT;

-- Add contact_name column to conversation_sessions table
ALTER TABLE conversation_sessions ADD COLUMN contact_name TEXT;
9 changes: 9 additions & 0 deletions backend/drizzle/migrations/0009_add_contacts_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- 0009_add_contacts_table.sql
CREATE TABLE IF NOT EXISTS contacts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
phone_number_hash TEXT NOT NULL UNIQUE,
contact_name TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_contacts_phone ON contacts (phone_number_hash);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- 0010_add_contact_phone_encrypted.sql
ALTER TABLE contacts ADD COLUMN phone_number_encrypted TEXT;
-- No index necessary for encrypted value
6 changes: 5 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wamr-backend",
"version": "1.0.2",
"version": "1.0.3",
"description": "WhatsApp Media Request Manager - Backend API",
"main": "dist/index.js",
"type": "module",
Expand All @@ -16,12 +16,16 @@
"test:coverage": "vitest run --coverage",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint src/**/*.ts --fix",
"typecheck": "tsc --project ./tsconfig.json --noEmit",
"typecheck:watch": "tsc --project ./tsconfig.json --noEmit --watch",
"format": "prettier --write \"src/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\"",
"clean": "rm -rf dist node_modules",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:migrate:run": "node dist/database/migrate.js",
"db:migrate:phone-hashes": "tsx scripts/migrate-phone-hashes.ts",
"db:migrate:phone-hashes:run": "node dist/scripts/migrate-phone-hashes.js",
"db:studio": "drizzle-kit studio",
"db:seed": "tsx src/database/seed.ts",
"db:seed:run": "node dist/database/seed.js"
Expand Down
14 changes: 14 additions & 0 deletions backend/scripts/migrate-phone-hashes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env tsx
import { runPhoneHashMigration } from '../src/services/migrations/phone-hash-migration.js';
import { logger } from '../src/config/logger.js';

(async () => {
try {
await runPhoneHashMigration();
logger.info('Phone hash migration script completed');
process.exit(0);
} catch (err) {
logger.error({ err }, 'Phone hash migration script failed');
process.exit(1);
}
})();
Loading
Loading