@codeenthusiast09/create-express-app 1.0.6 → 1.0.7
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/package.json +3 -3
- package/templates/boilerplate/src/common/utils/logger.ts +5 -0
- package/templates/boilerplate/src/config/env.ts +1 -9
- package/templates/boilerplate/src/config/index.ts +3 -1
- package/templates/boilerplate/src/database/drizzle.connection.ts +2 -2
- package/templates/boilerplate/src/database/mongoose.connection.ts +3 -3
- package/templates/boilerplate/src/database/prisma.connection.ts +2 -2
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeenthusiast09/create-express-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "CLI tool to generate production-ready Express TypeScript projects with flexible database options (MongoDB, PostgreSQL with Prisma or Drizzle)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"create-express-app": "
|
|
7
|
+
"create-express-app": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/CodeEnthusiast09/create-express-app"
|
|
11
|
+
"url": "git+https://github.com/CodeEnthusiast09/create-express-app.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/CodeEnthusiast09/create-express-app/issues"
|
|
@@ -12,6 +12,11 @@ import { config } from '@/config';
|
|
|
12
12
|
export const logger = pino({
|
|
13
13
|
level: config.logging.level,
|
|
14
14
|
|
|
15
|
+
serializers: {
|
|
16
|
+
err: pino.stdSerializers.err,
|
|
17
|
+
error: pino.stdSerializers.err,
|
|
18
|
+
},
|
|
19
|
+
|
|
15
20
|
// Pretty print in development, JSON in production
|
|
16
21
|
transport:
|
|
17
22
|
config.nodeEnv === 'development'
|
|
@@ -11,14 +11,6 @@ import path from 'path';
|
|
|
11
11
|
// Load .env from project root
|
|
12
12
|
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
|
|
13
13
|
|
|
14
|
-
// Validate required environment variables
|
|
15
|
-
const requiredEnvVars = ['DATABASE_URL', 'JWT_SECRET'];
|
|
16
|
-
|
|
17
|
-
for (const envVar of requiredEnvVars) {
|
|
18
|
-
if (!process.env[envVar]) {
|
|
19
|
-
throw new Error(`Missing required environment variable: ${envVar}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
// Export nothing - this file is just for side effects
|
|
15
|
+
// Validation is handled by Zod in config/index.ts with clear error messages
|
|
24
16
|
export {};
|
|
@@ -53,7 +53,9 @@ const parseConfig = () => {
|
|
|
53
53
|
},
|
|
54
54
|
cors: {
|
|
55
55
|
origin: process.env.CORS_ORIGIN || '*',
|
|
56
|
-
credentials: process.env.CORS_CREDENTIALS
|
|
56
|
+
credentials: process.env.CORS_CREDENTIALS !== undefined
|
|
57
|
+
? process.env.CORS_CREDENTIALS === 'true'
|
|
58
|
+
: true,
|
|
57
59
|
},
|
|
58
60
|
logging: {
|
|
59
61
|
level: (process.env.LOG_LEVEL || 'info') as 'info',
|
|
@@ -25,7 +25,7 @@ export const connectDatabase = async (): Promise<void> => {
|
|
|
25
25
|
await pool.query('SELECT NOW()');
|
|
26
26
|
logger.info(' PostgreSQL connected successfully (Drizzle)');
|
|
27
27
|
} catch (error) {
|
|
28
|
-
logger.error('
|
|
28
|
+
logger.error({ err: error }, ' PostgreSQL connection error');
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -35,7 +35,7 @@ export const disconnectDatabase = async (): Promise<void> => {
|
|
|
35
35
|
await pool.end();
|
|
36
36
|
logger.info(' PostgreSQL disconnected');
|
|
37
37
|
} catch (error) {
|
|
38
|
-
logger.error(' Error disconnecting from PostgreSQL
|
|
38
|
+
logger.error({ err: error }, ' Error disconnecting from PostgreSQL');
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -25,7 +25,7 @@ export const connectDatabase = async (): Promise<void> => {
|
|
|
25
25
|
|
|
26
26
|
return;
|
|
27
27
|
} catch (error) {
|
|
28
|
-
logger.error(` MongoDB connection attempt ${attempt}/${MAX_RETRIES} failed
|
|
28
|
+
logger.error({ err: error }, ` MongoDB connection attempt ${attempt}/${MAX_RETRIES} failed`);
|
|
29
29
|
|
|
30
30
|
if (attempt < MAX_RETRIES) {
|
|
31
31
|
logger.info(` Retrying in ${RETRY_DELAY}ms...`);
|
|
@@ -45,7 +45,7 @@ export const disconnectDatabase = async (): Promise<void> => {
|
|
|
45
45
|
await mongoose.disconnect();
|
|
46
46
|
logger.info(' MongoDB disconnected');
|
|
47
47
|
} catch (error) {
|
|
48
|
-
logger.error(' Error disconnecting from MongoDB
|
|
48
|
+
logger.error({ err: error }, ' Error disconnecting from MongoDB');
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -59,5 +59,5 @@ mongoose.connection.on('disconnected', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
mongoose.connection.on('error', (error) => {
|
|
62
|
-
logger.error(' MongoDB connection error
|
|
62
|
+
logger.error({ err: error }, ' MongoDB connection error');
|
|
63
63
|
});
|
|
@@ -25,7 +25,7 @@ export const connectDatabase = async (): Promise<void> => {
|
|
|
25
25
|
await prisma.$connect();
|
|
26
26
|
logger.info(' PostgreSQL connected successfully (Prisma)');
|
|
27
27
|
} catch (error) {
|
|
28
|
-
logger.error(' PostgreSQL connection error
|
|
28
|
+
logger.error({ err: error }, ' PostgreSQL connection error');
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -35,7 +35,7 @@ export const disconnectDatabase = async (): Promise<void> => {
|
|
|
35
35
|
await prisma.$disconnect();
|
|
36
36
|
logger.info(' PostgreSQL disconnected');
|
|
37
37
|
} catch (error) {
|
|
38
|
-
logger.error(' Error disconnecting from PostgreSQL
|
|
38
|
+
logger.error({ err: error }, ' Error disconnecting from PostgreSQL');
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|