File tree Expand file tree Collapse file tree 3 files changed +9
-36
lines changed
Expand file tree Collapse file tree 3 files changed +9
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11const http = require ( 'http' ) ;
22const url = require ( 'url' ) ;
33const crypto = require ( 'crypto' ) ;
4+ const functions = require ( '@google-cloud/functions-framework' ) ;
45
56// Import controllers
67const { listTechnologies } = require ( './controllers/technologiesController' ) ;
@@ -117,22 +118,16 @@ const handleRequest = async (req, res) => {
117118// Create HTTP server
118119const server = http . createServer ( handleRequest ) ;
119120
120- // Export the server and handleRequest for testing and cloud functions
121+ // Export the server for testing
121122exports . app = server ;
122- exports . handleRequest = handleRequest ;
123123
124- // Start server in development mode (not when imported as module)
124+ // Register with Functions Framework for Cloud Functions
125+ functions . http ( 'app' , handleRequest ) ;
126+
127+ // For standalone server mode (local development)
125128if ( require . main === module ) {
126129 const PORT = process . env . PORT || 3000 ;
127130 server . listen ( PORT , ( ) => {
128131 console . log ( `Server running on port ${ PORT } ` ) ;
129132 } ) ;
130133}
131-
132- // Functions Framework wrapper for Google Cloud Functions
133- try {
134- const functions = require ( '@google-cloud/functions-framework' ) ;
135- functions . http ( 'api' , handleRequest ) ;
136- } catch ( error ) {
137- // Functions Framework not available in development mode
138- }
Original file line number Diff line number Diff line change 88 },
99 "scripts" : {
1010 "start" : " node index.js" ,
11- "start:functions" : " functions-framework --target=api " ,
11+ "start:functions" : " functions-framework --target=app " ,
1212 "dev" : " nodemon index.js" ,
1313 "test" : " jest"
1414 },
1515 "dependencies" : {
16- "@google-cloud/firestore" : " 7.3.0"
16+ "@google-cloud/firestore" : " 7.3.0" ,
17+ "@google-cloud/functions-framework" : " ^4.0.0"
1718 },
1819 "devDependencies" : {
19- "@google-cloud/functions-framework" : " ^4.0.0" ,
2020 "jest" : " 29.7.0" ,
2121 "nodemon" : " 3.0.1" ,
2222 "supertest" : " ^7.1.0"
You can’t perform that action at this time.
0 commit comments