Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

server: handle route, render based on termbox request #52

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

wiese
Copy link
Contributor

@wiese Nov 16, 2018

Integrates route handling, entity loading from repo, and app
initialization.
This also fixes a problem in the way .env is loaded and removes the
redundant setting of SSR_PORT (part of what .env loading tried) to the
ssr service's environment - all project settings are now loaded into
the node environment from the file system inside server.ts

Depends on #48 & #50

Bug: T207467

Copy link
Member

@jakobw jakobw left a comment

Choose a reason for hiding this comment

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

Oh mah gawd it works!!1

@@ -39,6 +40,7 @@
"@vue/test-utils": "^1.0.0-beta.20",
"babel-core": "7.0.0-bridge.0",
"concurrently": "^4.0.1",
"nock": "^10.0.2",
Copy link
Member

Choose a reason for hiding this comment

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

/me keeps nock nock jokes to himself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Who's there?

{},
{},
{},
const termboxHandler = new TermboxHandler(
Copy link
Member

Choose a reason for hiding this comment

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

I like how this route controller-y thingy reads with the TermboxHandler.

@@ -4,11 +4,15 @@ import 'module-alias/register';
import app from './app';

dotenv.config( {
path: path.resolve( __dirname, '.env' ),
path: path.resolve( __dirname, '../../.env' ),
Copy link
Member

Choose a reason for hiding this comment

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

heh.


it( 'renders Server Error when requesting /termbox and backend request encounters malformed response', ( done ) => {
nock( WIKIBASE_TEST_API_HOST )
.post( WIKIBASE_TEST_API_PATH + '?format=json', 'ids=Q64&action=wbgetentities' )
Copy link
Member

Choose a reason for hiding this comment

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

Why the split between format and action/ids query params?

Copy link
Contributor Author

@wiese Nov 20, 2018

Choose a reason for hiding this comment

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

It may not be obvious but mwbot (unless we tell it otherwise - which may be wise) actually performs a post request. The latter part is the body.

const WIKIBASE_TEST_API_PATH = '/api.php';

describe( 'Termbox SSR', () => {
app.set( 'WIKIBASE_REPO_API', WIKIBASE_TEST_API_HOST + WIKIBASE_TEST_API_PATH );
Copy link
Member

@jakobw jakobw Nov 20, 2018

Choose a reason for hiding this comment

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

TIL. This app.get( /* route */ ) vs app.get( /* config */ ) was a bit confusing to me, but the fact that it is configurable like that is nice for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right - bit iffy. Just look at the ToC: https://expressjs.com/en/api.html#app.set

@@ -3,3 +3,5 @@ SSR_PORT=3030
MEDIAWIKI_NETWORK_TO_JOIN=
CSR_PORT=8080
NODE_ENV=development
# set to e.g. the api script of your development environment's mediawiki
WIKIBASE_REPO_API=http://default.web.mw.localhost/mediawiki/api.php
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakobw Thanks for poking me on this. Do you think the version w/ or w/o the /mediawiki path is more common?

Copy link
Member

Choose a reason for hiding this comment

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

I think with /mediawiki is. That's the one that works for me, too.

Integrates route handling, entity loading from repo, and app
initialization.
This also fixes a problem in the way .env is loaded and removes the
redundant setting of SSR_PORT (part of what .env loading tried) to the
ssr service's environment - all project settings are now loaded into
the node environment from the file system inside server.ts

Bug: T207467
Copy link
Member

@jakobw jakobw left a comment

Choose a reason for hiding this comment

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

Woo!

@jakobw jakobw merged commit cc530f5 into master Nov 20, 2018
@jakobw jakobw deleted the request-handler3-do branch November 20, 2018 13:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants