create-efc-app 0.4.4 → 0.4.6
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.js +26 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -121,21 +121,36 @@ async function writeTsConfig(dest, opts) {
|
|
|
121
121
|
strict: true,
|
|
122
122
|
esModuleInterop: true,
|
|
123
123
|
skipLibCheck: true,
|
|
124
|
-
outDir: "./dist"
|
|
125
|
-
rootDir: "./src"
|
|
124
|
+
outDir: "./dist"
|
|
126
125
|
},
|
|
127
|
-
|
|
126
|
+
// No explicit rootDir: efc.config.ts lives at the project root, outside src/, and
|
|
127
|
+
// src/index.ts imports it. `efc build prod` only uses this config for `tsc --noEmit`
|
|
128
|
+
// typechecking — the actual dist/index.js output path is decided by tsup's entry arg,
|
|
129
|
+
// so leaving rootDir implicit here has no effect on the production build's output layout.
|
|
130
|
+
include: ["src/**/*", "efc.config.ts"],
|
|
128
131
|
exclude: ["node_modules", "dist"]
|
|
129
132
|
};
|
|
130
133
|
await fs.writeJson(path.join(dest, "tsconfig.json"), config, { spaces: 2 });
|
|
131
134
|
}
|
|
132
135
|
async function writeEfcConfig(dest, opts) {
|
|
133
136
|
const ext = opts.language === "typescript" ? "ts" : "js";
|
|
134
|
-
const tasks = opts.tasks ? `{ backend: '${opts.taskBackend ?? "bullmq"}', concurrency: 5 }` : "false";
|
|
137
|
+
const tasks = opts.tasks ? `{ backend: '${opts.taskBackend ?? "bullmq"}', concurrency: 5, redisUrl: process.env.REDIS_URL }` : "false";
|
|
135
138
|
const content = `import type { EFCConfig } from 'express-file-cluster';
|
|
136
139
|
|
|
137
|
-
//
|
|
140
|
+
// The framework never reads process.env itself \u2014 every runtime value it needs is read
|
|
141
|
+
// here, explicitly, and passed in. Edit .env to change values; edit this file to change
|
|
142
|
+
// which env vars are wired up or add new ones.
|
|
143
|
+
const corsOrigins = process.env.CORS_ORIGINS
|
|
144
|
+
? process.env.CORS_ORIGINS.split(',').map((o) => o.trim()).filter(Boolean)
|
|
145
|
+
: undefined;
|
|
146
|
+
|
|
138
147
|
const config: EFCConfig = {
|
|
148
|
+
port: process.env.PORT ? Number(process.env.PORT) : undefined,
|
|
149
|
+
databaseUrl: process.env.DATABASE_URL,
|
|
150
|
+
jwtSecret: process.env.JWT_SECRET,
|
|
151
|
+
jwtExpiresIn: process.env.JWT_EXPIRES_IN,
|
|
152
|
+
cookieDomain: process.env.COOKIE_DOMAIN,
|
|
153
|
+
cors: corsOrigins ? { origin: corsOrigins } : true,
|
|
139
154
|
authStrategy: '${opts.authStrategy}',
|
|
140
155
|
tasks: ${tasks},
|
|
141
156
|
globalMiddlewares: [],
|
|
@@ -147,14 +162,16 @@ export default config;
|
|
|
147
162
|
}
|
|
148
163
|
async function writeEntryPoint(dest, opts) {
|
|
149
164
|
const ext = opts.language === "typescript" ? "ts" : "js";
|
|
150
|
-
const taskLine = opts.tasks ? ` tasks: { backend: '${opts.taskBackend ?? "bullmq"}' },
|
|
151
|
-
` : "";
|
|
152
165
|
const content = `import { ignite, gracefulShutdown } from 'express-file-cluster';
|
|
166
|
+
import config from '../efc.config.js';
|
|
153
167
|
|
|
154
|
-
// PORT, DATABASE_URL, JWT_SECRET, CORS_ORIGINS
|
|
168
|
+
// Every runtime value (PORT, DATABASE_URL, JWT_SECRET, CORS_ORIGINS, ...) is wired from
|
|
169
|
+
// .env in efc.config.${ext} and spread in below \u2014 ignite() itself never touches process.env
|
|
170
|
+
// for these, so this object is the single source of truth for what's actually applied.
|
|
155
171
|
ignite({
|
|
172
|
+
...config,
|
|
156
173
|
cluster: ${opts.cluster},
|
|
157
|
-
|
|
174
|
+
}).then(gracefulShutdown).catch(console.error);
|
|
158
175
|
`;
|
|
159
176
|
await fs.outputFile(path.join(dest, "src", `index.${ext}`), content);
|
|
160
177
|
}
|