- Clone the repo, then CD into the
apps-renderingsubdirectory before running any commands - - Make sure you're using the version of Node specified in
.nvmrc - Once Node is installed, make sure you're using the correct package manager by running
corepack enable - Install dependencies:
pnpmBefore you start get mobile Janus credentials (ask someone if you're unsure what this means)
This is the simplest way to get started, but will intermingle all the logs together in one shell. If you're doing development work it might be easier to run the client and server in separate shells as described in the next subsection.
pnpm watchView in a browser at http://localhost:3030.
The Apps Rendering development server supports the following routes for testing articles in the browser:
/path/to/content/(uk|us|au|international)/path/to/content/rendered-items/path/to/content/(uk|us|au|international)/rendered-items/path/to/content
Additionally, each route above can take a ?editions query parameter to render
the article as for the Editions app.
We also recommend testing articles in the mobile device simulators. The development server also supports a specific route for testing with the device simulator:
/AppsArticle/https://www.theguardian.com/food/2020/mar/15/easter-taste-test-dan-lepard-hot-cross-bun-milk-dark-chocolate-mini-eggs-bunny-sloth
This route matches the one implemented by DCR for rendering apps articles.
Note: You will need to refresh the page to see any changes you make to the server code. Any changes to client code should reload automatically.
This will output each command's logs to different shells, which can make development easier.
To start the server:
pnpm watch:serverTo start the client:
pnpm watch:clientView in a browser at http://localhost:3030
Note: You will need to refresh the page to see any changes you make to the server code. Any changes to client code should reload automatically.
You may need to build the client-side code first with:
pnpm build:clientThen start the server with:
pnpm watch:serverView in a browser at http://localhost:3040
Note: You will need to refresh the page to see any changes you make to the server code. If you change the client code you will need to rebuild it with the first command mentioned in this subsection.
The unit tests are built using Jest. They can be run with the following command:
pnpm testESLint is used to validate the code. It can be run like this:
pnpm lintIt can automatically fix problems for you:
pnpm lint:fixA good way to see components and test them in isolation is to run storybook:
pnpm storybookStories are deployed on GitHub pages
Note These models have moved! You can now find them, along with release instructions, at
guardian/apps-rendering-api-models.
MAPI uses apps-rendering-api-models to communicate with the Apps Rendering API. To render an article, MAPI sends a RenderingRequest to Apps Rendering. The RenderingRequest includes all the information Apps Rendering requires for rendering. RenderingRequest and other associated models are defined in apps-rendering-api-models.