@@ -52,6 +52,52 @@ async function startServer() {
5252 // Bootstrap
5353 await kernel . bootstrap ( ) ;
5454
55+ // Seed Data
56+ try {
57+ // Products
58+ const products = await memoryDriver . find ( 'product' ) ;
59+ if ( ! products || products . length === 0 ) {
60+ logger . info ( '🌱 Seeding Products...' ) ;
61+ const dummyProducts = [
62+ { name : 'MacBook Pro 16"' , sku : 'MBP16' , category : 'Electronics' , price : 2499 , stock : 45 , image : 'https://images.unsplash.com/photo-1517336714731-489689fd1ca4?auto=format&fit=crop&q=80&w=1000' } ,
63+ { name : 'Ergonomic Office Chair' , sku : 'CHAIR-v2' , category : 'Furniture' , price : 599 , stock : 120 , image : 'https://images.unsplash.com/photo-1505843490538-5133c6c7d0e1?auto=format&fit=crop&q=80&w=1000' } ,
64+ { name : 'Wireless Noise Canceling Headphones' , sku : 'AUDIO-X1' , category : 'Electronics' , price : 349 , stock : 85 , image : 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&q=80&w=1000' } ,
65+ { name : 'Standing Desk' , sku : 'DESK-PRO' , category : 'Furniture' , price : 799 , stock : 30 , image : 'https://images.unsplash.com/photo-1595515106969-1ce29566ff1c?auto=format&fit=crop&q=80&w=1000' } ,
66+ { name : 'Smart Watch Series 7' , sku : 'WATCH-S7' , category : 'Electronics' , price : 399 , stock : 200 , image : 'https://images.unsplash.com/photo-1546868871-7041f2a55e12?auto=format&fit=crop&q=80&w=1000' } ,
67+ { name : 'Bluetooth Speaker' , sku : 'SPK-BT' , category : 'Electronics' , price : 129 , stock : 150 , image : 'https://images.unsplash.com/photo-1608043152269-423dbba4e7e1?auto=format&fit=crop&q=80&w=1000' } ,
68+ ] ;
69+ for ( const p of dummyProducts ) {
70+ await memoryDriver . create ( 'product' , p ) ;
71+ }
72+ }
73+
74+ // Events
75+ const events = await memoryDriver . find ( 'event' ) ;
76+ if ( ! events || events . length === 0 ) {
77+ logger . info ( '🌱 Seeding Events...' ) ;
78+ const now = new Date ( ) ;
79+ const dummyEvents = [
80+ { subject : 'Client Meeting' , start : now , end : new Date ( now . getTime ( ) + 3600000 ) , location : 'Zoom' , type : 'Meeting' } ,
81+ { subject : 'Project Kickoff' , start : new Date ( now . getTime ( ) + 86400000 ) , end : new Date ( now . getTime ( ) + 90000000 ) , location : 'Conference Room' , type : 'Meeting' }
82+ ] ;
83+ for ( const e of dummyEvents ) await memoryDriver . create ( 'event' , e ) ;
84+ }
85+
86+ // Projects
87+ const tasks = await memoryDriver . find ( 'project_task' ) ;
88+ if ( ! tasks || tasks . length === 0 ) {
89+ logger . info ( '🌱 Seeding Projects...' ) ;
90+ const dummyTasks = [
91+ { name : 'Phase 1: Research' , start_date : '2023-11-01' , end_date : '2023-11-10' , progress : 100 , status : 'Completed' , priority : 'High' , color : '#4caf50' } ,
92+ { name : 'Phase 2: Design' , start_date : '2023-11-11' , end_date : '2023-11-25' , progress : 50 , status : 'In Progress' , priority : 'High' , color : '#2196f3' }
93+ ] ;
94+ for ( const t of dummyTasks ) await memoryDriver . create ( 'project_task' , t ) ;
95+ }
96+
97+ } catch ( e ) {
98+ logger . error ( e , 'Failed to seed data' ) ;
99+ }
100+
55101 logger . info ( '✅ CRM Server is running on http://localhost:3000' ) ;
56102 logger . info ( ' GraphQL: http://localhost:3000/graphql' ) ;
57103
0 commit comments