Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

2) The Express JS application

xem edited this page Jan 12, 2022 · 3 revisions

Structure

The Express code is present in the following folders:

  • /views/*.ejs : Qwant Maps HTML templates (index page, error pages)
  • /bin/*.js : entry point (index.js / app.js), helpers and middlewares

Middlewares

The middlewares intercept the requests from/to Qwant Maps to:

  • detect the browser and redirect the user if needed
  • interpret some query strings server-side
  • add metadata
  • ...

(NB: a middleware needs 3 parameters (req, res, next) and calls next() after doing its job, unless an error or redirection occurs)

HotLoadPoi

  • If a PoI is present in the URL when the application loads, prefetch_poi.js loads the item and copies its data in a <script> tag of the index page.
  • The PoI's data is stored in window.hotLoadPoi
  • Possible enhancement: use this PoI as initial value in poiContext ?
Clone this wiki locally