@ifecodes/backend-template 1.0.0 → 1.0.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/bin/lib/service-setup.js +12 -7
- package/package.json +1 -1
- package/template/base/src/app.ts +0 -1
package/bin/lib/service-setup.js
CHANGED
|
@@ -118,13 +118,6 @@ export const setupService = async (
|
|
|
118
118
|
const appPath = path.join(serviceRoot, "src/app.ts");
|
|
119
119
|
let content = fs.readFileSync(appPath, "utf8");
|
|
120
120
|
content = content.replace("/*__IMPORTS__*/", imports.join("\n"));
|
|
121
|
-
// import env if cors is selected
|
|
122
|
-
if (res.features && res.features.includes("cors")) {
|
|
123
|
-
envContent = envContent.replace(
|
|
124
|
-
"/*__ENV_CORS__*/",
|
|
125
|
-
"import { ENV } from '@/config';"
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
121
|
content = content.replace("/*__MIDDLEWARE__*/", middlewares.join("\n"));
|
|
129
122
|
fs.writeFileSync(appPath, content);
|
|
130
123
|
|
|
@@ -176,6 +169,18 @@ export const setupService = async (
|
|
|
176
169
|
if (fs.existsSync(envPath)) {
|
|
177
170
|
let envContent = fs.readFileSync(envPath, "utf8");
|
|
178
171
|
|
|
172
|
+
// Import ENV in app.ts if CORS is selected
|
|
173
|
+
if (res.features && res.features.includes("cors")) {
|
|
174
|
+
let appContent = fs.readFileSync(appPath, "utf8");
|
|
175
|
+
if (!appContent.includes("import { ENV } from")) {
|
|
176
|
+
appContent = appContent.replace(
|
|
177
|
+
"/*__IMPORTS__*/",
|
|
178
|
+
"import { ENV } from '@/config';\n/*__IMPORTS__*/"
|
|
179
|
+
);
|
|
180
|
+
fs.writeFileSync(appPath, appContent);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
179
184
|
// Add ALLOWED_ORIGIN if CORS is selected
|
|
180
185
|
if (res.features && res.features.includes("cors")) {
|
|
181
186
|
envContent = envContent.replace(
|
package/package.json
CHANGED