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
7 changes: 7 additions & 0 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

require("dotenv").config();

const REQUIRED_ENV = ['DB_HOST', 'DB_USER', 'DB_PASSWORD', 'DB_NAME', 'SESSION_SECRET'];
const missing = REQUIRED_ENV.filter((k) => !process.env[k]);
if (missing.length) {
console.error(`Missing required env vars: ${missing.join(', ')}`);
process.exit(1);
}

var app = require("../src/app");
var debug = require("debug")("food-ordering-website:server");
var http = require("http");
Expand Down
16 changes: 16 additions & 0 deletions db/migrations/001_add_order_status.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Add status column to orders table
ALTER TABLE orders ADD COLUMN status ENUM('pending', 'dispatched') NOT NULL DEFAULT 'pending';

-- Mark any existing orders that are already in order_dispatch as dispatched
UPDATE orders o
JOIN order_dispatch od ON o.order_id = od.order_id
SET o.status = 'dispatched';

-- Copy dispatched rows that only exist in order_dispatch (not in orders)
INSERT IGNORE INTO orders (order_id, user_id, item_id, quantity, price, datetime, status)
SELECT order_id, user_id, item_id, quantity, price, datetime, 'dispatched'
FROM order_dispatch
WHERE order_id NOT IN (SELECT order_id FROM orders);

-- Drop the redundant table
DROP TABLE order_dispatch;
3 changes: 3 additions & 0 deletions db/migrations/002_fix_rating_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Change item_rating from varchar(45) to DECIMAL(2,1)
-- Existing string values like '4.3', '5.0' convert cleanly to DECIMAL
ALTER TABLE menu MODIFY COLUMN item_rating DECIMAL(2,1) NOT NULL;
2 changes: 2 additions & 0 deletions db/seed_admin_bcrypt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Update admin password to bcrypt hash of '123456789'
UPDATE admin SET admin_password = '$2a$10$3vy.RVz6qVSrqxOjElPEeOy8J1QyWWLOgn4xs1tH11yByqgF5hBWW' WHERE admin_email = 'admin_fury@gmail.com';
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testEnvironment: 'node',
setupFilesAfterEnv: ['./tests/setup.js'],
testMatch: ['**/tests/**/*.test.js'],
};
Loading