Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2014: Adds search service to the front-end #2140

Merged
merged 3 commits into from
Apr 15, 2021
Merged

Fixes #2014: Adds search service to the front-end #2140

merged 3 commits into from
Apr 15, 2021

Conversation

HyperTHD
Copy link
Contributor

Issue This PR Addresses

This PR closes #2014

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Now that the search service is functional and merged, we can finally work towards moving it to the front-end. This PR addresses that by adding the search service related arguments to the Dockerfile, the production.yml file, the next.config.js file, the config.ts file, and finally the relevant components that make requests to this endpoint. One bug in the search service is preventing this from working and so I'll need to address that before this PR is ready for review.

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated Vercel to add the Search URL env var:


14:44:10.365 | Running "npm run build"
-- | --
14:44:10.659 | > @senecacdot/[email protected] build /vercel/workpath0
14:44:10.659 | > next build && next export
14:44:11.683 | info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
14:44:11.881 | Trying to load missing ENV variables from /.env
14:44:11.881 | Trying to load missing ENV variables from /config/env.development
14:44:11.881 | Using NEXT_PUBLIC_WEB_URL=https://telescope-c64dfl18s-humphd.vercel.app
14:44:11.881 | Using NEXT_PUBLIC_API_URL=https://dev.telescope.cdot.systems
14:44:11.881 | Using NEXT_PUBLIC_IMAGE_URL=https://dev.api.telescope.cdot.systems/v1/image
14:44:11.881 | Using NEXT_PUBLIC_POSTS_URL=https://dev.api.telescope.cdot.systems/v1/posts
14:44:11.881 | Using NEXT_PUBLIC_AUTH_URL=https://dev.api.telescope.cdot.systems/v1/auth
14:44:11.881 | Using NEXT_PUBLIC_SEARCH_URL=https://dev.api.telescope.cdot.systems/v1/search

But it's getting a 404 from https://dev.api.telescope.cdot.systems/v1/search/query?text=react&filter=post&page=0. What am I missing? Is it the extra /query? in that URL?

@@ -141,6 +143,7 @@ services:
environment:
- ELASTIC_URL=http://elasticsearch
- ELASTIC_PORT=9200
- SEARCH_PORT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, we do it in docker-compose.yml.

@HyperTHD
Copy link
Contributor Author

I updated Vercel to add the Search URL env var:


14:44:10.365 | Running "npm run build"
-- | --
14:44:10.659 | > @senecacdot/[email protected] build /vercel/workpath0
14:44:10.659 | > next build && next export
14:44:11.683 | info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
14:44:11.881 | Trying to load missing ENV variables from /.env
14:44:11.881 | Trying to load missing ENV variables from /config/env.development
14:44:11.881 | Using NEXT_PUBLIC_WEB_URL=https://telescope-c64dfl18s-humphd.vercel.app
14:44:11.881 | Using NEXT_PUBLIC_API_URL=https://dev.telescope.cdot.systems
14:44:11.881 | Using NEXT_PUBLIC_IMAGE_URL=https://dev.api.telescope.cdot.systems/v1/image
14:44:11.881 | Using NEXT_PUBLIC_POSTS_URL=https://dev.api.telescope.cdot.systems/v1/posts
14:44:11.881 | Using NEXT_PUBLIC_AUTH_URL=https://dev.api.telescope.cdot.systems/v1/auth
14:44:11.881 | Using NEXT_PUBLIC_SEARCH_URL=https://dev.api.telescope.cdot.systems/v1/search

But it's getting a 404 from https://dev.api.telescope.cdot.systems/v1/search/query?text=react&filter=post&page=0. What am I missing? Is it the extra /query? in that URL?

Think it's this piece that @manekenpix mentioned when fixing the search url awhile back

image

@@ -54,7 +54,9 @@ const SearchResults = () => {
const { textParam, filter } = useSearchValue();

const prepareUrl = (index: number) =>
`${telescopeUrl}/query?text=${encodeURIComponent(textParam)}&filter=${filter}&page=${index}`;
`${searchServiceUrl}/query?text=${encodeURIComponent(
Copy link
Member

@manekenpix manekenpix Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works without query in the URL

Suggested change
`${searchServiceUrl}/query?text=${encodeURIComponent(
`${searchServiceUrl}?text=${encodeURIComponent(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep using query, this line should be:

service.router.use('/query', query);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want /query any more, please remove.

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the /query path, please remove that and I'll retest/review.

src/api/search/src/routes/query.js Show resolved Hide resolved
src/api/search/src/routes/query.js Show resolved Hide resolved
@HyperTHD HyperTHD merged commit c575236 into Seneca-CDOT:master Apr 15, 2021
@HyperTHD HyperTHD deleted the issue-2014 branch April 19, 2021 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have search service work in staging and production
3 participants