You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`--typescript`| Generate the TypeScript template |
61
76
|`--no-install`| Skip dependency installation |
62
77
|`--port <number>`| Write a custom `PORT` value to `.env`|
78
+
|`--cors`| Add CORS support to the generated API |
79
+
|`-y, --yes`| Use defaults for any missing options |
63
80
|`-h, --help`| Show help |
64
81
|`-V, --version`| Show the installed CLI version |
65
82
@@ -71,8 +88,10 @@ JavaScript template:
71
88
72
89
```text
73
90
my-api/
91
+
|-- .gitignore
74
92
|-- .env
75
93
|-- package.json
94
+
|-- README.md
76
95
`-- src/
77
96
`-- app.js
78
97
```
@@ -81,14 +100,16 @@ TypeScript template:
81
100
82
101
```text
83
102
my-api/
103
+
|-- .gitignore
84
104
|-- .env
85
105
|-- package.json
106
+
|-- README.md
86
107
|-- tsconfig.json
87
108
`-- src/
88
109
`-- app.ts
89
110
```
90
111
91
-
The generated project name in `package.json` is automatically set to the selected folder name.
112
+
The generated project name in `package.json` is automatically set to the selected folder name, and the starter app includes request logging, JSON parsing, a `/health` endpoint, a `/echo` endpoint, a 404 handler, and a basic error handler.
92
113
93
114
## Examples
94
115
@@ -104,6 +125,12 @@ Create a TypeScript project and set a custom port:
104
125
setup-node-api my-api --typescript --port 4000
105
126
```
106
127
128
+
Create a JavaScript API with CORS enabled and no prompts:
129
+
130
+
```bash
131
+
setup-node-api my-api --cors --yes
132
+
```
133
+
107
134
Ask the CLI to guide you interactively:
108
135
109
136
```bash
@@ -125,7 +152,9 @@ GitHub Actions runs the test suite on Node.js 20 and 22 across Linux, Windows, a
125
152
## Notes
126
153
127
154
- In a non-interactive environment, provide the project name as an argument.
155
+
- When using `--yes`, you still need to provide the project name as an argument.
128
156
- If the target folder already exists, the CLI stops unless you explicitly confirm overwrite in an interactive terminal.
157
+
- The JavaScript template includes a `dev` script using Node's built-in watch mode.
129
158
-`prepublishOnly` runs `npm run check` before publish.
0 commit comments