-
Notifications
You must be signed in to change notification settings - Fork 0
server: handle route, render based on termbox request #52
Conversation
399dd91
to
e5b339a
Compare
37f686f
to
fadd4fc
Compare
0f33b82
to
46cd53e
Compare
There was a problem hiding this 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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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' ), |
There was a problem hiding this comment.
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' ) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo!
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