Wikimedia Apps/Team/RESTBase services for apps/Notes

From mediawiki.org

Routes[edit]

All routes start with {domain}/[...]v1/page:

Not actively developed[edit]

  • mobile-html (pure HTML, going away)
  • mobile-text (for Lite app)

Active development[edit]

  • mobile-html-sections
  • mobile-html-sections-lead
  • mobile-html-sections-remaining

Deployments / URIs[edit]

Local dev environment[edit]

http://localhost:6927/en.wikipedia.org/v1/page/mobile-html-sections/Munich

http://localhost:6927/en.wikipedia.org/v1/page/mobile-html-sections-lead/Munich

http://localhost:6927/en.wikipedia.org/v1/page/mobile-html-sections-remaining/Munich

Labs (mobileapps.wmflabs.org)[edit]

(Updated when code gets merged)

http://mobileapps.wmflabs.org/en.wikipedia.org/v1/page/mobile-html-sections/Munich

http://mobileapps.wmflabs.org/en.wikipedia.org/v1/page/mobile-html-sections-lead/Munich

http://mobileapps.wmflabs.org/en.wikipedia.org/v1/page/mobile-html-sections-remaining/Munich

Production (Service Cluster B)[edit]

(Deployment windows on Monday/Wednesday at 1:00PM PT.) Using RESTBase infrastructure. Docs.

https://en.wikipedia.org/api/rest_v1/page/mobile-html-sections/Munich

https://en.wikipedia.org/api/rest_v1/page/mobile-html-sections-lead/Munich

https://en.wikipedia.org/api/rest_v1/page/mobile-html-sections-remaining/Munich

Response format / Content[edit]

  • sections[] split between lead + remaining
  • changed/extra properties in lead response:
    • lead image
    • first infobox as JSON object,
    • text extracts,
    • pronunciation,
    • spokenWikipedia,
    • geo,
    • media {images, videos}
  • lead: should we have a mobile-preview route?

Architecture/Data Flow[edit]

RESTBase is the infrastructure which is hosting our Node.js service. Parallel requests to backend services:

  • action=mobileview
  • parsoid (soon)
  • gen=images -> prop=imageinfo | prop=videoinfo
  • extract

Development/Nodejs[edit]

  • Started with Marko's project template.
  • Node.js service, Express app
  • Parallel requests to backend services via Promises

Important commands[edit]

 npm install
 npm start
 npm test
 npm run-script coverage
 rm -rf node_modules

Files/folders of note[edit]

  • spec.yaml (Swagger spec, x-amples)
  • app.js (initApp, loadRoutes, createServer)
  • routes/mobile-html-sections.js (version 1, routes, promises)
  • lib/transforms.js (domino)
  • lib/mwapi.js
  • test/mobile-html-sections/pagecontent.js (describe.only)

Edit/debug[edit]

IntelliJ + Node.js plugin (WebStorm), any editor with JS syntax highlighting would do just fine

Use a lot of console.log() for debugging (sometimes with JSON.stringify() or pretty JSON.stringify(obj, null, 2)). Can't use JSON.stringify() for DOM elements due to the circular nature of DOM. util.inspect(obj) is not a ton of help but may be a start.

Enable it from the app / roll-out to Android Beta app[edit]

In App: Settings > Developer options > RESTBase access

Node.js service developers also change RESTBaseUriFormat to point to their dev machines.