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 Dec 1, 2021 · 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
  • ...

Hot take: a middleware needs 3 parameters (req, res, next) and calls next() after doing its job. (unless it does an early error or a redirection)

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 data is stored in window.hotLoadPoi
  • Possible enhancement: use this PoI as initial value in poiContext ?
Clone this wiki locally