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 1
1
const http = require ( 'http' ) ;
2
2
const url = require ( 'url' ) ;
3
3
const crypto = require ( 'crypto' ) ;
4
+ const functions = require ( '@google-cloud/functions-framework' ) ;
4
5
5
6
// Import controllers
6
7
const { listTechnologies } = require ( './controllers/technologiesController' ) ;
@@ -117,22 +118,16 @@ const handleRequest = async (req, res) => {
117
118
// Create HTTP server
118
119
const server = http . createServer ( handleRequest ) ;
119
120
120
- // Export the server and handleRequest for testing and cloud functions
121
+ // Export the server for testing
121
122
exports . app = server ;
122
- exports . handleRequest = handleRequest ;
123
123
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)
125
128
if ( require . main === module ) {
126
129
const PORT = process . env . PORT || 3000 ;
127
130
server . listen ( PORT , ( ) => {
128
131
console . log ( `Server running on port ${ PORT } ` ) ;
129
132
} ) ;
130
133
}
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 8
8
},
9
9
"scripts" : {
10
10
"start" : " node index.js" ,
11
- "start:functions" : " functions-framework --target=api " ,
11
+ "start:functions" : " functions-framework --target=app " ,
12
12
"dev" : " nodemon index.js" ,
13
13
"test" : " jest"
14
14
},
15
15
"dependencies" : {
16
- "@google-cloud/firestore" : " 7.3.0"
16
+ "@google-cloud/firestore" : " 7.3.0" ,
17
+ "@google-cloud/functions-framework" : " ^4.0.0"
17
18
},
18
19
"devDependencies" : {
19
- "@google-cloud/functions-framework" : " ^4.0.0" ,
20
20
"jest" : " 29.7.0" ,
21
21
"nodemon" : " 3.0.1" ,
22
22
"supertest" : " ^7.1.0"
You can’t perform that action at this time.
0 commit comments