Commit Graph

76 Commits

Author SHA1 Message Date
Naz
917641be4f Removed no backend optimization in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- The expectation is to only skip monting the backend API routes instead of skipping creation of whole GhostServer
2021-11-22 21:56:32 +13:00
Naz
bbc93ff996 Renamed withBackend/withFrotned to backend/frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- Shorter name still makes sense and the "with" might be causing confusion understanding what's gonig on during the boot time
2021-11-22 21:56:32 +13:00
Naz
d0dfac438d Changed /^testing/ regexp use to startsWith method
no issue

- `startsWith` method is way easier to read and understand. also, **probably** has better performance comparing to building up a regexp and then matching
2021-11-22 21:56:32 +13:00
Naz
c12ae81ece Introduced "withFrontend" and "withBackend" flags in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- These flags are meant to control initialization of sections of the boot sequence depending on the needs - with or without bakend (API)/frontend (public handlebars site)
- Ideally these flags should not be passed deep into the components, and if the are (like in the web/parent/app case) it's a smell that we need to move things up into the boot process!
2021-11-22 21:56:32 +13:00
Hannah Wolfe
4f9b72ff43
Renamed middlewares to middleware consistently
- This is a minor bugbare, but it will affect some configuration I'm about to do for c8
- I've been wanting to do it for ages, middleware is plural all on it's own so it's an odd affectation in our codebase
- This also only exists in 2 places, everywhere else we use "middleware"
- Sadly it did result in a lot of churn as I did a full find and replace, but consistency is king!
2021-11-16 15:51:47 +00:00
Hannah Wolfe
9a8b18a473
Swapped boot order for version util
- The version util is now required in logging as well as sentry and migrations
- I can see us needing it in config too, so put it straight to the first item
- we do this so that the debug statements can tell us how long each step took as we look to optimise everything
2021-11-16 14:44:14 +00:00
Naz
9b309cf4e7 Refactored URL cache persistance
refs https://github.com/TryGhost/Toolbox/issues/127

- This refactor is needed to accomodate incoming "resource cache" which shares a lot of common logic with how url cache is operated
2021-11-17 00:00:23 +13:00
Hannah Wolfe
88311381ef Added a URL Service boot log
- At the moment there's no way to see in the logs when the URL Service finally finishes
- This is the moment when Ghost stops serving 503s
- Adding this log line so it's clear to see, which migh be useful whilst were refactorising
2021-11-16 19:13:36 +13:00
Naz
cb652aed3f Added url cache persistance on instance shutdown
refs https://github.com/TryGhost/Toolbox/issues/125

- The in-memory url objects would be persisted in the contents folder allowing to take advantage of the cache during the next instance start
2021-11-13 01:01:28 +13:00
Hannah Wolfe
fdf38ba8c6
Initial card asset service implementation
- Requires the new @tryghost/minifier package
- Adds a new service that will handle taking config from the theme and optionally including assets for Koenig editor cards
- It supports both css and js as cards may need one or both
- For any given config, the tool can find the matching files to include and concat and minify them into one file per type
- Currently has an override in place so that this is not yet customisable in the theme - will remove this override when we're ready for the feature
2021-11-04 11:34:40 +00:00
Fabien O'Carroll
91efa4605c Used DynamicRedirectManager for Custom Redirects
refs https://github.com/TryGhost/Members/commit/9e59f5a9

Since we have a DynamicRedirectManager for handling adding/removing
redirects at runtime, we no longer need the custom-redirects middleware.
The redirects service does however need an init method now to add the
custom redirects at Ghost boot, so it's been refactored into our Class &
DI pattern.
2021-11-03 07:41:55 +13:00
Naz
51b78211c5 Renamed bootstrap to routerManager
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events

- A follow up rename after bootstrap module was transformed into class
2021-10-19 07:29:09 +13:00
Naz
6e075c78bf Moved URL service to backend
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events

- URL module is part of the backend heavily dependent on the model and fits perfectly here. Frontend should get the data it needs by passing a URL manager instance to it
2021-10-19 07:29:09 +13:00
Hannah Wolfe
67821a7bc7
Removed remaining usage of i18n & translation file
refs https://github.com/TryGhost/Ghost/issues/13380

- Now that i18n.t has been removed everywhere, we can cleanup the final usages
- Still TODO: merge the i18n logic into themeI18n, and get rid of shared/i18n entirely
2021-10-15 11:39:07 +01:00
Sam Lord
a535cfdf16 Added metric-shipping to monitor boot-time
no issue
Boot-time metrics are really valuable for understanding how releases affect the performance of Ghost. The new @tryghost/metrics package lets us ship these metrics to different sources using the same configuration framework as @tryghost/logging introduced.
2021-10-12 15:01:50 +01:00
Kevin Ansfield
3fd2e36720 Fixed boot order for themes services
refs c33b596e9c

- initializing the themes service before the custom theme settings service meant that `customThemeSettings.api` was not available when it's called as part of theme initialization
- swapped the boot order around so that the supporting service initialization is performed before the full themes service is initialized
2021-10-11 12:23:34 +01:00
Kevin Ansfield
c33b596e9c
Added API tests for custom theme settings (#13519)
refs https://github.com/TryGhost/Team/issues/1104

- bumped `@tryghost/custom-theme-settings-service` so it throws a more appropriate `ValidationError` when setting keys don't exist or a select value is not known
- changed the custom theme settings service to have a `.init()` method which creates an instance of the service under `.api` so that we're able to create the instance at a particular point in the boot process when we know the models have been initialised
  - there were problems in tests because the service was being initialised through the require chain before models were initialised through the boot process
- fixed incorrect `camelCase` of resource name in API responses
2021-10-08 16:18:49 +01:00
Fabien O'Carroll
6220406716 Added support for Offers with Stripe Checkout
refs https://github.com/TryGhost/Team/issues/1090

This updates the Members & Offers modules to provide support for using
Offers in Stripe Checkout.

Members module now needs a handle to the Offers module repository, and
as such we have had to reorder the services boot order.
2021-10-06 17:24:39 +02:00
Fabien O'Carroll
3742a4afb7 Added Offers service
refs https://github.com/TryGhost/Team/issues/1083

This adds the Offers service which will allow us to build out an Admin
API to communicate with it. As well as wiring up the redirects to the
site app.
2021-10-06 12:33:19 +02:00
Hannah Wolfe
9d7049cd3f
Refactored helper registration code into a service
- The helper registration code is "framework" code and very specific
- At the moment the "theme engine" is full of lots of disparate theme related stuff
- I'm trying to make the frontend framework code clearer and also expand it to  make it more useful
- The helper system now also exposes 3 methods allowing you to register a directory, a helper or an alias
- I've updated the codebase to use these both for our core helpers and for "apps"
2021-10-05 10:04:02 +01:00
Fabien O'Carroll
cda041d424 Moved StripeAPIService to its own service
refs https://github.com/TryGhost/Team/issues/1083

The Offers service is going to need access to the StripeAPIService too,
so we need to move it out of the @tryghost/members-api module and make
it accessible to both.
2021-10-04 19:28:19 +02:00
Hannah Wolfe
025faec7c3
Updated naming in boot post-refactors
- Trying to make the boot make more sense again
- Rough times ahead, but we're making progress towards the frontend being its own thing
2021-10-04 17:12:18 +01:00
Naz
dd042d69c9 Moved routing setting hash calculation to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- These were the last bits that had to be moved out of the frontend doing route.yaml related operations
- Next steps will be refactoring a "bag of everything" into smaller modules and reducing dependencies where possible
2021-09-28 04:59:41 +13:00
Naz
0586a73c6d Exposed async route settings loading method
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- There's no reason for the boot to block the event by loading route settings sychronously
- The only leftover use of a sync loader might also be refactored in some way to avoid blocking the event loo - for example by caching the value on the service layer.
2021-09-28 04:59:41 +13:00
Naz
ba964c549f Moved route settings "getter" to the backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Frontend is not meant to know about the underlying source of the "routes" configuration, so any reads/edits/validations are being moved into a backend service. This should also simplify the coupling of the backend with the frontend where the latter will get a JSON blob with all needed configuration during the boot
- Nother problem the "get" method had was hiding an underlying function it was doing - reading the file from the filesystem SYNCRONOUSLY. It might be a thing we need to do during the "web" app initialization, but there's no clear need to do this in a sync fassion during the bootup for example. Also having a more explicit name should help :)
2021-09-28 04:59:41 +13:00
Naz
31e9434466 Moved route settings initialization to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Actions logic related to file system operations (like ensuring files exist) should be done on the backend. The frontend will be receiving a unified JSON blob config without needing to know about filesystem
2021-09-28 04:59:41 +13:00
Naz
58ba14c188 Removed use of 'routes' parameter for getCurrentHash function
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- With a single possible value for setting ('routes') there's no need to pass the parameter around
2021-09-28 04:59:41 +13:00
Naz
93af11bdec Simplified knowSettings usage
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- 'knowSettings' was based on a "configurable" array of settings that might be configured in Ghost. The multitude never happened! The only setting the frontend takes care of is routes.yaml file (redirects is also kind of a setting but is a separate concept for now).
- Having just one type of file to deal with allows to simplify implementation significantly, which helps before a big refactor
2021-09-28 04:59:41 +13:00
Naz
8bc4d00fe6 Added email unfreeze for verified email config
refs https://github.com/TryGhost/Team/issues/912

- When instance has "verified" email configuration it should remove email freeze and disallow future feezes
2021-07-29 20:30:30 +12:00
Naz
ce1711735f Swapped to American English spellings
refs 16728a3ef1

- Same reason as in refed commit, ltdc:
 - Traditionally all of Ghost's public-facing text was written in British English
 - We're changing that to US English because that's more common
 - US English should also be used in code e.g. properties are called color not colour
2021-07-20 17:27:24 +04:00
Hannah Wolfe
72a1c0b898
Revert "Moved vhost mounts into boot file"
This reverts commit 7e61f73b8c.
2021-07-08 07:10:18 +01:00
Hannah Wolfe
7e61f73b8c
Moved vhost mounts into boot file
- This stops the mounting of the admin and frontend from being buried deep in express initialisation
- Instead it's explicit, which makes two things almost possible:
   1. we can potentially boot the frontend or backend independently
   2. we can pass services and settings loaded during boot into the frontend
- This needs more work, but we can start to group all the frontend code together
- Meanwhile we also need to rip apart the routing and url services to decouple the frontend from the backend fully
- BABY STEPS!
2021-07-07 21:29:14 +01:00
Hannah Wolfe
e7b80e50dc
Refactored bootstrap.init to require route settings
- The router bootstrap is no longer allowed to fetch it's own settings, but rather is passed them
- This moves the call to the site routes.js file, which isn't much better but it's a start
- The goal is to always pass these in from the boot process, or from the bridge reloader
2021-07-07 10:25:45 +01:00
Hannah Wolfe
b1b09efd75
Moved loadAllThemes out of test util
- this was skipped on boot, but then called in the test utilities, but only on restart 🙈
- this means that yarn test:acceptance (i.e. running all tests) works, but if you try to run just test/api-acceptance/themes_spec.js it would fail because that uses a fresh boot not a restart/reload
- I've changed this as keeping the test using the real boot, rather than the made-up acceptance-utils tasks as much as possible is way better
2021-07-06 20:24:48 +01:00
Hannah Wolfe
e410e16a5b
Refactored routing to be passed routes config
- At the moment the bootstrap.start method asks the settings service for its settings
- This couples the routing and settings services together - when maybe we want to use a different method to generate settings
- By passing the settings to the routing service at the right time, we open up possibilities for refactoring
2021-06-30 12:28:33 +01:00
Hannah Wolfe
4ef2ae4436
Revert "Refactored routing to be passed routes config"
This reverts commit 8d754a592e.
2021-06-30 10:52:11 +01:00
Hannah Wolfe
8d754a592e
Refactored routing to be passed routes config
- At the moment the bootstrap.start method asks the settings service for its settings
- This couples the routing and settings services together - when maybe we want to use a different method to generate settings
- By passing the settings to the routing service at the right time, we open up possibilities for refactoring
2021-06-30 09:43:54 +01:00
Hannah Wolfe
d9e8d9c148
Switched to using config-url-utils in boot.js
- config now exposes a few helpful methods: getSubdir, getSiteUrl, and getAdminUrl
- we can use these directly, instead of needing url-utils
- switching this inside of the boot process allows us to move the loading of url-utils into `initCore` which happens after the server has started and the database is ready
- this moves 100ms of loading time to later in the process
- also simplifies the initial loading
2021-06-28 10:50:41 +01:00
Hannah Wolfe
081d3b3a38
Cleaned comments in boot.js
- Cleaned up some of the comments
- Added proper method signatures where appropriate
- Split initDynamicRouting out from initServices, to make that clearer to read
2021-06-28 10:43:56 +01:00
Naz
c328ab781b Fixed broken boot sequence
refs 0d0e09f173
refs https://github.com/TryGhost/Team/issues/754

- As per comment on the top of boot.js:

// IMPORTANT: The only global requires here should be overrides + debug so we can monitor timings with DEBUG=ghost:boot* node ghost

- Referenced change broke the rule above and would have caused all sorts of boot problems.
2021-06-28 10:02:51 +04:00
Naz
0d0e09f173 Moved update check scheduling logic out of boot.js
refs https://github.com/TryGhost/Team/issues/754

- This is a minor cleanup. There should be no logic in the boot.js file other than calling services to "initialize themselves"
2021-06-23 15:01:43 +04:00
Sam Lord
24332c3d24 Replaced ghost-version.js with @tryghost/version
no issue
Part of the effort to break up the Ghost codebase into smaller, decoupled modules.
2021-06-16 13:16:15 +01: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
Sam Lord
caea330647 Change to use @tryghost/logging
no issue

Logging is now controlled by a logginrc.js file in the root of the project - and now we can just import @tryghost/logging everywhere
2021-06-15 15:59:11 +01:00
Thibaut Patel
a17403ab6a Move the update-check service to a scheduled job
issue https://github.com/TryGhost/Team/issues/729
2021-05-27 17:17:26 +02:00
Fabien O'Carroll
b668d6fc9c Added members service init to boot sequence
refs https://github.com/TryGhost/Team/issues/598

This method contains precondition checks for booting Ghost, and should
be called as early as possible.
2021-05-20 12:08:45 +01:00
Naz
1e20f2cb76 🐛 Fixed webhook initialization when over limit
refs https://github.com/TryGhost/Team/issues/599

- Webhook listener was still kicking in when the limit for  "customIntegrations" was in place. This is due to parallel initialization that was done previously and sometimes limit service initialized before webhooks but sometimes it didn't!
- Moving it to be initialized before any othe service ensures the race conditon doesnt happen anymore
2021-05-11 18:11:51 +04:00
Hannah Wolfe
fb974f6650 Moved i18n to correct location in boot process
- Note: added a forced error to show that this was previously happening at the wrong time
- i18n is required by ghost-server to log server start messages, and so gets initialised as part of the ghost-server load
- moving this into the right place means we can see how long it takes in the debug logs
- previously the debug log lines for i18n showed 0/1ms, which is not correct as this contains a sync file load operation!
- we should consider if we want to have i18n be a requirement for ghost server, or if we want static messages
2021-05-05 16:13:26 +01:00
Hannah Wolfe
c999e48c01 Refactored urlUtils out of ghost-server
- We only require a single value from urlUtils, the url for the site
- Move that logic back to the boot file makes it much more explict
- Will help if we want to refactor how urlUtils works, or when we want to move ghost-server out of core
2021-05-05 14:24:59 +01:00
Hannah Wolfe
273e220327 Moved i18n to shared
refs 829e8ed010

- i18n is used everywhere but only requires shared or external packages, therefore it's a good candidate for living in shared
- this reduces invalid requires across frontend and server, and lets us use it everywhere until we come up with a better option
2021-05-04 13:03:38 +01:00