create-express-kickstart 1.1.3 โ†’ 1.2.1

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/cli.js CHANGED
@@ -74,6 +74,7 @@ async function init() {
74
74
  const initDocker = (await question('๐Ÿ‘‰ Include Dockerfile & docker-compose.yml? [Y/n] ')).toLowerCase() !== 'n';
75
75
  const initAuth = (await question('๐Ÿ‘‰ Include basic JWT Auth boilerplate? [Y/n] ')).toLowerCase() !== 'n';
76
76
  const useESM = (await question('๐Ÿ‘‰ Use ECMAScript Modules (ESM) over CommonJS? [Y/n] ')).toLowerCase() !== 'n';
77
+ const initTests = (await question('๐Ÿ‘‰ Include Jest setup and boilerplate tests? [Y/n] ')).toLowerCase() !== 'n';
77
78
 
78
79
  rl.close();
79
80
 
@@ -152,6 +153,15 @@ async function init() {
152
153
  fs.appendFileSync(path.join(projectPath, '.env'), '\nJWT_SECRET=supersecretjwtkey123\n');
153
154
  }
154
155
 
156
+ if (initTests) {
157
+ console.log(`๐Ÿงช Adding Jest test templates...`);
158
+ fs.mkdirSync(path.join(projectPath, 'tests'), { recursive: true });
159
+ fs.copyFileSync(
160
+ path.join(__dirname, '..', 'templates', 'tests', 'healthcheck.test.js'),
161
+ path.join(projectPath, 'tests', 'healthcheck.test.js')
162
+ );
163
+ }
164
+
155
165
  // 3. Create package.json
156
166
  console.log(`๐Ÿ“ฆ Setting up package.json...`);
157
167
  const packageJsonTemplate = {
@@ -176,6 +186,12 @@ async function init() {
176
186
  packageJsonTemplate.scripts.format = "prettier --write \"src/**/*.{js,json}\"";
177
187
  }
178
188
 
189
+ if (initTests) {
190
+ packageJsonTemplate.scripts.test = useESM
191
+ ? "node --experimental-vm-modules node_modules/jest/bin/jest.js"
192
+ : "jest";
193
+ }
194
+
179
195
  // Write package.json
180
196
  fs.writeFileSync(
181
197
  path.join(projectPath, 'package.json'),
@@ -187,11 +203,17 @@ async function init() {
187
203
  if (deps['pino-http']) {
188
204
  dependenciesToInstall.push('pino');
189
205
  }
206
+ if (initAuth) {
207
+ dependenciesToInstall.push('jsonwebtoken', 'bcryptjs'); // Add bcryptjs too since it's standard with JWT
208
+ }
190
209
  const depString = dependenciesToInstall.join(' ');
191
210
 
192
211
  const devDependenciesToInstall = ['nodemon'];
193
212
  if (deps.prettier) devDependenciesToInstall.push('prettier');
194
213
  if (installPinoPretty) devDependenciesToInstall.push('pino-pretty');
214
+ if (initTests) {
215
+ devDependenciesToInstall.push('jest', 'supertest');
216
+ }
195
217
  const devDepString = devDependenciesToInstall.join(' ');
196
218
 
197
219
  console.log(`\nโณ Installing selected core dependencies (${dependenciesToInstall.join(', ')}). This might take a minute...`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-kickstart",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "description": "Production-ready CLI starter for Express APIs",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -0,0 +1,12 @@
1
+ import request from 'supertest';
2
+ import { app } from '../src/app.js';
3
+
4
+ describe('Healthcheck API', () => {
5
+ it('should return 200 OK', async () => {
6
+ const response = await request(app).get('/api/v1/healthcheck');
7
+
8
+ expect(response.status).toBe(200);
9
+ expect(response.body.success).toBe(true);
10
+ expect(response.body.message).toBe('Api is runing properly');
11
+ });
12
+ });