intlayer-editor 7.5.8 → 7.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{CodeBlockShiki-DOHz3hxi.js → CodeBlockShiki-DpCGruCb.js} +3 -3
- package/client/dist/assets/{bundle-web-BeYtMvYb.js → bundle-web-B0b7KTfP.js} +1 -1
- package/client/dist/assets/{index-BfDGXG1A.js → index-ChXpK4Au.js} +568 -490
- package/client/dist/assets/{index-ROdmYOAM.css → index-DxwJ6VyR.css} +123 -4
- package/client/dist/index.html +2 -2
- package/package.json +19 -21
- package/server/dist/controllers/configuration.controller.cjs +3 -5
- package/server/dist/controllers/configuration.controller.cjs.map +1 -1
- package/server/dist/controllers/configuration.controller.d.ts +2 -2
- package/server/dist/controllers/configuration.controller.mjs +3 -5
- package/server/dist/controllers/configuration.controller.mjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.cjs +13 -17
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.d.ts +6 -5
- package/server/dist/controllers/dictionary.controller.mjs +7 -11
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
- package/server/dist/index.cjs +45 -30
- package/server/dist/index.cjs.map +1 -1
- package/server/dist/index.mjs +38 -25
- package/server/dist/index.mjs.map +1 -1
- package/server/dist/routes/config.routes.cjs +3 -3
- package/server/dist/routes/config.routes.cjs.map +1 -1
- package/server/dist/routes/config.routes.d.ts +2 -2
- package/server/dist/routes/config.routes.mjs +3 -3
- package/server/dist/routes/config.routes.mjs.map +1 -1
- package/server/dist/routes/dictionary.routes.cjs +4 -4
- package/server/dist/routes/dictionary.routes.cjs.map +1 -1
- package/server/dist/routes/dictionary.routes.d.ts +2 -2
- package/server/dist/routes/dictionary.routes.mjs +4 -4
- package/server/dist/routes/dictionary.routes.mjs.map +1 -1
|
@@ -2,17 +2,16 @@ import { formatResponse } from "../utils/responseData.mjs";
|
|
|
2
2
|
import { getConfiguration } from "@intlayer/config";
|
|
3
3
|
import { writeContentDeclaration as writeContentDeclaration$1 } from "@intlayer/chokidar";
|
|
4
4
|
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
5
|
-
import { t } from "
|
|
5
|
+
import { t } from "fastify-intlayer";
|
|
6
6
|
|
|
7
7
|
//#region src/controllers/dictionary.controller.ts
|
|
8
8
|
/**
|
|
9
9
|
* Get the Intlayer configuration
|
|
10
10
|
*/
|
|
11
|
-
const getDictionaries = async (_req, res
|
|
11
|
+
const getDictionaries = async (_req, res) => {
|
|
12
12
|
try {
|
|
13
13
|
const formattedResponse = formatResponse({ data: getUnmergedDictionaries() });
|
|
14
|
-
res.
|
|
15
|
-
return;
|
|
14
|
+
return res.send(formattedResponse);
|
|
16
15
|
} catch (err) {
|
|
17
16
|
const errorMessage = err ?? {
|
|
18
17
|
message: "Internal Server Error",
|
|
@@ -26,14 +25,13 @@ const getDictionaries = async (_req, res, _next) => {
|
|
|
26
25
|
},
|
|
27
26
|
status: errorMessage.status ?? 500
|
|
28
27
|
});
|
|
29
|
-
res.
|
|
30
|
-
return;
|
|
28
|
+
return res.send(formattedErrorResponse);
|
|
31
29
|
}
|
|
32
30
|
};
|
|
33
31
|
/**
|
|
34
32
|
* Adds a new dictionary to the database.
|
|
35
33
|
*/
|
|
36
|
-
const writeContentDeclaration = async (req, res
|
|
34
|
+
const writeContentDeclaration = async (req, res) => {
|
|
37
35
|
try {
|
|
38
36
|
const dictionaryData = req.body.dictionary;
|
|
39
37
|
const result = await writeContentDeclaration$1(dictionaryData, getConfiguration());
|
|
@@ -84,8 +82,7 @@ const writeContentDeclaration = async (req, res, _next) => {
|
|
|
84
82
|
}),
|
|
85
83
|
description
|
|
86
84
|
});
|
|
87
|
-
res.
|
|
88
|
-
return;
|
|
85
|
+
return res.send(formattedResponse);
|
|
89
86
|
} catch (err) {
|
|
90
87
|
const errorMessage = err ?? {
|
|
91
88
|
message: "Internal Server Error",
|
|
@@ -100,8 +97,7 @@ const writeContentDeclaration = async (req, res, _next) => {
|
|
|
100
97
|
},
|
|
101
98
|
status: errorMessage.status ?? 500
|
|
102
99
|
});
|
|
103
|
-
res.
|
|
104
|
-
return;
|
|
100
|
+
return res.send(formattedErrorResponse);
|
|
105
101
|
}
|
|
106
102
|
};
|
|
107
103
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type {
|
|
1
|
+
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { t } from 'fastify-intlayer';\n\ntype GetDictionariesResult = ResponseData<UnmergedDictionaries>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getDictionaries = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const formattedResponse = formatResponse<UnmergedDictionaries>({\n data: getUnmergedDictionaries(),\n });\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n const formattedErrorResponse = formatResponse<UnmergedDictionaries>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n\nexport type WriteContentDeclarationBody = { dictionary: Dictionary };\ntype WriteContentDeclarationResultData = {\n status: DictionaryStatus;\n path: string;\n};\nexport type WriteContentDeclarationResult =\n ResponseData<WriteContentDeclarationResultData>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const writeContentDeclaration = async (\n req: FastifyRequest<{ Body: WriteContentDeclarationBody }>,\n res: FastifyReply\n): Promise<void> => {\n try {\n const dictionaryData = req.body.dictionary;\n\n const config = getConfiguration();\n\n const result = await writeContentDeclarationEditor(dictionaryData, config);\n\n let description = '';\n\n switch (result.status) {\n case 'created': {\n description = t({\n en: 'Content declaration created successfully',\n fr: 'Déclaration de contenu créée avec succès',\n es: 'Declaración de contenido creada con éxito',\n });\n break;\n }\n\n case 'updated': {\n description = t({\n en: 'Content declaration updated successfully',\n fr: 'Déclaration de contenu mise à jour avec succès',\n es: 'Declaración de contenido actualizada con éxito',\n });\n break;\n }\n case 'reimported in JSON': {\n description = t({\n en: 'Content declaration reimported in JSON successfully',\n fr: 'Déclaration de contenu réimportée en JSON avec succès',\n es: 'Declaración de contenido reimportada en JSON con éxito',\n });\n break;\n }\n case 'new content file': {\n description = t({\n en: 'Content declaration new content file successfully',\n fr: 'Déclaration de contenu réimportée dans un nouveau emplacement avec succès',\n es: 'Declaración de contenido reimportada en un nuevo lugar con éxito',\n });\n break;\n }\n default: {\n description = t({\n en: 'Content declaration written successfully',\n fr: 'Déclaration de contenu écrite avec succès',\n es: 'Declaración de contenido escrita con éxito',\n });\n break;\n }\n }\n\n const formattedResponse = formatResponse<WriteContentDeclarationResultData>(\n {\n data: result,\n message: t({\n en: 'Content declaration written',\n fr: 'Déclaration de contenu écrite',\n es: 'Declaración de contenido escrita',\n }),\n description,\n }\n );\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n console.error(errorMessage);\n\n const formattedErrorResponse =\n formatResponse<WriteContentDeclarationResultData>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,kBAAkB,OAC7B,MACA,QACkB;AAClB,KAAI;EACF,MAAM,oBAAoB,eAAqC,EAC7D,MAAM,yBAAyB,EAChC,CAAC;AAEF,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;EAED,MAAM,yBAAyB,eAAqC;GAClE,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEF,SAAO,IAAI,KAAK,uBAAuB;;;;;;AAe3C,MAAa,0BAA0B,OACrC,KACA,QACkB;AAClB,KAAI;EACF,MAAM,iBAAiB,IAAI,KAAK;EAIhC,MAAM,SAAS,MAAMA,0BAA8B,gBAFpC,kBAAkB,CAEyC;EAE1E,IAAI,cAAc;AAElB,UAAQ,OAAO,QAAf;GACE,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAGF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF;AACE,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;;EAIJ,MAAM,oBAAoB,eACxB;GACE,MAAM;GACN,SAAS,EAAE;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;IACL,CAAC;GACF;GACD,CACF;AAED,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;AAED,UAAQ,MAAM,aAAa;EAE3B,MAAM,yBACJ,eAAkD;GAChD,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEJ,SAAO,IAAI,KAAK,uBAAuB"}
|
package/server/dist/index.cjs
CHANGED
|
@@ -3,20 +3,24 @@ const require_routes_config_routes = require('./routes/config.routes.cjs');
|
|
|
3
3
|
const require_routes_dictionary_routes = require('./routes/dictionary.routes.cjs');
|
|
4
4
|
const require_utils_checkPortAvailability = require('./utils/checkPortAvailability.cjs');
|
|
5
5
|
let _intlayer_config = require("@intlayer/config");
|
|
6
|
-
let
|
|
6
|
+
let fastify_intlayer = require("fastify-intlayer");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
let node_url = require("node:url");
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
|
|
10
|
+
let _fastify_compress = require("@fastify/compress");
|
|
11
|
+
_fastify_compress = require_rolldown_runtime.__toESM(_fastify_compress);
|
|
12
|
+
let _fastify_cookie = require("@fastify/cookie");
|
|
13
|
+
_fastify_cookie = require_rolldown_runtime.__toESM(_fastify_cookie);
|
|
14
|
+
let _fastify_cors = require("@fastify/cors");
|
|
15
|
+
_fastify_cors = require_rolldown_runtime.__toESM(_fastify_cors);
|
|
16
|
+
let _fastify_formbody = require("@fastify/formbody");
|
|
17
|
+
_fastify_formbody = require_rolldown_runtime.__toESM(_fastify_formbody);
|
|
18
|
+
let _fastify_helmet = require("@fastify/helmet");
|
|
19
|
+
_fastify_helmet = require_rolldown_runtime.__toESM(_fastify_helmet);
|
|
20
|
+
let _fastify_static = require("@fastify/static");
|
|
21
|
+
_fastify_static = require_rolldown_runtime.__toESM(_fastify_static);
|
|
22
|
+
let fastify = require("fastify");
|
|
23
|
+
fastify = require_rolldown_runtime.__toESM(fastify);
|
|
20
24
|
let mime = require("mime");
|
|
21
25
|
mime = require_rolldown_runtime.__toESM(mime);
|
|
22
26
|
|
|
@@ -27,8 +31,8 @@ const envFileOptions = {
|
|
|
27
31
|
envFile: process.env.ENV_FILE
|
|
28
32
|
};
|
|
29
33
|
const packageJson = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(__dirname$1, "../../package.json"), "utf8"));
|
|
30
|
-
const app = (0,
|
|
31
|
-
app.
|
|
34
|
+
const app = (0, fastify.default)({ disableRequestLogging: true });
|
|
35
|
+
app.register(fastify_intlayer.intlayer);
|
|
32
36
|
const FALLBACK_PORT = 8e3;
|
|
33
37
|
const config = (0, _intlayer_config.getConfiguration)(envFileOptions);
|
|
34
38
|
const port = config.editor.port ?? FALLBACK_PORT;
|
|
@@ -42,25 +46,33 @@ const startServer = async (app$1) => {
|
|
|
42
46
|
console.error(`\x1b[1;31mError: Port ${port} is already in use.\x1b[0m`);
|
|
43
47
|
process.exit(255);
|
|
44
48
|
}
|
|
45
|
-
app$1.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
app$1.
|
|
50
|
-
app$1.
|
|
51
|
-
app$1.
|
|
52
|
-
app$1.
|
|
53
|
-
app$1.
|
|
54
|
-
app$1.
|
|
55
|
-
app$1.
|
|
56
|
-
|
|
49
|
+
await app$1.register(_fastify_helmet.default, {
|
|
50
|
+
contentSecurityPolicy: false,
|
|
51
|
+
global: true
|
|
52
|
+
});
|
|
53
|
+
await app$1.register(_fastify_cors.default, corsOptions);
|
|
54
|
+
await app$1.register(_fastify_compress.default);
|
|
55
|
+
await app$1.register(_fastify_cookie.default);
|
|
56
|
+
await app$1.register(_fastify_formbody.default);
|
|
57
|
+
await app$1.register(require_routes_dictionary_routes.dictionaryRouter, { prefix: "/api/dictionary" });
|
|
58
|
+
await app$1.register(require_routes_config_routes.configurationRouter, { prefix: "/api/config" });
|
|
59
|
+
await app$1.register(_fastify_static.default, {
|
|
60
|
+
root: clientDistPath,
|
|
61
|
+
wildcard: false
|
|
62
|
+
});
|
|
63
|
+
app$1.setNotFoundHandler((req, reply) => {
|
|
64
|
+
const requestedPath = (0, node_path.join)(clientDistPath, req.raw.url || "/");
|
|
57
65
|
if ((0, node_fs.existsSync)(requestedPath) && (0, node_fs.lstatSync)(requestedPath).isFile()) {
|
|
58
66
|
const mimeType = mime.default.getType(requestedPath) ?? "application/octet-stream";
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} else
|
|
67
|
+
reply.header("Content-Type", mimeType);
|
|
68
|
+
return reply.sendFile(req.raw.url?.split("/").pop() || "index.html");
|
|
69
|
+
} else return reply.sendFile("index.html");
|
|
62
70
|
});
|
|
63
|
-
|
|
71
|
+
try {
|
|
72
|
+
await app$1.listen({
|
|
73
|
+
port,
|
|
74
|
+
host: "0.0.0.0"
|
|
75
|
+
});
|
|
64
76
|
const dotEnvFilePath = (0, _intlayer_config.getEnvFilePath)(envFileOptions.env, envFileOptions.envFile);
|
|
65
77
|
console.log(`
|
|
66
78
|
${(0, _intlayer_config.colorize)((0, _intlayer_config.colorize)("INTLAYER", _intlayer_config.ANSIColors.BOLD), _intlayer_config.ANSIColors.GREY_DARK)} ${(0, _intlayer_config.colorize)(`v${packageJson.version}`, _intlayer_config.ANSIColors.GREY_DARK)}
|
|
@@ -70,7 +82,10 @@ const startServer = async (app$1) => {
|
|
|
70
82
|
${(0, _intlayer_config.colorize)("➜", _intlayer_config.ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? "-"}
|
|
71
83
|
${(0, _intlayer_config.colorize)("➜", _intlayer_config.ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? "-"}
|
|
72
84
|
`);
|
|
73
|
-
})
|
|
85
|
+
} catch (err) {
|
|
86
|
+
app$1.log.error(err);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
74
89
|
};
|
|
75
90
|
startServer(app);
|
|
76
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__dirname","app:
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__dirname","app: FastifyInstance","intlayer","corsOptions: FastifyCorsOptions","checkPortAvailability","app","fastifyHelmet","fastifyCors","fastifyCompress","fastifyCookie","fastifyFormbody","dictionaryRouter","configurationRouter","fastifyStatic","ANSIColors"],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync, lstatSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport fastifyCompress from '@fastify/compress';\nimport fastifyCookie from '@fastify/cookie';\nimport fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';\nimport fastifyFormbody from '@fastify/formbody';\nimport fastifyHelmet from '@fastify/helmet';\nimport fastifyStatic from '@fastify/static';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getConfiguration,\n getEnvFilePath,\n} from '@intlayer/config';\nimport { configurationRouter } from '@routes/config.routes';\nimport { dictionaryRouter } from '@routes/dictionary.routes';\nimport { checkPortAvailability } from '@utils/checkPortAvailability';\nimport Fastify, { type FastifyInstance } from 'fastify';\nimport { intlayer } from 'fastify-intlayer';\nimport mime from 'mime';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst envFileOptions = {\n env: process.env.NODE_ENV,\n envFile: process.env.ENV_FILE,\n};\n\n// Load package.json\nconst packageJson = JSON.parse(\n readFileSync(resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nconst app: FastifyInstance = Fastify({\n disableRequestLogging: true, // Optional: Keep logs clean like the original\n});\n\n// Load internationalization plugin\n// Assuming fastify-intlayer is the Fastify equivalent of express-intlayer\napp.register(intlayer);\n\nconst FALLBACK_PORT = 8000;\nconst config = getConfiguration(envFileOptions);\nconst port = config.editor.port ?? FALLBACK_PORT;\n\nconst clientDistPath = resolve(__dirname, '../../client/dist');\n\nconst corsOptions: FastifyCorsOptions = {\n origin: '*',\n credentials: true,\n};\n\nconst startServer = async (app: FastifyInstance) => {\n const isPortAvailable = await checkPortAvailability(port);\n\n if (!isPortAvailable) {\n console.error(`\\x1b[1;31mError: Port ${port} is already in use.\\x1b[0m`);\n process.exit(255);\n }\n\n // Security Headers\n await app.register(fastifyHelmet, {\n contentSecurityPolicy: false,\n global: true,\n });\n\n // CORS\n await app.register(fastifyCors, corsOptions);\n\n // Compression\n await app.register(fastifyCompress);\n\n // Cookie Parser\n await app.register(fastifyCookie);\n\n // Parse application/x-www-form-urlencoded\n await app.register(fastifyFormbody);\n\n // Register Routes\n await app.register(dictionaryRouter, { prefix: '/api/dictionary' });\n await app.register(configurationRouter, { prefix: '/api/config' });\n\n // Serve Static Files\n await app.register(fastifyStatic, {\n root: clientDistPath,\n wildcard: false, // We handle the fallback manually to match SPA logic\n });\n\n // For single-page applications, redirect all unmatched routes to index.html\n app.setNotFoundHandler((req, reply) => {\n const requestedPath = join(clientDistPath, req.raw.url || '/');\n\n if (existsSync(requestedPath) && lstatSync(requestedPath).isFile()) {\n const mimeType =\n mime.getType(requestedPath) ?? 'application/octet-stream';\n reply.header('Content-Type', mimeType);\n return reply.sendFile(req.raw.url?.split('/').pop() || 'index.html');\n } else {\n return reply.sendFile('index.html');\n }\n });\n\n try {\n await app.listen({ port, host: '0.0.0.0' });\n\n const dotEnvFilePath = getEnvFilePath(\n envFileOptions.env,\n envFileOptions.envFile\n );\n\n console.log(`\n ${colorize(colorize('INTLAYER', ANSIColors.BOLD), ANSIColors.GREY_DARK)} ${colorize(`v${packageJson.version}`, ANSIColors.GREY_DARK)}\n\n Editor running at: ${colorizePath(`http://localhost:${port}`)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Watching application at: ${config.editor.applicationURL === '' ? '-' : colorizePath(config.editor.applicationURL)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? '-'}\n ${colorize('➜', ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? '-'}\n `);\n } catch (err) {\n app.log.error(err);\n process.exit(1);\n }\n};\n\n// Start it up!\nstartServer(app);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAMA,+GAAkD,CAAC;AAEzD,MAAM,iBAAiB;CACrB,KAAK,QAAQ,IAAI;CACjB,SAAS,QAAQ,IAAI;CACtB;AAGD,MAAM,cAAc,KAAK,uDACFA,aAAW,qBAAqB,EAAE,OAAO,CAC/D;AAED,MAAMC,2BAA+B,EACnC,uBAAuB,MACxB,CAAC;AAIF,IAAI,SAASC,0BAAS;AAEtB,MAAM,gBAAgB;AACtB,MAAM,gDAA0B,eAAe;AAC/C,MAAM,OAAO,OAAO,OAAO,QAAQ;AAEnC,MAAM,wCAAyBF,aAAW,oBAAoB;AAE9D,MAAMG,cAAkC;CACtC,QAAQ;CACR,aAAa;CACd;AAED,MAAM,cAAc,OAAO,UAAyB;AAGlD,KAAI,CAFoB,MAAMC,0DAAsB,KAAK,EAEnC;AACpB,UAAQ,MAAM,yBAAyB,KAAK,4BAA4B;AACxE,UAAQ,KAAK,IAAI;;AAInB,OAAMC,MAAI,SAASC,yBAAe;EAChC,uBAAuB;EACvB,QAAQ;EACT,CAAC;AAGF,OAAMD,MAAI,SAASE,uBAAa,YAAY;AAG5C,OAAMF,MAAI,SAASG,0BAAgB;AAGnC,OAAMH,MAAI,SAASI,wBAAc;AAGjC,OAAMJ,MAAI,SAASK,0BAAgB;AAGnC,OAAML,MAAI,SAASM,mDAAkB,EAAE,QAAQ,mBAAmB,CAAC;AACnE,OAAMN,MAAI,SAASO,kDAAqB,EAAE,QAAQ,eAAe,CAAC;AAGlE,OAAMP,MAAI,SAASQ,yBAAe;EAChC,MAAM;EACN,UAAU;EACX,CAAC;AAGF,OAAI,oBAAoB,KAAK,UAAU;EACrC,MAAM,oCAAqB,gBAAgB,IAAI,IAAI,OAAO,IAAI;AAE9D,8BAAe,cAAc,2BAAc,cAAc,CAAC,QAAQ,EAAE;GAClE,MAAM,WACJ,aAAK,QAAQ,cAAc,IAAI;AACjC,SAAM,OAAO,gBAAgB,SAAS;AACtC,UAAO,MAAM,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI,aAAa;QAEpE,QAAO,MAAM,SAAS,aAAa;GAErC;AAEF,KAAI;AACF,QAAMR,MAAI,OAAO;GAAE;GAAM,MAAM;GAAW,CAAC;EAE3C,MAAM,sDACJ,eAAe,KACf,eAAe,QAChB;AAED,UAAQ,IAAI;oEACQ,YAAYS,4BAAW,KAAK,EAAEA,4BAAW,UAAU,CAAC,kCAAY,IAAI,YAAY,WAAWA,4BAAW,UAAU,CAAC;;sEAEzF,oBAAoB,OAAO,CAAC;qCAC7D,KAAKA,4BAAW,UAAU,CAAC,8BAA8B,OAAO,OAAO,mBAAmB,KAAK,yCAAmB,OAAO,OAAO,eAAe,CAAC;qCAChJ,KAAKA,4BAAW,UAAU,CAAC,8BAA8B,OAAO,OAAO,YAAY,IAAI;qCACvF,KAAKA,4BAAW,UAAU,CAAC,8BAA8B,kBAAkB,IAAI;MACxF;UACK,KAAK;AACZ,QAAI,IAAI,MAAM,IAAI;AAClB,UAAQ,KAAK,EAAE;;;AAKnB,YAAY,IAAI"}
|
package/server/dist/index.mjs
CHANGED
|
@@ -2,15 +2,17 @@ import { configurationRouter } from "./routes/config.routes.mjs";
|
|
|
2
2
|
import { dictionaryRouter } from "./routes/dictionary.routes.mjs";
|
|
3
3
|
import { checkPortAvailability } from "./utils/checkPortAvailability.mjs";
|
|
4
4
|
import { ANSIColors, colorize, colorizePath, getConfiguration, getEnvFilePath } from "@intlayer/config";
|
|
5
|
-
import { intlayer } from "
|
|
5
|
+
import { intlayer } from "fastify-intlayer";
|
|
6
6
|
import { existsSync, lstatSync, readFileSync } from "node:fs";
|
|
7
7
|
import { dirname, join, resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
9
|
+
import fastifyCompress from "@fastify/compress";
|
|
10
|
+
import fastifyCookie from "@fastify/cookie";
|
|
11
|
+
import fastifyCors from "@fastify/cors";
|
|
12
|
+
import fastifyFormbody from "@fastify/formbody";
|
|
13
|
+
import fastifyHelmet from "@fastify/helmet";
|
|
14
|
+
import fastifyStatic from "@fastify/static";
|
|
15
|
+
import Fastify from "fastify";
|
|
14
16
|
import mime from "mime";
|
|
15
17
|
|
|
16
18
|
//#region src/index.ts
|
|
@@ -20,8 +22,8 @@ const envFileOptions = {
|
|
|
20
22
|
envFile: process.env.ENV_FILE
|
|
21
23
|
};
|
|
22
24
|
const packageJson = JSON.parse(readFileSync(resolve(__dirname, "../../package.json"), "utf8"));
|
|
23
|
-
const app =
|
|
24
|
-
app.
|
|
25
|
+
const app = Fastify({ disableRequestLogging: true });
|
|
26
|
+
app.register(intlayer);
|
|
25
27
|
const FALLBACK_PORT = 8e3;
|
|
26
28
|
const config = getConfiguration(envFileOptions);
|
|
27
29
|
const port = config.editor.port ?? FALLBACK_PORT;
|
|
@@ -35,25 +37,33 @@ const startServer = async (app$1) => {
|
|
|
35
37
|
console.error(`\x1b[1;31mError: Port ${port} is already in use.\x1b[0m`);
|
|
36
38
|
process.exit(255);
|
|
37
39
|
}
|
|
38
|
-
app$1.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
app$1.
|
|
43
|
-
app$1.
|
|
44
|
-
app$1.
|
|
45
|
-
app$1.
|
|
46
|
-
app$1.
|
|
47
|
-
app$1.
|
|
48
|
-
app$1.
|
|
49
|
-
|
|
40
|
+
await app$1.register(fastifyHelmet, {
|
|
41
|
+
contentSecurityPolicy: false,
|
|
42
|
+
global: true
|
|
43
|
+
});
|
|
44
|
+
await app$1.register(fastifyCors, corsOptions);
|
|
45
|
+
await app$1.register(fastifyCompress);
|
|
46
|
+
await app$1.register(fastifyCookie);
|
|
47
|
+
await app$1.register(fastifyFormbody);
|
|
48
|
+
await app$1.register(dictionaryRouter, { prefix: "/api/dictionary" });
|
|
49
|
+
await app$1.register(configurationRouter, { prefix: "/api/config" });
|
|
50
|
+
await app$1.register(fastifyStatic, {
|
|
51
|
+
root: clientDistPath,
|
|
52
|
+
wildcard: false
|
|
53
|
+
});
|
|
54
|
+
app$1.setNotFoundHandler((req, reply) => {
|
|
55
|
+
const requestedPath = join(clientDistPath, req.raw.url || "/");
|
|
50
56
|
if (existsSync(requestedPath) && lstatSync(requestedPath).isFile()) {
|
|
51
57
|
const mimeType = mime.getType(requestedPath) ?? "application/octet-stream";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} else
|
|
58
|
+
reply.header("Content-Type", mimeType);
|
|
59
|
+
return reply.sendFile(req.raw.url?.split("/").pop() || "index.html");
|
|
60
|
+
} else return reply.sendFile("index.html");
|
|
55
61
|
});
|
|
56
|
-
|
|
62
|
+
try {
|
|
63
|
+
await app$1.listen({
|
|
64
|
+
port,
|
|
65
|
+
host: "0.0.0.0"
|
|
66
|
+
});
|
|
57
67
|
const dotEnvFilePath = getEnvFilePath(envFileOptions.env, envFileOptions.envFile);
|
|
58
68
|
console.log(`
|
|
59
69
|
${colorize(colorize("INTLAYER", ANSIColors.BOLD), ANSIColors.GREY_DARK)} ${colorize(`v${packageJson.version}`, ANSIColors.GREY_DARK)}
|
|
@@ -63,7 +73,10 @@ const startServer = async (app$1) => {
|
|
|
63
73
|
${colorize("➜", ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? "-"}
|
|
64
74
|
${colorize("➜", ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? "-"}
|
|
65
75
|
`);
|
|
66
|
-
})
|
|
76
|
+
} catch (err) {
|
|
77
|
+
app$1.log.error(err);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
67
80
|
};
|
|
68
81
|
startServer(app);
|
|
69
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["app:
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["app: FastifyInstance","corsOptions: FastifyCorsOptions","app"],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync, lstatSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport fastifyCompress from '@fastify/compress';\nimport fastifyCookie from '@fastify/cookie';\nimport fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';\nimport fastifyFormbody from '@fastify/formbody';\nimport fastifyHelmet from '@fastify/helmet';\nimport fastifyStatic from '@fastify/static';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getConfiguration,\n getEnvFilePath,\n} from '@intlayer/config';\nimport { configurationRouter } from '@routes/config.routes';\nimport { dictionaryRouter } from '@routes/dictionary.routes';\nimport { checkPortAvailability } from '@utils/checkPortAvailability';\nimport Fastify, { type FastifyInstance } from 'fastify';\nimport { intlayer } from 'fastify-intlayer';\nimport mime from 'mime';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst envFileOptions = {\n env: process.env.NODE_ENV,\n envFile: process.env.ENV_FILE,\n};\n\n// Load package.json\nconst packageJson = JSON.parse(\n readFileSync(resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nconst app: FastifyInstance = Fastify({\n disableRequestLogging: true, // Optional: Keep logs clean like the original\n});\n\n// Load internationalization plugin\n// Assuming fastify-intlayer is the Fastify equivalent of express-intlayer\napp.register(intlayer);\n\nconst FALLBACK_PORT = 8000;\nconst config = getConfiguration(envFileOptions);\nconst port = config.editor.port ?? FALLBACK_PORT;\n\nconst clientDistPath = resolve(__dirname, '../../client/dist');\n\nconst corsOptions: FastifyCorsOptions = {\n origin: '*',\n credentials: true,\n};\n\nconst startServer = async (app: FastifyInstance) => {\n const isPortAvailable = await checkPortAvailability(port);\n\n if (!isPortAvailable) {\n console.error(`\\x1b[1;31mError: Port ${port} is already in use.\\x1b[0m`);\n process.exit(255);\n }\n\n // Security Headers\n await app.register(fastifyHelmet, {\n contentSecurityPolicy: false,\n global: true,\n });\n\n // CORS\n await app.register(fastifyCors, corsOptions);\n\n // Compression\n await app.register(fastifyCompress);\n\n // Cookie Parser\n await app.register(fastifyCookie);\n\n // Parse application/x-www-form-urlencoded\n await app.register(fastifyFormbody);\n\n // Register Routes\n await app.register(dictionaryRouter, { prefix: '/api/dictionary' });\n await app.register(configurationRouter, { prefix: '/api/config' });\n\n // Serve Static Files\n await app.register(fastifyStatic, {\n root: clientDistPath,\n wildcard: false, // We handle the fallback manually to match SPA logic\n });\n\n // For single-page applications, redirect all unmatched routes to index.html\n app.setNotFoundHandler((req, reply) => {\n const requestedPath = join(clientDistPath, req.raw.url || '/');\n\n if (existsSync(requestedPath) && lstatSync(requestedPath).isFile()) {\n const mimeType =\n mime.getType(requestedPath) ?? 'application/octet-stream';\n reply.header('Content-Type', mimeType);\n return reply.sendFile(req.raw.url?.split('/').pop() || 'index.html');\n } else {\n return reply.sendFile('index.html');\n }\n });\n\n try {\n await app.listen({ port, host: '0.0.0.0' });\n\n const dotEnvFilePath = getEnvFilePath(\n envFileOptions.env,\n envFileOptions.envFile\n );\n\n console.log(`\n ${colorize(colorize('INTLAYER', ANSIColors.BOLD), ANSIColors.GREY_DARK)} ${colorize(`v${packageJson.version}`, ANSIColors.GREY_DARK)}\n\n Editor running at: ${colorizePath(`http://localhost:${port}`)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Watching application at: ${config.editor.applicationURL === '' ? '-' : colorizePath(config.editor.applicationURL)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? '-'}\n ${colorize('➜', ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? '-'}\n `);\n } catch (err) {\n app.log.error(err);\n process.exit(1);\n }\n};\n\n// Start it up!\nstartServer(app);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,iBAAiB;CACrB;CACA,SAAS,QAAQ,IAAI;CACtB;AAGD,MAAM,cAAc,KAAK,MACvB,aAAa,QAAQ,WAAW,qBAAqB,EAAE,OAAO,CAC/D;AAED,MAAMA,MAAuB,QAAQ,EACnC,uBAAuB,MACxB,CAAC;AAIF,IAAI,SAAS,SAAS;AAEtB,MAAM,gBAAgB;AACtB,MAAM,SAAS,iBAAiB,eAAe;AAC/C,MAAM,OAAO,OAAO,OAAO,QAAQ;AAEnC,MAAM,iBAAiB,QAAQ,WAAW,oBAAoB;AAE9D,MAAMC,cAAkC;CACtC,QAAQ;CACR,aAAa;CACd;AAED,MAAM,cAAc,OAAO,UAAyB;AAGlD,KAAI,CAFoB,MAAM,sBAAsB,KAAK,EAEnC;AACpB,UAAQ,MAAM,yBAAyB,KAAK,4BAA4B;AACxE,UAAQ,KAAK,IAAI;;AAInB,OAAMC,MAAI,SAAS,eAAe;EAChC,uBAAuB;EACvB,QAAQ;EACT,CAAC;AAGF,OAAMA,MAAI,SAAS,aAAa,YAAY;AAG5C,OAAMA,MAAI,SAAS,gBAAgB;AAGnC,OAAMA,MAAI,SAAS,cAAc;AAGjC,OAAMA,MAAI,SAAS,gBAAgB;AAGnC,OAAMA,MAAI,SAAS,kBAAkB,EAAE,QAAQ,mBAAmB,CAAC;AACnE,OAAMA,MAAI,SAAS,qBAAqB,EAAE,QAAQ,eAAe,CAAC;AAGlE,OAAMA,MAAI,SAAS,eAAe;EAChC,MAAM;EACN,UAAU;EACX,CAAC;AAGF,OAAI,oBAAoB,KAAK,UAAU;EACrC,MAAM,gBAAgB,KAAK,gBAAgB,IAAI,IAAI,OAAO,IAAI;AAE9D,MAAI,WAAW,cAAc,IAAI,UAAU,cAAc,CAAC,QAAQ,EAAE;GAClE,MAAM,WACJ,KAAK,QAAQ,cAAc,IAAI;AACjC,SAAM,OAAO,gBAAgB,SAAS;AACtC,UAAO,MAAM,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI,aAAa;QAEpE,QAAO,MAAM,SAAS,aAAa;GAErC;AAEF,KAAI;AACF,QAAMA,MAAI,OAAO;GAAE;GAAM,MAAM;GAAW,CAAC;EAE3C,MAAM,iBAAiB,eACrB,eAAe,KACf,eAAe,QAChB;AAED,UAAQ,IAAI;MACV,SAAS,SAAS,YAAY,WAAW,KAAK,EAAE,WAAW,UAAU,CAAC,GAAG,SAAS,IAAI,YAAY,WAAW,WAAW,UAAU,CAAC;;mCAEtG,aAAa,oBAAoB,OAAO,CAAC;MACtE,SAAS,KAAK,WAAW,UAAU,CAAC,8BAA8B,OAAO,OAAO,mBAAmB,KAAK,MAAM,aAAa,OAAO,OAAO,eAAe,CAAC;MACzJ,SAAS,KAAK,WAAW,UAAU,CAAC,8BAA8B,OAAO,OAAO,YAAY,IAAI;MAChG,SAAS,KAAK,WAAW,UAAU,CAAC,8BAA8B,kBAAkB,IAAI;MACxF;UACK,KAAK;AACZ,QAAI,IAAI,MAAM,IAAI;AAClB,UAAQ,KAAK,EAAE;;;AAKnB,YAAY,IAAI"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_controllers_configuration_controller = require('../controllers/configuration.controller.cjs');
|
|
3
3
|
let _intlayer_config = require("@intlayer/config");
|
|
4
|
-
let express = require("express");
|
|
5
4
|
|
|
6
5
|
//#region src/routes/config.routes.ts
|
|
7
|
-
const configurationRouter = (0, express.Router)();
|
|
8
6
|
const { editor } = (0, _intlayer_config.getConfiguration)();
|
|
9
7
|
const getBaseURL = () => `${editor.editorURL}/api/dictionary`;
|
|
10
8
|
const getConfigurationRoutes = () => ({ getConfiguration: {
|
|
@@ -12,7 +10,9 @@ const getConfigurationRoutes = () => ({ getConfiguration: {
|
|
|
12
10
|
url: getBaseURL(),
|
|
13
11
|
method: "GET"
|
|
14
12
|
} });
|
|
15
|
-
configurationRouter
|
|
13
|
+
const configurationRouter = async (fastify) => {
|
|
14
|
+
fastify.get(getConfigurationRoutes().getConfiguration.urlModel, require_controllers_configuration_controller.getConfiguration);
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
exports.configurationRouter = configurationRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.routes.cjs","names":[
|
|
1
|
+
{"version":3,"file":"config.routes.cjs","names":[],"sources":["../../src/routes/config.routes.ts"],"sourcesContent":["import * as configurationController from '@controllers/configuration.controller';\nimport { getConfiguration } from '@intlayer/config';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/dictionary`;\n\nexport const getConfigurationRoutes = () =>\n ({\n getConfiguration: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n }) satisfies Routes;\n\nexport const configurationRouter = async (fastify: FastifyInstance) => {\n fastify.get(\n getConfigurationRoutes().getConfiguration.urlModel,\n configurationController.getConfiguration\n );\n};\n"],"mappings":";;;;;AAKA,MAAM,EAAE,mDAA6B;AAErC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,gCACV,EACC,kBAAkB;CAChB,UAAU;CACV,KAAK,YAAY;CACjB,QAAQ;CACT,EACF;AAEH,MAAa,sBAAsB,OAAO,YAA6B;AACrE,SAAQ,IACN,wBAAwB,CAAC,iBAAiB,wEAE3C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FastifyInstance } from "fastify";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/config.routes.d.ts
|
|
4
|
-
declare const configurationRouter: Router;
|
|
5
4
|
declare const getConfigurationRoutes: () => {
|
|
6
5
|
getConfiguration: {
|
|
7
6
|
urlModel: string;
|
|
@@ -9,6 +8,7 @@ declare const getConfigurationRoutes: () => {
|
|
|
9
8
|
method: "GET";
|
|
10
9
|
};
|
|
11
10
|
};
|
|
11
|
+
declare const configurationRouter: (fastify: FastifyInstance) => Promise<void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { configurationRouter, getConfigurationRoutes };
|
|
14
14
|
//# sourceMappingURL=config.routes.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { getConfiguration as getConfiguration$1 } from "../controllers/configuration.controller.mjs";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config";
|
|
3
|
-
import { Router } from "express";
|
|
4
3
|
|
|
5
4
|
//#region src/routes/config.routes.ts
|
|
6
|
-
const configurationRouter = Router();
|
|
7
5
|
const { editor } = getConfiguration();
|
|
8
6
|
const getBaseURL = () => `${editor.editorURL}/api/dictionary`;
|
|
9
7
|
const getConfigurationRoutes = () => ({ getConfiguration: {
|
|
@@ -11,7 +9,9 @@ const getConfigurationRoutes = () => ({ getConfiguration: {
|
|
|
11
9
|
url: getBaseURL(),
|
|
12
10
|
method: "GET"
|
|
13
11
|
} });
|
|
14
|
-
configurationRouter
|
|
12
|
+
const configurationRouter = async (fastify) => {
|
|
13
|
+
fastify.get(getConfigurationRoutes().getConfiguration.urlModel, getConfiguration$1);
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
export { configurationRouter, getConfigurationRoutes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.routes.mjs","names":["
|
|
1
|
+
{"version":3,"file":"config.routes.mjs","names":["configurationController.getConfiguration"],"sources":["../../src/routes/config.routes.ts"],"sourcesContent":["import * as configurationController from '@controllers/configuration.controller';\nimport { getConfiguration } from '@intlayer/config';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/dictionary`;\n\nexport const getConfigurationRoutes = () =>\n ({\n getConfiguration: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n }) satisfies Routes;\n\nexport const configurationRouter = async (fastify: FastifyInstance) => {\n fastify.get(\n getConfigurationRoutes().getConfiguration.urlModel,\n configurationController.getConfiguration\n );\n};\n"],"mappings":";;;;AAKA,MAAM,EAAE,WAAW,kBAAkB;AAErC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,gCACV,EACC,kBAAkB;CAChB,UAAU;CACV,KAAK,YAAY;CACjB,QAAQ;CACT,EACF;AAEH,MAAa,sBAAsB,OAAO,YAA6B;AACrE,SAAQ,IACN,wBAAwB,CAAC,iBAAiB,UAC1CA,mBACD"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_controllers_dictionary_controller = require('../controllers/dictionary.controller.cjs');
|
|
3
3
|
let _intlayer_config = require("@intlayer/config");
|
|
4
|
-
let express = require("express");
|
|
5
4
|
|
|
6
5
|
//#region src/routes/dictionary.routes.ts
|
|
7
|
-
const dictionaryRouter = (0, express.Router)();
|
|
8
6
|
const { editor } = (0, _intlayer_config.getConfiguration)();
|
|
9
7
|
const getBaseURL = () => `${editor.editorURL}/api/dictionary`;
|
|
10
8
|
const getDictionaryRoutes = () => ({
|
|
@@ -19,8 +17,10 @@ const getDictionaryRoutes = () => ({
|
|
|
19
17
|
method: "POST"
|
|
20
18
|
}
|
|
21
19
|
});
|
|
22
|
-
dictionaryRouter
|
|
23
|
-
|
|
20
|
+
const dictionaryRouter = async (fastify) => {
|
|
21
|
+
fastify.get(getDictionaryRoutes().getDictionaries.urlModel, require_controllers_dictionary_controller.getDictionaries);
|
|
22
|
+
fastify.post(getDictionaryRoutes().writeContentDeclaration.urlModel, require_controllers_dictionary_controller.writeContentDeclaration);
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
exports.dictionaryRouter = dictionaryRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.routes.cjs","names":["
|
|
1
|
+
{"version":3,"file":"dictionary.routes.cjs","names":["getDictionaries","writeContentDeclaration"],"sources":["../../src/routes/dictionary.routes.ts"],"sourcesContent":["import {\n getDictionaries,\n writeContentDeclaration,\n} from '@controllers/dictionary.controller';\nimport { getConfiguration } from '@intlayer/config';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/dictionary`;\n\nexport const getDictionaryRoutes = () =>\n ({\n getDictionaries: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n writeContentDeclaration: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const dictionaryRouter = async (fastify: FastifyInstance) => {\n fastify.get(getDictionaryRoutes().getDictionaries.urlModel, getDictionaries);\n fastify.post(\n getDictionaryRoutes().writeContentDeclaration.urlModel,\n writeContentDeclaration\n );\n};\n"],"mappings":";;;;;AAQA,MAAM,EAAE,mDAA6B;AAErC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,6BACV;CACC,iBAAiB;EACf,UAAU;EACV,KAAK,YAAY;EACjB,QAAQ;EACT;CACD,yBAAyB;EACvB,UAAU;EACV,KAAK,YAAY;EACjB,QAAQ;EACT;CACF;AAEH,MAAa,mBAAmB,OAAO,YAA6B;AAClE,SAAQ,IAAI,qBAAqB,CAAC,gBAAgB,UAAUA,0DAAgB;AAC5E,SAAQ,KACN,qBAAqB,CAAC,wBAAwB,UAC9CC,kEACD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FastifyInstance } from "fastify";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/dictionary.routes.d.ts
|
|
4
|
-
declare const dictionaryRouter: Router;
|
|
5
4
|
declare const getDictionaryRoutes: () => {
|
|
6
5
|
getDictionaries: {
|
|
7
6
|
urlModel: string;
|
|
@@ -14,6 +13,7 @@ declare const getDictionaryRoutes: () => {
|
|
|
14
13
|
method: "POST";
|
|
15
14
|
};
|
|
16
15
|
};
|
|
16
|
+
declare const dictionaryRouter: (fastify: FastifyInstance) => Promise<void>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { dictionaryRouter, getDictionaryRoutes };
|
|
19
19
|
//# sourceMappingURL=dictionary.routes.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { getDictionaries, writeContentDeclaration } from "../controllers/dictionary.controller.mjs";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config";
|
|
3
|
-
import { Router } from "express";
|
|
4
3
|
|
|
5
4
|
//#region src/routes/dictionary.routes.ts
|
|
6
|
-
const dictionaryRouter = Router();
|
|
7
5
|
const { editor } = getConfiguration();
|
|
8
6
|
const getBaseURL = () => `${editor.editorURL}/api/dictionary`;
|
|
9
7
|
const getDictionaryRoutes = () => ({
|
|
@@ -18,8 +16,10 @@ const getDictionaryRoutes = () => ({
|
|
|
18
16
|
method: "POST"
|
|
19
17
|
}
|
|
20
18
|
});
|
|
21
|
-
dictionaryRouter
|
|
22
|
-
|
|
19
|
+
const dictionaryRouter = async (fastify) => {
|
|
20
|
+
fastify.get(getDictionaryRoutes().getDictionaries.urlModel, getDictionaries);
|
|
21
|
+
fastify.post(getDictionaryRoutes().writeContentDeclaration.urlModel, writeContentDeclaration);
|
|
22
|
+
};
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { dictionaryRouter, getDictionaryRoutes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.routes.mjs","names":[
|
|
1
|
+
{"version":3,"file":"dictionary.routes.mjs","names":[],"sources":["../../src/routes/dictionary.routes.ts"],"sourcesContent":["import {\n getDictionaries,\n writeContentDeclaration,\n} from '@controllers/dictionary.controller';\nimport { getConfiguration } from '@intlayer/config';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/dictionary`;\n\nexport const getDictionaryRoutes = () =>\n ({\n getDictionaries: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n writeContentDeclaration: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const dictionaryRouter = async (fastify: FastifyInstance) => {\n fastify.get(getDictionaryRoutes().getDictionaries.urlModel, getDictionaries);\n fastify.post(\n getDictionaryRoutes().writeContentDeclaration.urlModel,\n writeContentDeclaration\n );\n};\n"],"mappings":";;;;AAQA,MAAM,EAAE,WAAW,kBAAkB;AAErC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,6BACV;CACC,iBAAiB;EACf,UAAU;EACV,KAAK,YAAY;EACjB,QAAQ;EACT;CACD,yBAAyB;EACvB,UAAU;EACV,KAAK,YAAY;EACjB,QAAQ;EACT;CACF;AAEH,MAAa,mBAAmB,OAAO,YAA6B;AAClE,SAAQ,IAAI,qBAAqB,CAAC,gBAAgB,UAAU,gBAAgB;AAC5E,SAAQ,KACN,qBAAqB,CAAC,wBAAwB,UAC9C,wBACD"}
|