|
1 | | - |
2 | | - |
| 1 | +[](https://www.npmjs.com/package/setup-node-api) |
| 2 | +[](https://www.npmjs.com/package/setup-node-api) |
| 3 | +[](https://github.com/codehassoul/setup-node-api/actions/workflows/ci.yml) |
3 | 4 |
|
4 | 5 | # setup-node-api |
5 | 6 |
|
6 | | -A minimal CLI for scaffolding Node.js + Express APIs. |
| 7 | +`setup-node-api` scaffolds a minimal Node.js + Express API with sensible defaults. |
7 | 8 |
|
8 | | -Opinionated, simple, and focused on developer experience. |
| 9 | +Node.js 20.12.0 or newer is required. |
9 | 10 |
|
10 | | ---- |
| 11 | +## Features |
| 12 | + |
| 13 | +- Scaffold a ready-to-run Express API |
| 14 | +- Choose JavaScript or TypeScript |
| 15 | +- Use prompts interactively or pass CLI flags |
| 16 | +- Validate project names before generation |
| 17 | +- Avoid overwriting existing folders without confirmation |
| 18 | +- Optionally skip dependency installation |
11 | 19 |
|
12 | | -## Quick Start |
| 20 | +## Quick start |
13 | 21 |
|
14 | 22 | ```bash |
15 | 23 | npx setup-node-api my-api |
16 | 24 | ``` |
17 | 25 |
|
18 | | ---- |
| 26 | +Create a TypeScript project: |
19 | 27 |
|
20 | | -## Features |
| 28 | +```bash |
| 29 | +npx setup-node-api my-api --typescript |
| 30 | +``` |
21 | 31 |
|
22 | | -* Fast API scaffolding |
23 | | -* JavaScript and TypeScript support |
24 | | -* Interactive prompts + CLI flags |
25 | | -* Safe project creation |
26 | | -* Clean project structure |
| 32 | +Skip package installation: |
27 | 33 |
|
28 | | ---- |
| 34 | +```bash |
| 35 | +npx setup-node-api my-api --no-install |
| 36 | +``` |
29 | 37 |
|
30 | | -## Usage |
| 38 | +Set a custom port: |
31 | 39 |
|
32 | 40 | ```bash |
33 | | -setup-node-api <project-name> |
| 41 | +npx setup-node-api my-api --port 8080 |
34 | 42 | ``` |
35 | 43 |
|
36 | | -### Options |
| 44 | +## CLI usage |
37 | 45 |
|
38 | 46 | ```bash |
39 | | ---typescript |
40 | | ---no-install |
41 | | ---port <number> |
| 47 | +setup-node-api [project-name] [options] |
42 | 48 | ``` |
43 | 49 |
|
44 | | ---- |
| 50 | +### Options |
45 | 51 |
|
46 | | -## Example |
| 52 | +| Option | Description | |
| 53 | +| --- | --- | |
| 54 | +| `--typescript` | Generate the TypeScript template | |
| 55 | +| `--no-install` | Skip dependency installation | |
| 56 | +| `--port <number>` | Write a custom `PORT` value to `.env` | |
| 57 | +| `-h, --help` | Show help | |
| 58 | +| `-V, --version` | Show the installed CLI version | |
47 | 59 |
|
48 | | -```bash |
49 | | -npx setup-node-api my-api --typescript |
50 | | -``` |
| 60 | +If you omit some options, the CLI prompts for them in an interactive terminal. |
51 | 61 |
|
52 | | ---- |
| 62 | +## Generated project |
53 | 63 |
|
54 | | -## Generated Project |
| 64 | +JavaScript template: |
55 | 65 |
|
56 | 66 | ```text |
57 | 67 | my-api/ |
58 | | - |-- src/ |
59 | | - | `-- app.js / app.ts |
60 | | - |-- package.json |
61 | | - `-- .env |
| 68 | +|-- .env |
| 69 | +|-- package.json |
| 70 | +`-- src/ |
| 71 | + `-- app.js |
62 | 72 | ``` |
63 | 73 |
|
64 | | ---- |
| 74 | +TypeScript template: |
65 | 75 |
|
66 | | -## Architecture |
| 76 | +```text |
| 77 | +my-api/ |
| 78 | +|-- .env |
| 79 | +|-- package.json |
| 80 | +|-- tsconfig.json |
| 81 | +`-- src/ |
| 82 | + `-- app.ts |
| 83 | +``` |
| 84 | + |
| 85 | +## Development |
67 | 86 |
|
68 | | -* CLI layer (Commander) |
69 | | -* Core orchestration layer |
70 | | -* Services (template, install, filesystem) |
71 | | -* Prompt system + validation |
| 87 | +```bash |
| 88 | +npm install |
| 89 | +npm test |
| 90 | +``` |
72 | 91 |
|
73 | | ---- |
| 92 | +## CI |
74 | 93 |
|
75 | | -## Roadmap |
| 94 | +GitHub Actions runs the test suite on Node.js 20 and 22 across Linux, Windows, and macOS for pushes to `main` and pull requests. |
76 | 95 |
|
77 | | -* Command-based CLI (`create`, `add`, `generate`) |
78 | | -* Config file support |
79 | | -* Plugin system |
80 | | -* AI-assisted scaffolding |
| 96 | +## Notes |
81 | 97 |
|
82 | | ---- |
| 98 | +- In a non-interactive environment, provide the project name as an argument. |
| 99 | +- If the target folder already exists, the CLI stops unless you explicitly confirm overwrite in an interactive terminal. |
| 100 | +- The generated project package name is automatically set to the selected folder name. |
83 | 101 |
|
84 | 102 | ## License |
85 | 103 |
|
|
0 commit comments