Skip to content

Commit

Permalink
Remove author check
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Oct 25, 2024
1 parent adfb33a commit c6ab5ac
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 75 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/check.yml

This file was deleted.

1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@aws-sdk/client-s3": "^3.645.0",
"@fastify/middie": "^8.3.0",
"@fastify/websocket": "^8.2.0",
"@kakang/fastify-static": "latest",
"commander": "^9.4.1",
"cors": "^2.8.5",
"deepmerge": "^4.2.2",
Expand Down
65 changes: 32 additions & 33 deletions packages/cli/src/plugins/mosaicFastifyPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
import { FastifyInstance } from 'fastify';
import fp from 'fastify-plugin';
import MosaicCore from '@jpmorganchase/mosaic-core';
import { MosaicConfig, IUnionVolume } from '@jpmorganchase/mosaic-types';
import path from 'node:path';

export interface FastifyMosaicPluginOptions {
config: MosaicConfig;
Expand All @@ -24,37 +23,37 @@ async function fastifyMosaic(fastify: FastifyInstance, options: FastifyMosaicPlu
/**
* General content fetch
*/
fastify.get('/*', async (req: FastifyRequest, reply: FastifyReply) => {
try {
if (await fs.promises.exists(req.url)) {
if ((await fs.promises.stat(req.url)).isDirectory()) {
if (await fs.promises.exists(path.join(req.url, 'index'))) {
// Don't do an actual redirect - just send the URL as the response
reply.header('Content-Type', 'application/json');
reply.status(302).send({ redirect: path.posix.join(req.url, 'index') });
} else {
reply.status(404);
}
} else {
const pagePath = String(await fs.promises.realpath(req.url));
if (path.extname(pagePath) === '.mdx') {
reply.header('Content-Type', 'text/mdx');
} else if (path.extname(pagePath) === '.json') {
reply.header('Content-Type', 'application/json');
} else if (path.extname(pagePath) === '.xml') {
reply.header('Content-Type', 'application/xml');
}
const result = await fs.promises.readFile(req.url);
reply.send(result);
}
} else {
reply.status(404);
}
} catch (e) {
console.error(e);
reply.status(500);
}
});
// fastify.get('/*', async (req: FastifyRequest, reply: FastifyReply) => {
// try {
// if (await fs.promises.exists(req.url)) {
// if ((await fs.promises.stat(req.url)).isDirectory()) {
// if (await fs.promises.exists(path.join(req.url, 'index'))) {
// // Don't do an actual redirect - just send the URL as the response
// reply.header('Content-Type', 'application/json');
// reply.status(302).send({ redirect: path.posix.join(req.url, 'index') });
// } else {
// reply.status(404);
// }
// } else {
// const pagePath = String(await fs.promises.realpath(req.url));
// if (path.extname(pagePath) === '.mdx') {
// reply.header('Content-Type', 'text/mdx');
// } else if (path.extname(pagePath) === '.json') {
// reply.header('Content-Type', 'application/json');
// } else if (path.extname(pagePath) === '.xml') {
// reply.header('Content-Type', 'application/xml');
// }
// const result = await fs.promises.readFile(req.url);
// reply.send(result);
// }
// } else {
// reply.status(404);
// }
// } catch (e) {
// console.error(e);
// reply.status(500);
// }
// });
}

// Most importantly, use declaration merging to add the custom property to the Fastify type system
Expand Down
22 changes: 22 additions & 0 deletions packages/cli/src/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Fastify from 'fastify';
import cors from 'cors';
import { MosaicConfig } from '@jpmorganchase/mosaic-types';
import middie from '@fastify/middie';
import { FastifyStatic, FileSystemEngine } from '@kakang/fastify-static';
import { send } from '@kakang/abstract-send';

import fastifyMosaic from './plugins/mosaicFastifyPlugin.js';
import fastifyMosaicAdmin from './plugins/mosaicAdminPlugin.js';
Expand All @@ -15,6 +17,19 @@ export const server = Fastify({
pluginTimeout: 20000
});

class MosaicEngine extends FileSystemEngine {
declare mosaic: any;

constructor(mosaic: any) {
super();
this.mosaic = mosaic;
}

async download(message, path, options): FileSystemEngine['download'] {
return send(message, path, { ...options, engine: this.mosaic.filesystem });
}
}

export default async function serve(config: MosaicConfig, port: number, scope?: string[]) {
const mosaic = await createMosaicInstance(config);
await server.register(middie);
Expand All @@ -24,6 +39,13 @@ export default async function serve(config: MosaicConfig, port: number, scope?:
prefix: MOSAIC_ADMIN_PREFIX,
enableSourcePush: config.enableSourcePush
});
config.sources;

await server.register(FastifyStatic, {
serve: '/',
root: '/',
engine: new MosaicEngine(mosaic)
});

server.use(cors());

Expand Down
2 changes: 1 addition & 1 deletion packages/site/public/search-data.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/site/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/plugins/document-assets-plugin</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/plugins/index</loc>
<changefreq>weekly</changefreq>
Expand Down
106 changes: 76 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,26 @@
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"
integrity sha1-nfA7vXxpalxYiFw0qgbaQchUN5Y=

"@kakang/abstract-send@^0.0.6":
version "0.0.6"
resolved "https://registry.yarnpkg.com/@kakang/abstract-send/-/abstract-send-0.0.6.tgz#aaab5a4956130476d5ed0ee83edb0fb72945ee75"
integrity sha512-Q9lDWV2zgFMp+dmkur27LVp8NIh2ZiZW/pF++rMwGXhR0LMycmWT6vWPyagZyXdbM5N3sxHRTNZw3vPmuPjGug==
dependencies:
"@lukeed/ms" "^2.0.2"
escape-html "^1.0.3"
fast-decode-uri-component "^1.0.1"
http-errors "^2.0.0"
mime "^4.0.4"

"@kakang/fastify-static@latest":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@kakang/fastify-static/-/fastify-static-1.1.1.tgz#7132b304216d76a632e212379419f547787c7d13"
integrity sha512-E3wkiNHYDVfmYklKoE6JaBiWvds0L1/pEOIjTueRZMwxSYuT5q12AaD8Q2hOCqC5Vx6QM+7ISz+yutWJO6C/ug==
dependencies:
"@kakang/abstract-send" "^0.0.6"
"@types/fast-decode-uri-component" "^1.0.0"
fastify-plugin "^5.0.1"

"@lexical/[email protected]":
version "0.17.1"
resolved "https://registry.yarnpkg.com/@lexical/clipboard/-/clipboard-0.17.1.tgz#816b2559e60c5cfb5df5c6a4d1d1dcd850662d14"
Expand Down Expand Up @@ -2006,6 +2026,11 @@
"@lexical/offset" "0.17.1"
lexical "0.17.1"

"@lukeed/ms@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@lukeed/ms/-/ms-2.0.2.tgz#07f09e59a74c52f4d88c6db5c1054e819538e2a8"
integrity sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==

"@manypkg/find-root@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@manypkg/find-root/-/find-root-1.1.0.tgz#a62d8ed1cd7e7d4c11d9d52a8397460b5d4ad29f"
Expand Down Expand Up @@ -3350,6 +3375,11 @@
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==

"@types/fast-decode-uri-component@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/fast-decode-uri-component/-/fast-decode-uri-component-1.0.0.tgz#e5534f041f39495b77f83b774461e2bac26e4c91"
integrity sha512-xhTFpMookjiVEDxI8RBUOxZL8BQiI2+YZZoqzW/G6s3r1h60gDzGnmKP83LNuTmCqk8ZmbY5cYkByKu4t+rKhA==

"@types/fs-extra@^9.0.13":
version "9.0.13"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
Expand Down Expand Up @@ -5641,6 +5671,11 @@ delayed-stream@~1.0.0:
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==

dequal@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.2.tgz#85ca22025e3a87e65ef75a7a437b35284a7e319d"
Expand Down Expand Up @@ -6187,6 +6222,11 @@ escalade@^3.1.2:
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5"
integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==

escape-html@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==

[email protected], escape-string-regexp@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8"
Expand Down Expand Up @@ -6811,6 +6851,11 @@ fastify-plugin@^4.0.0, fastify-plugin@^4.5.1:
resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-4.5.1.tgz#44dc6a3cc2cce0988bc09e13f160120bbd91dbee"
integrity sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==

fastify-plugin@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-5.0.1.tgz#82d44e6fe34d1420bb5a4f7bee434d501e41939f"
integrity sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==

fastify@^4.23.2:
version "4.23.2"
resolved "https://registry.yarnpkg.com/fastify/-/fastify-4.23.2.tgz#7072f04b544540d2523afb4a54d4095d187f5444"
Expand Down Expand Up @@ -7586,6 +7631,17 @@ http-cache-semantics@^4.1.1:
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a"
integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==

http-errors@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3"
integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==
dependencies:
depd "2.0.0"
inherits "2.0.4"
setprototypeof "1.2.0"
statuses "2.0.1"
toidentifier "1.0.1"

http-proxy-agent@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e"
Expand Down Expand Up @@ -7715,7 +7771,7 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4:
inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=
Expand Down Expand Up @@ -9509,6 +9565,11 @@ mime-types@^2.1.12:
dependencies:
mime-db "1.52.0"

mime@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.4.tgz#9f851b0fc3c289d063b20a7a8055b3014b25664b"
integrity sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==

mimic-fn@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
Expand Down Expand Up @@ -11676,6 +11737,11 @@ set-function-name@^2.0.1, set-function-name@^2.0.2:
functions-have-names "^1.2.3"
has-property-descriptors "^1.0.2"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424"
integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==

sha.js@^2.4.11:
version "2.4.11"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7"
Expand Down Expand Up @@ -11956,7 +12022,7 @@ stampit@^4.3.2:
resolved "https://registry.yarnpkg.com/stampit/-/stampit-4.3.2.tgz#cfd3f607dd628a161ce6305621597994b4d56573"
integrity sha512-pE2org1+ZWQBnIxRPrBM2gVupkuDD0TTNIo1H6GdT/vO82NXli2z8lRE8cu/nBIHrcOCXFBAHpb9ZldrB2/qOA==

statuses@^2.0.1:
statuses@2.0.1, statuses@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"
integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==
Expand Down Expand Up @@ -11988,7 +12054,7 @@ string-argv@^0.3.1:
resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -11997,15 +12063,6 @@ string-argv@^0.3.1:
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha1-JpxxF9J7Ba0uU2gwqOyJXvnG0BA=
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.0, string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -12133,20 +12190,13 @@ stringify-entities@^4.0.0:
character-entities-html4 "^2.0.0"
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha1-nibGPTD1NEPpSJSVshBdN7Z6hdk=
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
Expand Down Expand Up @@ -12510,6 +12560,11 @@ toggle-selection@^1.0.6:
resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35"
integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==

toposort@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330"
Expand Down Expand Up @@ -13419,7 +13474,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -13437,15 +13492,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha1-Z+FFz/UQpqaYS98RUpEdadLrnkM=
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit c6ab5ac

Please sign in to comment.