Commit ea3a31b1 authored by Muneeb Saeed's avatar Muneeb Saeed

Server js added

parent 101437ec
runtime: nodejs14
service: api
\ No newline at end of file
{ {
"name": "test-app", "name": "test-app",
"version": "1.0.0", "version": "1.0.0",
"main": "App.js", "main": "server.js",
"dependencies": { "dependencies": {
"@google-cloud/retail": "^2.3.0", "@google-cloud/retail": "^2.3.0",
"body-parser": "^1.20.1", "body-parser": "^1.20.1",
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"nodemon": "^2.0.20" "nodemon": "^2.0.20"
}, },
"scripts": { "scripts": {
"dev": "set GOOGLE_APPLICATION_CREDENTIALS=credentials.json && nodemon App.js", "dev": "set GOOGLE_APPLICATION_CREDENTIALS=credentials.json && nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "", "author": "",
......
...@@ -21,4 +21,5 @@ app.get('/search', (req, res) => { ...@@ -21,4 +21,5 @@ app.get('/search', (req, res) => {
.catch(err => res.send(err)) .catch(err => res.send(err))
}); });
app.listen(3002); const PORT = process.env.PORT || 8080;
app.listen(PORT);
\ No newline at end of file
#service: ulta-beauty-react
#
#runtime: nodejs16
#
#handlers:
# - url: /static
#
# static_dir: build/static
# - url: /(.*\.(json|ico|js|webp))$
#
# static_files: build/\1
#
# upload: build/.*\.(json|ico|js|webp)$
# - url: .*
#
# static_files: build/index.html
#
# upload: build/index.html
#
# - url: /public
# static_dir: public
#
# - url: /public/(.*\.(json|ico|js|webp))$
#
# static_files: public/\1
#
# upload: public/.*\.(json|ico|js|webp)$
#
runtime: nodejs14
handlers:
- url: /(.*\..+)$
static_files: build/\1
upload: build/(.*\..+)$
- url: /.*
static_files: build/index.html
upload: build/index.html
runtime: nodejs14 runtime: nodejs14
service: default
handlers: handlers:
- url: /(.*\..+)$ - url: /(.*\..+)$
static_files: ./ static_files: build/\1
upload: ./ upload: build/(.*\..+)$
- url: /.* - url: /.*
static_files: build/index.html static_files: build/index.html
upload: build/index.html upload: build/index.html
...@@ -20,7 +20,7 @@ const Search = () => { ...@@ -20,7 +20,7 @@ const Search = () => {
const handleOnSearch = async (value) => { const handleOnSearch = async (value) => {
const { text, facets } = value; const { text, facets } = value;
if (text) { if (text) {
const url = `http://localhost:3002/search?text=${text}${facets && facets.length? `&facets=${facets}` : ''}`; const url = `https://api-dot-abs-poc-np-prj-01-3f2a.uc.r.appspot.com/search?text=${text}${facets && facets.length? `&facets=${facets}` : ''}`;
const searchResults = await fetch(url) const searchResults = await fetch(url)
.then(res => res.json()) .then(res => res.json())
.catch(err => console.log(err)); .catch(err => console.log(err));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment