File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,32 @@ const Stock = require('../models/Stock');
4
4
const stockPriceService = require ( '../services/stockPriceService' ) ;
5
5
const { Op } = require ( 'sequelize' ) ;
6
6
const { finnhubClient } = require ( '../config/finnhub' ) ;
7
+ const axios = require ( 'axios' ) ;
8
+
9
+ // Test Finnhub connection
10
+ router . get ( '/test-finnhub/:ticker' , async ( req , res ) => {
11
+ try {
12
+ const { ticker } = req . params ;
13
+ console . log ( 'Testing Finnhub connection for ticker:' , ticker ) ;
14
+
15
+ const response = await axios . get ( 'https://finnhub.io/api/v1/quote' , {
16
+ params : {
17
+ symbol : ticker ,
18
+ token : process . env . FINNHUB_API_KEY
19
+ }
20
+ } ) ;
21
+
22
+ console . log ( 'Finnhub response:' , response . data ) ;
23
+ res . json ( response . data ) ;
24
+ } catch ( error ) {
25
+ console . error ( 'Finnhub test error:' , error . response ?. data || error . message ) ;
26
+ res . status ( 500 ) . json ( {
27
+ error : 'Finnhub test failed' ,
28
+ details : error . response ?. data || error . message ,
29
+ apiKey : process . env . FINNHUB_API_KEY ? 'Present' : 'Missing'
30
+ } ) ;
31
+ }
32
+ } ) ;
7
33
8
34
// Get all stocks
9
35
router . get ( '/' , async ( req , res ) => {
You can’t perform that action at this time.
0 commit comments