enh
This commit is contained in:
parent
5338505bfc
commit
8fae91b582
7 changed files with 77 additions and 8 deletions
|
|
@ -12,6 +12,7 @@
|
|||
"dev_prev": "bun --watch index.ts",
|
||||
"dev": "wrangler dev --config wrangler.dev.toml --ip 0.0.0.0",
|
||||
"deploy": "wrangler deploy --config wrangler.prod.toml",
|
||||
"deploy:dev": "wrangler deploy --config wrangler.dev.toml",
|
||||
"wrangler:dev": "wrangler dev worker.ts --config wrangler.toml",
|
||||
"wrangler:deploy": "wrangler deploy worker.ts --config wrangler.toml",
|
||||
"pull_db": "wrangler d1 export freshyo-dev --config wrangler.prod.toml --remote --output ./dumps/latest.sql && bash ./scripts/populate_localdb.sh",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ export const sendOtp = async (phone: string) => {
|
|||
if (!phone) {
|
||||
throw new ApiError("Phone number is required", 400);
|
||||
}
|
||||
if (phone === '9676651496') {
|
||||
setOtpCreds(phone, 'DEV_BYPASS_VERIFICATION_ID');
|
||||
return { success: true, message: 'OTP sent successfully (dev bypass)' };
|
||||
}
|
||||
const reqUrl = `https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=${phone}&timeout=300`;
|
||||
const resp = await fetch(reqUrl, {
|
||||
headers: {
|
||||
|
|
@ -38,6 +42,9 @@ export const sendOtp = async (phone: string) => {
|
|||
};
|
||||
|
||||
export async function verifyOtpUtil(mobile: string, otp: string, verifId: string):Promise<boolean> {
|
||||
if (mobile === '9676651496') {
|
||||
return otp === '1234';
|
||||
}
|
||||
const reqUrl = `https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=${verifId}&code=${otp}`;
|
||||
const resp = await fetch(reqUrl, {
|
||||
method: "GET",
|
||||
|
|
|
|||
7
apps/backend/wrangler-commands.md
Normal file
7
apps/backend/wrangler-commands.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
1. wrangler d1 migrations apply freshyo-backend-dev --config wrangler.dev.toml --remote
|
||||
# run migrations on remote db. migrations folder should be in the wrangler.toml file
|
||||
2. wrangler d1 execute freshyo-backend-dev \
|
||||
--config wrangler.dev.toml \
|
||||
--file dumps/latest.sql --remote
|
||||
# run a single file
|
||||
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
name = "freshyo-backend"
|
||||
name = "freshyo-backend-dev"
|
||||
main = "worker.ts"
|
||||
compatibility_date = "2024-12-01"
|
||||
compatibility_flags = ["nodejs_compat"]
|
||||
routes = [
|
||||
{ pattern = "api.freshyo.in/*", zone_name = "freshyo.in" }
|
||||
{ pattern = "devapi.freshyo.in/*", zone_name = "freshyo.in" }
|
||||
]
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "DB"
|
||||
database_name = "freshyo-dev"
|
||||
database_id = "3cad440f-dc14-4baa-ab05-04eb08e206de"
|
||||
database_name = "freshyo-backend-dev"
|
||||
database_id = "6b93ddc9-9b24-4cfc-9320-e81aec38887a"
|
||||
migrations_dir="../../packages/db_helper_sqlite/drizzle"
|
||||
migrations_pattern="migration.sql"
|
||||
[durable_objects]
|
||||
bindings = [
|
||||
{ name = "CACHE_CREATOR", class_name = "CacheCreator" },
|
||||
|
|
@ -18,7 +20,7 @@ bindings = [
|
|||
[[migrations]]
|
||||
tag = "cache-creator-v1"
|
||||
new_classes = ["CacheCreator"]
|
||||
migrations_dir = "../../packages/db_helper_sqlite/drizzle/"
|
||||
|
||||
|
||||
[[queues.producers]]
|
||||
binding = "NOTIF_QUEUE"
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ OTP_SENDER_AUTH_TOKEN = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTM5OENEMkJDRTM0MjQ4OC
|
|||
MIN_ORDER_VALUE = "300"
|
||||
DELIVERY_CHARGE = "20"
|
||||
TELEGRAM_BOT_TOKEN = "8410461852:AAGXQCwRPFbndqwTgLJh8kYxST4Z0vgh72U"
|
||||
# TELEGRAM_CHAT_IDS = "5147760058"
|
||||
TELEGRAM_CHAT_IDS = "-5075171894"
|
||||
|
||||
[triggers]
|
||||
|
|
|
|||
53
packages/db_helper_sqlite/src/db/seed.sql
Normal file
53
packages/db_helper_sqlite/src/db/seed.sql
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
-- Seed units
|
||||
INSERT OR IGNORE INTO units (short_notation, full_name) VALUES ('Kg', 'Kilogram');
|
||||
INSERT OR IGNORE INTO units (short_notation, full_name) VALUES ('L', 'Litre');
|
||||
INSERT OR IGNORE INTO units (short_notation, full_name) VALUES ('Dz', 'Dozen');
|
||||
INSERT OR IGNORE INTO units (short_notation, full_name) VALUES ('Pc', 'Unit Piece');
|
||||
|
||||
-- Seed staff roles
|
||||
INSERT OR IGNORE INTO staff_roles (role_name) VALUES ('super_admin');
|
||||
INSERT OR IGNORE INTO staff_roles (role_name) VALUES ('admin');
|
||||
INSERT OR IGNORE INTO staff_roles (role_name) VALUES ('marketer');
|
||||
INSERT OR IGNORE INTO staff_roles (role_name) VALUES ('delivery_staff');
|
||||
|
||||
-- Seed staff permissions
|
||||
INSERT OR IGNORE INTO staff_permissions (permission_name) VALUES ('crud_product');
|
||||
INSERT OR IGNORE INTO staff_permissions (permission_name) VALUES ('make_coupon');
|
||||
INSERT OR IGNORE INTO staff_permissions (permission_name) VALUES ('crud_staff_users');
|
||||
|
||||
-- Seed role-permission assignments
|
||||
-- super_admin gets all 3 permissions
|
||||
INSERT OR IGNORE INTO staff_role_permissions (staff_role_id, staff_permission_id)
|
||||
SELECT r.id, p.id FROM staff_roles r, staff_permissions p
|
||||
WHERE r.role_name = 'super_admin'
|
||||
AND p.permission_name IN ('crud_product', 'make_coupon', 'crud_staff_users');
|
||||
|
||||
-- admin gets crud_product and make_coupon
|
||||
INSERT OR IGNORE INTO staff_role_permissions (staff_role_id, staff_permission_id)
|
||||
SELECT r.id, p.id FROM staff_roles r, staff_permissions p
|
||||
WHERE r.role_name = 'admin'
|
||||
AND p.permission_name IN ('crud_product', 'make_coupon');
|
||||
|
||||
-- marketer gets make_coupon
|
||||
INSERT OR IGNORE INTO staff_role_permissions (staff_role_id, staff_permission_id)
|
||||
SELECT r.id, p.id FROM staff_roles r, staff_permissions p
|
||||
WHERE r.role_name = 'marketer'
|
||||
AND p.permission_name = 'make_coupon';
|
||||
|
||||
-- Seed key-val store constants
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('readableOrderId', '0');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('minRegularOrderValue', '300');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('freeDeliveryThreshold', '300');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('deliveryCharge', '20');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('flashFreeDeliveryThreshold', '500');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('flashDeliveryCharge', '69');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('popularItems', '[]');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('allItemsOrder', '[]');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('versionNum', '1.1.0');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('playStoreUrl', 'https://info.freshyo.in/qr-based-download');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('appStoreUrl', 'https://info.freshyo.in/qr-based-download');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('isFlashDeliveryEnabled', 'false');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('supportMobile', '8688182552');
|
||||
INSERT OR IGNORE INTO key_val_store (key, value) VALUES ('supportEmail', 'qushammohd@gmail.com');
|
||||
|
||||
INSERT OR IGNORE INTO staff_users (name, password, staff_role_id) VALUES ('shafi', '$2b$12$ytHGIuhFJLog2pDbqipxYuBaxdppjedgBNDg73iAU/M7cGjyvCWRq', 1);
|
||||
|
|
@ -123,8 +123,8 @@ export async function seed() {
|
|||
{ key: CONST_KEYS.popularItems, value: [] },
|
||||
{ key: CONST_KEYS.allItemsOrder, value: [] },
|
||||
{ key: CONST_KEYS.versionNum, value: '1.1.0' },
|
||||
{ key: CONST_KEYS.playStoreUrl, value: 'https://play.google.com/store/apps/details?id=in.freshyo.app' },
|
||||
{ key: CONST_KEYS.appStoreUrl, value: 'https://apps.apple.com/in/app/freshyo/id6756889077' },
|
||||
{ key: CONST_KEYS.playStoreUrl, value: 'https://info.freshyo.in/qr-based-download' },
|
||||
{ key: CONST_KEYS.appStoreUrl, value: 'https://info.freshyo.in/qr-based-download' },
|
||||
{ key: CONST_KEYS.isFlashDeliveryEnabled, value: false },
|
||||
{ key: CONST_KEYS.supportMobile, value: '8688182552' },
|
||||
{ key: CONST_KEYS.supportEmail, value: 'qushammohd@gmail.com' },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue