mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
ed6a8dca76
no issue
- following on from f4fb0fcbaa
,
this commit moves around some package requires in Ghost
- these are often niche packages that do something in a subsystem of
Ghost, and are not necessarily be needed to boot the application
- these packages use non-negligible CPU and memory when they are
required, so it makes sense to lazy-require them
- the concern here is that we obscure the code too much by moving
random requires further into code, but the changes are small and the
improvements big
- this commit bring the boot time since 4.19.0 down ~31% and initial
memory usage down by a total of ~12%
24 lines
708 B
JavaScript
24 lines
708 B
JavaScript
const express = require('../../shared/express');
|
|
const settings = require('../../shared/settings-cache');
|
|
|
|
module.exports = function setupWellKnownApp() {
|
|
const wellKnownApp = express('well-known');
|
|
|
|
const jose = require('node-jose');
|
|
const dangerousPrivateKey = settings.get('ghost_private_key');
|
|
const keyStore = jose.JWK.createKeyStore();
|
|
const keyStoreReady = keyStore.add(dangerousPrivateKey, 'pem');
|
|
|
|
const getSafePublicJWKS = async () => {
|
|
await keyStoreReady;
|
|
return keyStore.toJSON();
|
|
};
|
|
|
|
wellKnownApp.get('/jwks.json', async (req, res) => {
|
|
const jwks = await getSafePublicJWKS();
|
|
res.json(jwks);
|
|
});
|
|
|
|
return wellKnownApp;
|
|
};
|