Commit Graph

4 Commits

Author SHA1 Message Date
Daniel Lockyer
f4fb0fcbaa Improved Ghost boot time and memory usage by lazy loading routes
no issue

- right now, we mount all API endpoints (v2, v3 and canary), alongside some
  other routes, when Ghost is booting. This is wasteful because we don't
  necessarily need any of the endpoints to get Ghost up and running
- even when Admin is used, it uses `canary` so `v2` and `v3` sit in memory
- the better approach here is to lazy load these endpoints, so they only
  get mounted when needed
- this commit adds the `lazyUse` function into our Express lib,
  which takes a mount path and a module function to execute down the
  line. This gets passed to the wonderful `express-lazy-router` lib which
  detects when we're calling an unmounted module and will mount it for
  us
- from local testing, this speeds up boot time by about 18% and reduces
  initial memory usage by about 6% 🚀
2021-10-15 17:52:07 +02:00
Sam Lord
35e51e364b Switch to @tryghost/debug, remove ghost-ignition
no issue
The only pieces of Ghost-Ignition used in Ghost were debug and
logging. Both of these modules have been superceded by the Framework
monorepo, and all usages of Ignition have now been removed, replaced
with @tryghost/debug and @tryghost/logging.
2021-06-15 17:24:22 +01:00
Hannah Wolfe
53d14fd8e3 Added Router etc to shared/express + use everywhere
- Added a wrapper around express.Router to our shared/express util
- Also export static and _express
- Use this shared util everywhre, meaning express is only used directly in this one file
- ATM this file is mostly an experiment / debug helper, it might be removed again later
- The aim is to have a minimal framework wrapping express that allows us to:
     - reduce our usage of express() in favour of Router()
     - unify some of our duplicated logic
     - fix some structural issues e.g. Sentry
     - make it easier to understand the codebase
2020-05-01 19:32:57 +01:00
Hannah Wolfe
0fe0e09d62 Moved express init + sentry to a shared util
- added core/shared to watched folders in grunt
- moved sentry to shared
- moved express initialisation to a shared file
- always set trust proxy + sentry error handler
- use this new express init everywhere, and remove duplicate trust proxy and sentry error handler code
2020-04-27 18:17:50 +01:00