This commit is contained in:
Mathieu Sanchez 2019-06-12 22:42:51 +09:00
parent 1b2c44eb83
commit d6650e31ab
2 changed files with 13 additions and 2 deletions

View File

@ -14,6 +14,7 @@
}, },
"main": "lib/index.js", "main": "lib/index.js",
"dependencies": { "dependencies": {
"cors": "^2.8.5",
"firebase-admin": "~7.0.0", "firebase-admin": "~7.0.0",
"firebase-functions": "^2.3.0", "firebase-functions": "^2.3.0",
"request": "^2.88.0" "request": "^2.88.0"

View File

@ -1,4 +1,7 @@
import * as functions from 'firebase-functions'; import * as functions from 'firebase-functions';
// import * as request from 'request';
const cors = require( 'cors' )( { origin: true } );
// // Start writing Firebase Functions // // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript // // https://firebase.google.com/docs/functions/typescript
@ -7,10 +10,17 @@ import * as functions from 'firebase-functions';
// response.send("Hello from Firebase!"); // response.send("Hello from Firebase!");
// }); // });
export const search = functions.https.onRequest( ( req, res ) => { exports.search = functions.https.onRequest( ( req, res ) => {
res.send( '[{"tfidf":"0.0052","url":"https://www.skysports.com/share/11740401"},{"tfidf":"0.0023","url":"https://www.skysports.com/share/11740370"},{"tfidf":"0.0021","url":"https://www.skysports.com/share/11740366"},{"tfidf":"0","url":"https://www.skysports.com/share/11740338"},{"tfidf":"0.0012","url":"https://www.skysports.com/share/11740227"},{"tfidf":"0.0038","url":"https://www.skysports.com/share/11740400"},{"tfidf":"0","url":"https://www.skysports.com/share/11728937"},{"tfidf":"0","url":"https://www.skysports.com/share/11731660"},{"tfidf":"0.0007","url":"https://www.skysports.com/share/11739856"},{"tfidf":"0.0035","url":"https://www.skysports.com/share/11740171"},{"tfidf":"0.0007","url":"https://www.skysports.com/share/11740333"},{"tfidf":"0.0009","url":"https://www.skysports.com/share/11709253"},{"tfidf":"0","url":"https://www.skysports.com/share/11709512"},{"tfidf":"0","url":"https://www.skysports.com/share/11713244"},{"tfidf":"0","url":"https://www.skysports.com/share/11740141"}]' ); res.send( '[{"tfidf":"0.0052","url":"https://www.skysports.com/share/11740401"},{"tfidf":"0.0023","url":"https://www.skysports.com/share/11740370"},{"tfidf":"0.0021","url":"https://www.skysports.com/share/11740366"},{"tfidf":"0","url":"https://www.skysports.com/share/11740338"},{"tfidf":"0.0012","url":"https://www.skysports.com/share/11740227"},{"tfidf":"0.0038","url":"https://www.skysports.com/share/11740400"},{"tfidf":"0","url":"https://www.skysports.com/share/11728937"},{"tfidf":"0","url":"https://www.skysports.com/share/11731660"},{"tfidf":"0.0007","url":"https://www.skysports.com/share/11739856"},{"tfidf":"0.0035","url":"https://www.skysports.com/share/11740171"},{"tfidf":"0.0007","url":"https://www.skysports.com/share/11740333"},{"tfidf":"0.0009","url":"https://www.skysports.com/share/11709253"},{"tfidf":"0","url":"https://www.skysports.com/share/11709512"},{"tfidf":"0","url":"https://www.skysports.com/share/11713244"},{"tfidf":"0","url":"https://www.skysports.com/share/11740141"}]' );
// request( 'http://142.4.212.26:8080/search?s=' + req.params[0], ( error, response, body ) => { // request( 'http://142.4.212.26:8080/search?s=' + req.params[ 0 ], ( error, response, body ) => {
// res.send( body ); // res.send( body );
// } ); // } );
} ); } );
exports.cors = functions.https.onRequest( ( req, res ) => {
cors( req, res, () => {
res.send( 'Hello from Firebase!' );
} );
} );