create-wabck 1.0.0 → 1.1.0
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/README.md +2 -0
- package/package.json +2 -6
- package/src/generator.js +5 -1
- package/src/index.js +4 -3
- package/src/prompts.js +10 -2
- package/src/templates/base.js +400 -387
- package/src/templates/config.js +75 -24
- package/src/templates/index.js +2 -0
- package/src/templates/routes.js +178 -12
- package/src/utils/pkg.js +10 -2
package/README.md
CHANGED
|
@@ -73,6 +73,8 @@ my-api/
|
|
|
73
73
|
| POST | `/api/v1/auth/register` | Register (JWT) |
|
|
74
74
|
| POST | `/api/v1/auth/login` | Login (JWT) |
|
|
75
75
|
| GET | `/api/v1/auth/me` | Profile (JWT) |
|
|
76
|
+
| GET | `/api-docs` | Swagger UI (Interactive Docs) |
|
|
77
|
+
| GET | `/api-docs.json` | OpenAPI 3.0 JSON Spec |
|
|
76
78
|
|
|
77
79
|
## 📜 License
|
|
78
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-wabck",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Scaffold production-ready Express.js backends in seconds",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,9 +40,5 @@
|
|
|
40
40
|
"graphql"
|
|
41
41
|
],
|
|
42
42
|
"author": "w4simz",
|
|
43
|
-
"license": "MIT"
|
|
44
|
-
"repository": {
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": ""
|
|
47
|
-
}
|
|
43
|
+
"license": "MIT"
|
|
48
44
|
}
|
package/src/generator.js
CHANGED
|
@@ -20,7 +20,7 @@ import * as T from './templates/index.js';
|
|
|
20
20
|
* @returns {Promise<string>} - Absolute path to the created project
|
|
21
21
|
*/
|
|
22
22
|
export async function generate(options) {
|
|
23
|
-
const { projectName, language, database, auth, validation, apiStyle, docker } = options;
|
|
23
|
+
const { projectName, language, database, auth, validation, apiStyle, docker, swagger } = options;
|
|
24
24
|
const isTS = language === 'typescript';
|
|
25
25
|
const ext = isTS ? 'ts' : 'js';
|
|
26
26
|
const hasDB = database !== 'none';
|
|
@@ -28,6 +28,7 @@ export async function generate(options) {
|
|
|
28
28
|
const hasJwt = auth === 'jwt';
|
|
29
29
|
const isGql = apiStyle === 'graphql';
|
|
30
30
|
const hasValidation = validation && validation !== 'none';
|
|
31
|
+
const hasSwagger = swagger === true;
|
|
31
32
|
|
|
32
33
|
const projectDir = path.resolve(process.cwd(), projectName);
|
|
33
34
|
const createdDirs = [];
|
|
@@ -107,6 +108,9 @@ export async function generate(options) {
|
|
|
107
108
|
// ── Config ────────────────────────────────────────────────────────────
|
|
108
109
|
await write(`src/config/db.${ext}`, T.db(options));
|
|
109
110
|
await write(`src/config/env.${ext}`, T.envConfig(options));
|
|
111
|
+
if (hasSwagger) {
|
|
112
|
+
await write(`src/config/swagger.${ext}`, T.swaggerConfig(options));
|
|
113
|
+
}
|
|
110
114
|
|
|
111
115
|
// ── Routes ────────────────────────────────────────────────────────────
|
|
112
116
|
await write(`src/routes/index.${ext}`, T.routesIndex(options));
|
package/src/index.js
CHANGED
|
@@ -73,10 +73,10 @@ async function main() {
|
|
|
73
73
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
74
74
|
|
|
75
75
|
function printSuccessSummary(options, projectDir) {
|
|
76
|
-
const { projectName, language, database, auth, validation, docker, packageManager, installDeps } = options;
|
|
76
|
+
const { projectName, language, database, auth, validation, docker, swagger, packageManager, installDeps } = options;
|
|
77
77
|
const pm = packageManager;
|
|
78
78
|
const relDir = path.relative(process.cwd(), projectDir) || projectName;
|
|
79
|
-
const devCmd =
|
|
79
|
+
const devCmd = `${pm} run dev`;
|
|
80
80
|
|
|
81
81
|
// Progress recap
|
|
82
82
|
log.success('Project scaffolded successfully!');
|
|
@@ -85,7 +85,8 @@ function printSuccessSummary(options, projectDir) {
|
|
|
85
85
|
log.label(' Database', database === 'none' ? 'None' : database);
|
|
86
86
|
log.label(' Auth', auth === 'none' ? 'None' : auth);
|
|
87
87
|
if (validation && validation !== 'none') log.label(' Validation', validation);
|
|
88
|
-
if (
|
|
88
|
+
if (swagger) log.label(' API Docs', 'Swagger UI → /api-docs');
|
|
89
|
+
if (docker) log.label(' Docker', 'Dockerfile + docker-compose.yml');
|
|
89
90
|
log.blank();
|
|
90
91
|
|
|
91
92
|
// Next steps
|
package/src/prompts.js
CHANGED
|
@@ -62,7 +62,7 @@ export async function runPrompts(initialName) {
|
|
|
62
62
|
choices: [
|
|
63
63
|
{ name: `${chalk.yellow('JWT')} — jsonwebtoken + bcryptjs`, value: 'jwt' },
|
|
64
64
|
{ name: `${chalk.blue('Clerk')} — @clerk/express`, value: 'clerk' },
|
|
65
|
-
{ name: `${chalk.
|
|
65
|
+
{ name: `${chalk.hex('#FFA500')('Firebase')} — firebase-admin`, value: 'firebase' },
|
|
66
66
|
{ name: `${chalk.dim('None')} — no auth`, value: 'none' },
|
|
67
67
|
],
|
|
68
68
|
});
|
|
@@ -93,12 +93,19 @@ export async function runPrompts(initialName) {
|
|
|
93
93
|
default: true,
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
// 9.
|
|
96
|
+
// 9. Swagger / OpenAPI docs
|
|
97
|
+
const swagger = await confirm({
|
|
98
|
+
message: 'Include Swagger / OpenAPI 3 docs? (served at /api-docs)',
|
|
99
|
+
default: true,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// 10. Install Dependencies
|
|
97
103
|
const installDeps = await confirm({
|
|
98
104
|
message: `Install dependencies now with ${chalk.cyan(packageManager)}?`,
|
|
99
105
|
default: true,
|
|
100
106
|
});
|
|
101
107
|
|
|
108
|
+
|
|
102
109
|
return {
|
|
103
110
|
projectName: projectName.trim(),
|
|
104
111
|
language,
|
|
@@ -108,6 +115,7 @@ export async function runPrompts(initialName) {
|
|
|
108
115
|
validation,
|
|
109
116
|
apiStyle,
|
|
110
117
|
docker,
|
|
118
|
+
swagger,
|
|
111
119
|
installDeps,
|
|
112
120
|
};
|
|
113
121
|
}
|