Closed yahonda closed 10 months ago
Based on the error message, it looks like DATA_SERVICE_USERNAME
, DATA_SERVICE_PASSWORD,
DATA_SERVICE_ENDPOINT` environment variables need configured.
Taking a look at https://docs.pingcap.com/tidbcloud/data-service-get-started but still I have not found how to configure them. Please advise.
The datasrouce config successfully pulled from tidbcloud.
See commit a36e48
Files deployed at https://github.com/pingcap/sp500-insight-template/tree/main/datasource/dataservice
This issue has been resolved.
Go to "Authentication" -> "Create API Key" and choose "ReadOnly" role.
then set the "Public Key" value as DATA_SERVICE_USERNAME
, the "Private Key" value as DATA_SERVICE_PASSWORD
.
Also DATA_SERVICE_ENDPOINT
=https://ap-northeast-1.data.tidbcloud.com/api/v1beta/app/
Run npm run dev
and open http://localhost/3000
Click S&P 500 Analysis
, Ranking
and Constituents
to see if they works.
Still the Selected Stocks
gets Unhandled Runtime Error TypeError: data.map is not a function
that should be another issue.
Closing this issue as resolved. Thanks for the kind help.
Steps to reproduce
Install, Node.js, npm and pnpm versions as follows.
Create a TiDB Serverless instance, named "Cluster0"
Import "S%P 500 Analysis"
sp500insight
database and its tablesDatabase changed mysql> show tables; +------------------------+ | Tables_in_sp500insight | +------------------------+ | companies | | index_compositions | | index_price_history | | indexes | | stock_price_history | | user_selected_stocks | | users | +------------------------+ 7 rows in set (0.01 sec)
mysql> select count() from companies; +----------+ | count() | +----------+ | 493 | +----------+ 1 row in set (0.02 sec)
mysql> select count() from index_compositions; +----------+ | count() | +----------+ | 493 | +----------+ 1 row in set (0.02 sec)
mysql> select count() from index_price_history; +----------+ | count() | +----------+ | 2517 | +----------+ 1 row in set (0.01 sec)
mysql> select count() from indexes; +----------+ | count() | +----------+ | 1 | +----------+ 1 row in set (0.01 sec)
mysql> select count() from stock_price_history; +----------+ | count() | +----------+ | 1157000 | +----------+ 1 row in set (0.49 sec)
mysql> select count() from user_selected_stocks; +----------+ | count() | +----------+ | 14 | +----------+ 1 row in set (0.01 sec)
mysql> select count() from users; +----------+ | count() | +----------+ | 1 | +----------+ 1 row in set (0.01 sec)
mysql>
git clone https://github.com/pingcap/sp500-insight-template cd sp500-insight-template npm install
export DATABASE_URL=mysql://:@gateway01.us-west-2.prod.aws.tidbcloud.com:4000/sp500insight?timezone=Z
% npm run dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000 warn - You have enabled experimental features (appDir, serverComponentsExternalPackages, mdxRs) in next.config.js. warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info - Thank you for testing
appDir
please leave your feedback at https://nextjs.link/app-feedback event - compiled client and server successfully in 1263 ms (265 modules) wait - compiling... event - compiled client and server successfully in 362 ms (265 modules)error - Error: Data service not configured. at executeEndpoint (webpack-internal:///(sc_server)/./utils/data-api/server.ts:24:15) at eval (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:36:119) at withUpstreamErrorHandled (webpack-internal:///(sc_server)/./utils/data-api/server.ts:71:22) at handle (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:35:96) at GET (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:18:12) at /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:308:24 at AsyncLocalStorage.run (node:async_hooks:338:14) at StaticGenerationAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:32:24) at StaticGenerationAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:7:52) at /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:217:52 at AsyncLocalStorage.run (node:async_hooks:338:14) at RequestAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/request-async-storage-wrapper.js:65:24) at RequestAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/request-async-storage-wrapper.js:30:43) at AppRouteRouteHandler.execute (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:214:69) at AppRouteRouteHandler.handle (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:350:41) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RouteHandlerManager.handle (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handler-managers/route-handler-manager.js:16:24) at async doRender (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/base-server.js:743:32) at async cacheEntry1.responseCache.get.incrementalCache.incrementalCache (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/base-server.js:929:28) at async /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/response-cache/index.js:83:36 error - Error: Data service not configured. at executeEndpoint (webpack-internal:///(sc_server)/./utils/data-api/server.ts:24:15) at eval (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:36:119) at withUpstreamErrorHandled (webpack-internal:///(sc_server)/./utils/data-api/server.ts:71:22) at handle (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:35:96) at GET (webpack-internal:///(sc_server)/./app/data-api/[...id]/route.ts:18:12) at /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:308:24 at AsyncLocalStorage.run (node:async_hooks:338:14) at StaticGenerationAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:32:24) at StaticGenerationAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:7:52) at /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:217:52 at AsyncLocalStorage.run (node:async_hooks:338:14) at RequestAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/request-async-storage-wrapper.js:65:24) at RequestAsyncStorageWrapper.wrap (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/async-storage/request-async-storage-wrapper.js:30:43) at AppRouteRouteHandler.execute (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:214:69) at AppRouteRouteHandler.handle (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:350:41) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RouteHandlerManager.handle (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/future/route-handler-managers/route-handler-manager.js:16:24) at async doRender (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/base-server.js:743:32) at async cacheEntry1.responseCache.get.incrementalCache.incrementalCache (/Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/base-server.js:929:28) at async /Users/yahonda/src/github.com/pingcap/sp500-insight-template/node_modules/next/dist/server/response-cache/index.js:83:36