0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
Commit graph

37851 commits

Author SHA1 Message Date
Fabien "egg" O'Carroll
8601f68347 Refactor sentry handling into base class 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
a4345afb82 Initial refactor for base repository 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
b65b4cb057 Refactored entity -> row mapping 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
0431ab64e0 Formatting 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
c37d6bf2eb Refactored getAll & getSome shared code 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
3c2939c8a9 Refactored row -> entity mapping 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
323e102def Switched to knex repository 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
12e192cdae Added knex to NestJS DI Container 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
6f9ae37706 Added initial knex repository 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
f8f58c9dd8 Installed deps for knex repository 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
166a29b1ed Updated in memory repository 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
af21a1104a Added generic repository, and updated SnippetRepository to use it 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
d6ac611550 Updated pagination type 2024-01-22 11:11:33 +07:00
Naz
b457eb57b0 Added real pagination to GET /snippets endpoint
refs https://github.com/TryGhost/Arch/issues/99

- This is a naive implementation mostly based on existing bookshelf approach. It's up for discussion if doing aggregation inside of the browse method is a right call or this data should be separated into a different method
- To reiterate, the aim for initial spike is to make the cod work using nest and figure out better patterns iteratively while it's fresh.
2024-01-22 11:11:33 +07:00
Naz
b116262083 Fixed source map generation in ghost/ghost project
- It was not enabled by default and caused problems when debugging
2024-01-22 11:11:33 +07:00
Naz
12ad019447 Added 100% test coverage to controller and dto
refs https://github.com/TryGhost/Arch/issues/99

- We aim to keep test coverage close to 100% on all new code. This change adds full coverage to controller layer code
2024-01-22 11:11:33 +07:00
Naz
e6865ee6f0 Removed dead test 2024-01-22 11:11:33 +07:00
Naz
200aaacf42 Removed timezone-related code
refs https://github.com/TryGhost/Arch/issues/99

- The timezone formatting was dropped from the migrated implementation because we do not do the formatting in the legacy API  (incorrectly imo). We only do the timezone formatting on Posts API endpoints.
- Adding formatting for migrated Snippets API would mean a breaking change, which we don't want to make just yet
2024-01-22 11:11:33 +07:00
Naz
df82ab0e5f Removed unnecessary date formatting
refs https://github.com/TryGhost/Arch/issues/99

- Only posts resources ever have the dates formatted in the legacy API. There's no need to implement this formatting in Snippets API at the moment
2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
ce5cfb742f [WIP] Initial timezone interceptor 2024-01-22 11:11:33 +07:00
Fabien "egg" O'Carroll
058d95bdc2 Fixed controller tests 2024-01-22 11:11:33 +07:00
Naz
803f8ee3f1 Added snippet controller implementation to pass e2e tests
refs https://github.com/TryGhost/Arch/issues/99

- This is a very crude implementation that showcases moving pieces that are needed to make Snippets API work with NestJS
- The snippets api e2e test suite enables the `nestSnippetsAPI` flag to allow testing nest implementation of the GET /snippets endpoint
2024-01-22 11:11:33 +07:00
Naz
8eb9ba9616 Added bookshelf snippets repository implementation
refs https://github.com/TryGhost/Arch/issues/99

- The Snippets repository allows to fetch Snippet entity data through the legacy bookshelf models. The bookshelf should be substituted with knex wherever possible, once we have reached the feature parity and stability with the legacy Snippets API.
2024-01-22 11:11:33 +07:00
Naz
486aab2e01 Added settings cache injection to SnippetsController
refs https://github.com/TryGhost/Arch/issues/99

- The "timezone" value will be needed to format the dates  in the Snippet response according to out API rules
2024-01-22 11:11:33 +07:00
Naz
cbb6a7cae2 Injected settings-cache into Nest app
refs https://github.com/TryGhost/Arch/issues/99

- Nest app needs access to settings (timezone for now)
2024-01-22 11:11:33 +07:00
Naz
cd2175f99f Have put the GET /snippets endpoint behind feature flag
refs https://github.com/TryGhost/Arch/issues/100

- Because of the way how new NestJS code is integrated into existing Ghost I've introduced a way to "skip" rather than "block" access to certain API endpoints when the labs flag is enabled.
- This change skips the `GET /snippets` legacy Admin API route and falls through to the NestJS route
2024-01-22 11:11:33 +07:00
Naz
c45b28edc1 Added an alpha flag for Nest migration
refs https://github.com/TryGhost/Arch/issues/100

- Added a `nestSnippetsAPI` flag to control the rollout of the Snippets API migration to NestJS and new architecture
2024-01-22 11:11:31 +07:00
Fabien "egg" O'Carroll
1b39abdcb4 Fixed types 2024-01-22 11:10:35 +07:00
Naz
b6dae2c383 Fixed breaking build after entity renames 2024-01-22 11:10:35 +07:00
Fabien "egg" O'Carroll
76cc218928 Started on base Entity class 2024-01-22 11:10:35 +07:00
Naz
71495ed22f Added minimal repository structure for Snippets
refs https://github.com/TryGhost/Arch/issues/99

- Adds connection between snippets in NestJS application to the models in the legacy Ghost codebase to link snippets to real data
- The NestJS controller code can be executed by commenting out `router.get('/snippets', mw.authAdminApi, http(api.snippets.browse));` in the ghost core Admin API routes file
2024-01-22 11:10:35 +07:00
Naz
7e152e638f Basic controller/service setup for Snippets API
refs https://github.com/TryGhost/Arch/issues/99

- This is scaffolding for the Snippets API controller
- The change includes a basic controller, service and a test to get the ball rolling
2024-01-22 11:10:33 +07:00
Naz
8778ba9f8d Added ESlint ignore rule to allow dotted filenames
- In the Nest code we are writing an example of the ideal code. The ESlint rules will adjust to how code is written in this project eventually once we experiment with things enough.
- Examples of new naming convention are based on  `.` separator e.g.:
- The middle words represent use cases, could later become pods e.g. posts.controller.js, posts.repository.js, posts.dto.js, posts.service.js, posts.scheduling.service.js, stripe.provider.js, stripe.webhook.listener.js.
2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
529990cadf Fixed order of routes 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
671346dc15 [WIP] Adding Snippet stuff 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
7ec8154331 Add models to DI container 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
0fe557f35f Setup initial DI 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
da17bd725e FIXME Updating global tsconfig to get rid of decorator errors in vscode 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
09d8c0eed7 Wired up bare bones nest app 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
581ba93cee Added bare bones nest app 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
4f1bf4137d Enabled decorator metadata 2024-01-22 11:09:46 +07:00
Fabien "egg" O'Carroll
3013cee91c install nest deps 2024-01-22 11:09:44 +07:00
Fabien "egg" O'Carroll
8706adf509 slimer new ghost 2024-01-22 11:07:30 +07:00
Fabien "egg" O'Carroll
f34999a51f Implemented Refresh-Ahead caching for Redis
This updates the AdapterCacheRedis instance to be able to handle updating
itself when reading from the cache. For this to work we need to pass a
`fetchData` function to the `get` method.

In the case of a cache miss, we will read the data via the `fetchData`
function, and store it in the cache, before returning the value to the caller.

When coupled with a `refreshAheadFactor` config, we will go a step further and
implement the "Refresh Ahead" caching strategy. What this means is that we will
refresh the contents of the cache in the background, this happens on a cache
read and only once the data in the cache has only a certain percentage of the
TTL left, which is set as a decimal value between 0 and 1.

e.g.

ttl = 100s
refreshAheadFactor = 0.2;

Any read from the cache that happens _after_ 80s will do a background refresh
2024-01-18 20:16:36 +07:00
Fabien "egg" O'Carroll
ef999c4fd4 Refactored the pipeline execution to async fn
Having the code use `async/await` make it more readable, and extracting the
execution to a separate function make its easier to run in the background in the
future
2024-01-18 20:16:36 +07:00
Fabien "egg" O'Carroll
c60dd779c9 Removed usage of EventAwareCacheAdapter
This logic is so simple it isn't worth having the indirection of another class.

This also removes the indirection of wrapped getters/setters, which is useful
because otherwise we need to update the wrapper with new methods each time
theunderlying implementation is changed. There was a note about losing the
context of this, but I haven't found anywhere that the context is lost.
2024-01-18 20:16:36 +07:00
Ronald Langeveld
c7d7b883cc
🎨 Added Offers to the new Settings (#19493)
no issue

- Removes flags for the new Offers in Admin X (Settings)
- Removes old Offers from the sidebar.
- See a new version of Offers in Settings. 🎨
2024-01-18 12:56:08 +00:00
Ronald Langeveld
14bf2df834
Made offers iframe init load async (#19516)
no issue

- ensures it waits for event data to load before rendering the iframe
which sometimes causes an undesired flashing experience.
2024-01-18 12:38:41 +00:00
Ronald Langeveld
66238c7ccf
Added default string to href to Offers Portal iFrame (#19514)
no issue

- potentially fixes a small performance issues to avoid the homepage of
your publication from being loaded should an href from Portal not exist
when loading Offers, that could cause flashing.
2024-01-18 09:42:46 +00:00
Sam Lord
167a442ffe Free ubuntu-latest machines now also have 4 cores
refs: https://github.blog/2024-01-17-github-hosted-runners-double-the-power-for-open-source/

This should still allow us to run tests in 8~ minutes without paying for the VM time
2024-01-18 09:35:30 +00:00