@@ -647,7 +647,43 @@ app.use(express.json({
647647
648648app . use ( cookieParser ( ) ) ;
649649
650- // Serve static frontend files BEFORE API routes
650+ // Get all investors from investor_directory table (MUST be before static middleware)
651+ app . get ( '/api/investors' , requireAuth , async ( req , res ) => {
652+ try {
653+ console . log ( 'Fetching investors from database...' ) ;
654+
655+ // Check if table exists first (MySQL syntax)
656+ const tableExists = await dbGet (
657+ `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?` ,
658+ [ 'investor_directory' ]
659+ ) ;
660+
661+ if ( ! tableExists ) {
662+ console . log ( 'investor_directory table does not exist' ) ;
663+ return res . json ( [ ] ) ;
664+ }
665+
666+ const investors = await dbAll (
667+ `SELECT
668+ id, url, image, name, vc_type, industries, about,
669+ ideal_for, no_of_investments, social_links, portfolio_companies,
670+ contact_name, contact_role, contact_linkedin, error
671+ FROM ${ tableName ( 'investor_directory' ) }
672+ ORDER BY
673+ CASE WHEN LOWER(name) LIKE '%lets venture%' THEN 0 ELSE 1 END,
674+ no_of_investments DESC,
675+ name ASC`
676+ ) ;
677+
678+ console . log ( `Found ${ investors . length } investors` ) ;
679+ res . json ( investors ) ;
680+ } catch ( error ) {
681+ console . error ( 'Error fetching investors:' , error ) ;
682+ res . status ( 500 ) . json ( { error : 'Failed to fetch investors' , details : error . message } ) ;
683+ }
684+ } ) ;
685+
686+ // Serve static frontend files AFTER API routes
651687const staticDir = path . join ( __dirname , '..' , 'frontend' ) ;
652688app . use ( express . static ( staticDir ) ) ;
653689
@@ -5482,6 +5518,10 @@ app.get('/networking.html', (req, res) => {
54825518 res . sendFile ( path . join ( staticDir , 'networking.html' ) ) ;
54835519} ) ;
54845520
5521+ app . get ( '/academy.html' , ( req , res ) => {
5522+ res . sendFile ( path . join ( staticDir , 'academy.html' ) ) ;
5523+ } ) ;
5524+
54855525app . get ( '/whisper-network.html' , ( req , res ) => {
54865526 res . sendFile ( path . join ( staticDir , 'whisper-network.html' ) ) ;
54875527} ) ;
0 commit comments