@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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifecodes/backend-template",
3
- "version": "1.0.0",
3
+ "version": "1.0.6",
4
4
  "description": "Production-ready Express + TypeScript backend generator with optional features and microservice support",
5
5
  "bin": {
6
6
  "ifecodes-template": "bin/cli.js"
@@ -1,6 +1,5 @@
1
1
  import express from "express";
2
2
  /*__IMPORTS__*/
3
- /*__ENV_CORS__*/
4
3
 
5
4
  const app = express();
6
5