@ldsg/express-app-module-template-constants 0.0.0-stage → 0.3.45
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/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/template.json +28 -0
- package/package.json +27 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B;;;;;CAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EXPRESS_APP_MODULE_TEMPLATE = void 0;
|
|
7
|
+
const template_json_1 = __importDefault(require("./template.json"));
|
|
8
|
+
exports.EXPRESS_APP_MODULE_TEMPLATE = template_json_1.default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
{
|
|
4
|
+
"path": "index.ts",
|
|
5
|
+
"content": "import { instantiateAppResource } from \"@ldsg/instantiate-app-resource\";\nimport { ApplicationResource } from \"@ldsg/application\";\nimport MANIFEST_JSON from \"./manifest.json\" with { type: \"json\" };\n\nconst { resourceRecords } = MANIFEST_JSON as any;\n\nconst handlerModules: Record<string, any> = {};\n\n/**\n * 将 handler 引入 app 并放入相应 handler 资源中\n * 使运行时无需通过 require(moduleId) 动态加载 handler 模块\n */\nconst wiredResourceRecords = (resourceRecords as any[]).map((resourceRecord: any) => {\n const { kind, id, settings } = resourceRecord;\n\n if (kind === \"handler\" && handlerModules[id]) {\n return {\n ...resourceRecord,\n settings: {\n ...settings,\n handler: handlerModules[id].handler,\n },\n };\n }\n\n return resourceRecord;\n});\n\nconst start = async () => {\n const appResource = (await instantiateAppResource({\n resourceRecords: wiredResourceRecords,\n })) as ApplicationResource;\n\n const app = appResource.createExpressApp();\n\n const port = process.env.PORT || \"3253\";\n\n app.listen(port, () => {\n console.log(`App listening on http://localhost:${port}`);\n\n console.log(`GraphQL listening on http://localhost:${port}/graphql`);\n });\n};\n\nstart();\n"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"path": "manifest.json",
|
|
9
|
+
"content": "{\n \"resourceRecords\": [\n {\n \"id\": \"resource-definition-resource-definition\",\n \"kind\": \"resource_definition\",\n \"parentId\": \"root\",\n \"settings\": {\n \"title\": \"资源定义资源定义\",\n \"description\": \"\",\n \"kind\": \"resource_definition\",\n \"parentKind\": \"\"\n }\n },\n {\n \"id\": \"resource-definition-resource-handler\",\n \"kind\": \"handler\",\n \"parentId\": \"resource-definition-resource-definition\",\n \"settings\": {\n \"title\": \"资源定义实例化资源处理程序\",\n \"description\": \"\",\n \"code\": \"export * from \\\"@ldsg/resource-definition\\\";\",\n \"dependencies\": [{ \"name\": \"@ldsg/resource-definition\" }]\n }\n },\n {\n \"id\": \"handler-resource-definition\",\n \"kind\": \"resource_definition\",\n \"parentId\": \"root\",\n \"settings\": {\n \"title\": \"处理程序资源定义\",\n \"description\": \"主要包含引入模块列表与相应的处理程序代码,处理程序类型资源无子级资源。\",\n \"kind\": \"handler\",\n \"parentKind\": \"\"\n }\n },\n {\n \"id\": \"handler-resource-handler\",\n \"kind\": \"handler\",\n \"parentId\": \"handler-resource-definition\",\n \"settings\": {\n \"title\": \"处理程序实例化资源处理程序\",\n \"description\": \"包含处理程序相应的模块,此模块主要通过\",\n \"code\": \"export * from \\\"@ldsg/handler\\\";\",\n \"dependencies\": [{ \"name\": \"@ldsg/handler\" }]\n }\n },\n {\n \"id\": \"application-resource-definition\",\n \"kind\": \"resource_definition\",\n \"parentId\": \"root\",\n \"settings\": {\n \"title\": \"应用资源定义\",\n \"description\": \"\",\n \"kind\": \"application\",\n \"parentKind\": \"\"\n }\n },\n {\n \"id\": \"application-resource-handler\",\n \"kind\": \"handler\",\n \"parentId\": \"application-resource-definition\",\n \"settings\": {\n \"title\": \"应用实例化资源处理程序\",\n \"description\": \"\",\n \"code\": \"export * from \\\"@ldsg/application\\\";\",\n \"dependencies\": [{ \"name\": \"@ldsg/application\" }]\n }\n },\n {\n \"id\": \"main-app\",\n \"kind\": \"application\",\n \"parentId\": \"root\",\n \"settings\": { \"title\": \"主要应用\", \"description\": \"\" }\n }\n ]\n}\n"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "package.json",
|
|
13
|
+
"content": "{\n \"name\": \"@ldsg/express-app-module-template\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"description\": \"\",\n \"license\": \"UNLICENSED\",\n \"author\": \"\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"vite build\",\n \"start\": \"node ./dist/index.js\",\n \"start:telemetry\": \"node --import @ldsg/opentelemetry-node ./dist/index.js\"\n },\n \"dependencies\": {\n \"@ldsg/application\": \"workspace:*\",\n \"@ldsg/instantiate-app-resource\": \"workspace:*\",\n \"@ldsg/opentelemetry-node\": \"workspace:*\",\n \"graphql\": \"^16.9.0\",\n \"graphql-middleware\": \"^6.1.35\",\n \"graphql-shield\": \"^7.6.5\"\n },\n \"devDependencies\": {\n \"@types/express\": \"^4.17.17\",\n \"@types/node\": \"^22.1.0\",\n \"typescript\": \"^5.5.4\",\n \"vite\": \"^7.1.7\"\n }\n}\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "pnpm-workspace.yaml",
|
|
17
|
+
"content": "packages:\n - handlers/*\nminimumReleaseAgeExclude:\n - \"@ldsg/*\"\n"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "tsconfig.json",
|
|
21
|
+
"content": "{\n \"compilerOptions\": {\n \"module\": \"NodeNext\",\n \"declaration\": true,\n \"removeComments\": true,\n \"emitDecoratorMetadata\": true,\n \"experimentalDecorators\": true,\n \"allowSyntheticDefaultImports\": true,\n \"target\": \"esnext\",\n \"sourceMap\": true,\n \"outDir\": \"./dist\",\n \"baseUrl\": \"./\",\n \"incremental\": true,\n \"skipLibCheck\": true,\n \"strictNullChecks\": false,\n \"noImplicitAny\": false,\n \"strictBindCallApply\": false,\n \"forceConsistentCasingInFileNames\": false,\n \"noFallthroughCasesInSwitch\": false,\n \"resolveJsonModule\": true,\n \"esModuleInterop\": true\n },\n \"include\": [\"./*.ts\"]\n}\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "vite.config.ts",
|
|
25
|
+
"content": "import { defineConfig } from \"vite\";\n\nexport default defineConfig({\n build: {\n outDir: \"dist\",\n ssr: \"index.ts\",\n commonjsOptions: {\n include: [/.*/],\n },\n rollupOptions: {\n output: {\n inlineDynamicImports: true,\n },\n },\n },\n ssr: {\n /**\n * 全量打包依赖进单文件,运行时无需 node_modules\n */\n noExternal: true,\n },\n plugins: [\n {\n /**\n * 把仅在桌面端使用的包(如 got@8 内引用的 electron)替换为空模块,\n * 避免服务端 bundle 启动时因找不到该包而报错\n */\n name: \"ldsg:shim-server-externals\",\n enforce: \"pre\",\n resolveId(id) {\n if (id === \"electron\") return \"\\0ldsg-shim:electron\";\n return null;\n },\n load(id) {\n if (id === \"\\0ldsg-shim:electron\") return \"export default {};\";\n return null;\n },\n },\n {\n /**\n * rollup 的 CJS interop 会把 graphql-compose 的 ObjectTypeComposer 类加上数字后缀\n * (如 ObjectTypeComposer2),破坏 graphql-compose-mongoose 基于 constructor.name\n * 的字符串校验(Second arg for Resolver count() should be instance of ObjectTypeComposer)。\n * 这里在产物里把类名恢复为 ObjectTypeComposer。\n */\n name: \"ldsg:restore-cjs-class-names\",\n enforce: \"post\",\n generateBundle(_options, bundle) {\n for (const file of Object.values(bundle)) {\n if (file.type === \"chunk\" && typeof file.code === \"string\") {\n file.code = file.code.replace(/\\bObjectTypeComposer\\d*\\b/g, \"ObjectTypeComposer\");\n }\n }\n },\n },\n ],\n});\n"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/express-app-module-template-constants",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.3.45",
|
|
4
|
+
"description": "Constants generated from the app module template",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "wanxger",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/"
|
|
10
|
+
],
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^20.13.0",
|
|
18
|
+
"oxfmt": "latest",
|
|
19
|
+
"oxlint": "latest",
|
|
20
|
+
"tsx": "^4.19.3",
|
|
21
|
+
"typescript": "^5.8.3"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run clean && npm run generate && tsc --project tsconfig.build.json && npm run format",
|
|
25
|
+
"clean": "rm -rf dist",
|
|
26
|
+
"format": "oxfmt --write src/ scripts/",
|
|
27
|
+
"generate": "tsx scripts/generate.ts",
|
|
28
|
+
"lint": "oxlint src/ scripts/"
|
|
29
|
+
}
|
|
6
30
|
}
|
package/README.md
DELETED