servcraft 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "servcraft",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "A modular, production-ready Node.js backend framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,15 +49,36 @@ export const initCommand = new Command('init')
49
49
  console.log(chalk.yellow('\n⚠ DRY RUN MODE - No files will be written\n'));
50
50
  }
51
51
 
52
+ console.log('');
53
+ console.log(chalk.cyan('╭───────────────────────────────────────╮'));
54
+ console.log(chalk.cyan('│') + ' ' + chalk.cyan('│'));
52
55
  console.log(
53
- chalk.blue(`
54
- ╔═══════════════════════════════════════════╗
55
- ║ ║
56
- ║ ${chalk.bold('🚀 Servcraft Project Generator')} ║
57
- ║ ║
58
- ╚═══════════════════════════════════════════╝
59
- `)
56
+ chalk.cyan('│') +
57
+ ' ' +
58
+ chalk.bold.white('🚀 Servcraft') +
59
+ chalk.gray(' - Project Generator') +
60
+ ' ' +
61
+ chalk.cyan('│')
60
62
  );
63
+ console.log(
64
+ chalk.cyan('│') +
65
+ ' ' +
66
+ chalk.gray('by ') +
67
+ chalk.blue('Yao Logan') +
68
+ chalk.gray(' (@Le-Sourcier)') +
69
+ ' ' +
70
+ chalk.cyan('│')
71
+ );
72
+ console.log(
73
+ chalk.cyan('│') +
74
+ ' ' +
75
+ chalk.bgBlue.white(' in/yao-logan ') +
76
+ ' ' +
77
+ chalk.cyan('│')
78
+ );
79
+ console.log(chalk.cyan('│') + ' ' + chalk.cyan('│'));
80
+ console.log(chalk.cyan('╰───────────────────────────────────────╯'));
81
+ console.log('');
61
82
 
62
83
  let options: InitOptions;
63
84
 
@@ -77,11 +98,11 @@ export const initCommand = new Command('init')
77
98
  {
78
99
  type: 'input',
79
100
  name: 'name',
80
- message: 'Project name:',
101
+ message: '📦 Project name:',
81
102
  default: name || 'my-servcraft-app',
82
103
  validate: (input: string) => {
83
104
  if (!/^[a-z0-9-_]+$/i.test(input)) {
84
- return 'Project name can only contain letters, numbers, hyphens, and underscores';
105
+ return 'Project name can only contain letters, numbers, hyphens, and underscores';
85
106
  }
86
107
  return true;
87
108
  },
@@ -89,51 +110,51 @@ export const initCommand = new Command('init')
89
110
  {
90
111
  type: 'list',
91
112
  name: 'language',
92
- message: 'Select language:',
113
+ message: '💻 Select language:',
93
114
  choices: [
94
- { name: 'TypeScript (Recommended)', value: 'typescript' },
95
- { name: 'JavaScript', value: 'javascript' },
115
+ { name: 'TypeScript (Recommended)', value: 'typescript' },
116
+ { name: ' JavaScript', value: 'javascript' },
96
117
  ],
97
118
  default: 'typescript',
98
119
  },
99
120
  {
100
121
  type: 'list',
101
122
  name: 'moduleSystem',
102
- message: 'Select module system:',
123
+ message: '📦 Select module system:',
103
124
  choices: [
104
- { name: 'ESM (import/export) - Recommended', value: 'esm' },
105
- { name: 'CommonJS (require/module.exports)', value: 'commonjs' },
125
+ { name: 'ESM (import/export) - Recommended', value: 'esm' },
126
+ { name: ' CommonJS (require/module.exports)', value: 'commonjs' },
106
127
  ],
107
128
  default: 'esm',
108
129
  },
109
130
  {
110
131
  type: 'list',
111
132
  name: 'database',
112
- message: 'Select database:',
133
+ message: '🗄️ Select database:',
113
134
  choices: [
114
- { name: 'PostgreSQL (Recommended for SQL)', value: 'postgresql' },
115
- { name: 'MySQL', value: 'mysql' },
116
- { name: 'SQLite (Development)', value: 'sqlite' },
117
- { name: 'MongoDB (NoSQL)', value: 'mongodb' },
118
- { name: 'None (Add later)', value: 'none' },
135
+ { name: 'PostgreSQL (Recommended)', value: 'postgresql' },
136
+ { name: ' MySQL', value: 'mysql' },
137
+ { name: ' SQLite (Development)', value: 'sqlite' },
138
+ { name: ' MongoDB (NoSQL)', value: 'mongodb' },
139
+ { name: ' None (Add later)', value: 'none' },
119
140
  ],
120
141
  default: 'postgresql',
121
142
  },
122
143
  {
123
144
  type: 'list',
124
145
  name: 'validator',
125
- message: 'Select validation library:',
146
+ message: 'Select validation library:',
126
147
  choices: [
127
- { name: 'Zod (Recommended - TypeScript-first)', value: 'zod' },
128
- { name: 'Joi (Battle-tested, feature-rich)', value: 'joi' },
129
- { name: 'Yup (Inspired by Joi, lighter)', value: 'yup' },
148
+ { name: 'Zod (TypeScript-first)', value: 'zod' },
149
+ { name: ' Joi (Battle-tested)', value: 'joi' },
150
+ { name: ' Yup (Lightweight)', value: 'yup' },
130
151
  ],
131
152
  default: 'zod',
132
153
  },
133
154
  {
134
155
  type: 'checkbox',
135
156
  name: 'features',
136
- message: 'Select features to include:',
157
+ message: '🔧 Select features to include:',
137
158
  choices: [
138
159
  { name: 'Authentication (JWT)', value: 'auth', checked: true },
139
160
  { name: 'User Management', value: 'users', checked: true },
@@ -13,12 +13,21 @@ const prismaClientSingleton = (): PrismaClient => {
13
13
  });
14
14
  };
15
15
 
16
- // Use singleton pattern to prevent multiple instances in development
17
- export const prisma = globalThis.__prisma ?? prismaClientSingleton();
18
-
19
- if (!isProduction()) {
20
- globalThis.__prisma = prisma;
21
- }
16
+ // Lazy initialization - only create client when accessed
17
+ let _prisma: PrismaClient | undefined;
18
+
19
+ export const prisma = new Proxy({} as PrismaClient, {
20
+ get(target, prop) {
21
+ // Initialize on first access
22
+ if (!_prisma) {
23
+ _prisma = globalThis.__prisma ?? prismaClientSingleton();
24
+ if (!isProduction()) {
25
+ globalThis.__prisma = _prisma;
26
+ }
27
+ }
28
+ return (_prisma as any)[prop];
29
+ },
30
+ });
22
31
 
23
32
  export async function connectDatabase(): Promise<void> {
24
33
  try {