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

Split API and WebApp routes #2376

Merged
merged 36 commits into from
Aug 8, 2019
Merged

Split API and WebApp routes #2376

merged 36 commits into from
Aug 8, 2019

Conversation

saneery
Copy link
Contributor

@saneery saneery commented Jul 17, 2019

#2364

Motivation

To launch API endpoints separately from the web application.

There are three groups of endpoints:

  • Read-only API
  • Web app
  • Write endpoints

Changelog

  • Split API's and WebApp's endpoints into separate routers
  • Save old endpoints for backward compatibility
  • Update tests
  • Add envs:
    • DISABLE_WEBAPP=true
    • DISABLE_READ_API =true
    • DISABLE_INDEXER=true
    • DISABLE_WRITE_API =true
    • WEBAPP_URL=http://host/path
    • API_URL=http://host/path

@saneery saneery force-pushed the split-api-and-webapp-routes branch from 151070b to b717c37 Compare July 17, 2019 13:45
@coveralls
Copy link

coveralls commented Jul 17, 2019

Pull Request Test Coverage Report for Build 67d739b8-53c0-4bab-b3c4-225c6512606f

  • 33 of 45 (73.33%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 79.267%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/block_scout_web/lib/block_scout_web/web_router.ex 10 11 90.91%
apps/block_scout_web/lib/block_scout_web/api_router.ex 9 11 81.82%
apps/block_scout_web/lib/block_scout_web/router.ex 5 7 71.43%
apps/block_scout_web/lib/block_scout_web/views/layout_view.ex 3 6 50.0%
apps/indexer/lib/indexer/application.ex 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
apps/block_scout_web/lib/block_scout_web/controllers/chain/market_history_chart_controller.ex 1 78.57%
apps/indexer/lib/indexer/application.ex 1 0.0%
Totals Coverage Status
Change from base Build 8058fcb5-b17e-4859-8b4a-a778a384046a: 0.03%
Covered Lines: 5192
Relevant Lines: 6550

💛 - Coveralls

@saneery saneery force-pushed the split-api-and-webapp-routes branch from 4c7f331 to 3652aa2 Compare July 18, 2019 14:12
@saneery saneery added ready for review This PR is ready for reviews. and removed in progress labels Jul 19, 2019
Copy link
Contributor

@pasqu4le pasqu4le left a comment

Choose a reason for hiding this comment

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

It seems you've forgot to add a CHANGELOG entry

vbaranov added a commit that referenced this pull request Jul 22, 2019
Copy link
Member

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

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

@saneery

If I set export DISABLE_WEBAPP=true before launch

  1. Indexer still works - I see new blocks. It shouldn't
  2. I don't see api_docs view on the path. Instead, I see web app main page.

@saneery
Copy link
Contributor Author

saneery commented Jul 23, 2019

@saneery

If I set export DISABLE_WEBAPP=true before launch

  1. Indexer still works - I see new blocks. It shouldn't

@vbaranov Maybe I should add new ENV var DISABLE_INDEXER ?

  1. I don't see api_docs view on the path. Instead, I see web app main page.

The router gets ENV vars on compile-time, so you need recompile BS with that vars

$ DISABLE_WEBAPP=true mix compile --force

@saneery saneery requested a review from vbaranov July 23, 2019 09:09
@saneery saneery force-pushed the split-api-and-webapp-routes branch from 8468768 to 1e4de6e Compare July 23, 2019 09:13
@vbaranov
Copy link
Member

@vbaranov Maybe I should add new ENV var DISABLE_INDEXER ?

@saneery yes, it makes sense in order to increase manageability.

vbaranov added a commit that referenced this pull request Jul 24, 2019
Copy link
Member

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

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

@saneery I set these env vars:

DISABLE_READ_API=true
API_URL=https://localhost:3000

I expect, that write API is working in this case on the application side, but when I open http://localhost:4000/api?module=contract&action=verify it gives me 404 error

I confirm that I set those vars before compiling.

@saneery saneery force-pushed the split-api-and-webapp-routes branch from d2f473e to cc4de01 Compare August 5, 2019 10:30
@saneery saneery force-pushed the split-api-and-webapp-routes branch from cc4de01 to 843800f Compare August 5, 2019 10:50
@saneery saneery requested a review from vbaranov August 5, 2019 12:01
Copy link
Member

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

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

@saneery

If I don't set any of new env vars, I expect that app should work in a full mode, but when I go to any item in APIs menu the application shows me 404 page instead of (eth) api docs or graphiql

@saneery
Copy link
Contributor Author

saneery commented Aug 6, 2019

@saneery

If I don't set any of new env vars, I expect that app should work in a full mode, but when I go to any item in APIs menu the application shows me 404 page instead of (eth) api docs or graphiql

@vbaranov 🤔 I don't have 404 on documentation pages

@saneery
Copy link
Contributor Author

saneery commented Aug 7, 2019

@vbaranov I don't know how to reproduce your issue

@vbaranov
Copy link
Member

vbaranov commented Aug 7, 2019

@saneery yes, I should revoke my last review. I tested all possible combinations of parameters. Seems, it works. Please resolve merging conflicts. And you didn't update docs/env-variables.md with the finalized set of ENV vars.

@vbaranov
Copy link
Member

vbaranov commented Aug 7, 2019

And it is odd that all tests on the real node failed.

Copy link
Contributor

@ayrat555 ayrat555 left a comment

Choose a reason for hiding this comment

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

tests are failing

** (CompileError) test/block_scout_web/controllers/api/v1/health_controller_test.exs:15: undefined function api_v1_health_path/2

@saneery
Copy link
Contributor Author

saneery commented Aug 8, 2019

@vbaranov @pasqu4le @ayrat555 I've repaired test, could you check the PR?

Copy link
Contributor

@pasqu4le pasqu4le left a comment

Choose a reason for hiding this comment

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

Just one question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants