rapidkit 0.11.2 → 0.12.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 +99 -408
- package/dist/index.js +508 -279
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/templates/generator.js +175 -0
- package/templates/kits/fastapi-standard/.rapidkit/__init__.py.j2 +1 -0
- package/templates/kits/fastapi-standard/.rapidkit/activate.j2 +24 -0
- package/templates/kits/fastapi-standard/.rapidkit/cli.py.j2 +257 -0
- package/templates/kits/fastapi-standard/.rapidkit/project.json.j2 +7 -0
- package/templates/kits/fastapi-standard/.rapidkit/rapidkit.j2 +98 -0
- package/templates/kits/fastapi-standard/Makefile.j2 +41 -0
- package/templates/kits/fastapi-standard/README.md.j2 +4 -4
- package/templates/kits/fastapi-standard/pyproject.toml.j2 +1 -0
- package/templates/kits/fastapi-standard/rapidkit.j2 +50 -0
- package/templates/kits/fastapi-standard/src/main.py.j2 +15 -12
- package/templates/kits/nestjs-standard/.env.example.j2 +16 -0
- package/templates/kits/nestjs-standard/.eslintrc.js.j2 +25 -0
- package/templates/kits/nestjs-standard/.gitignore.j2 +26 -0
- package/templates/kits/nestjs-standard/.node-version.j2 +1 -0
- package/templates/kits/nestjs-standard/.nvmrc.j2 +1 -0
- package/templates/kits/nestjs-standard/.prettierrc.j2 +7 -0
- package/templates/kits/nestjs-standard/.rapidkit/activate.j2 +25 -0
- package/templates/kits/nestjs-standard/.rapidkit/project.json.j2 +7 -0
- package/templates/kits/nestjs-standard/.rapidkit/rapidkit.j2 +227 -0
- package/templates/kits/nestjs-standard/README.md.j2 +97 -0
- package/templates/kits/nestjs-standard/jest.config.ts.j2 +21 -0
- package/templates/kits/nestjs-standard/nest-cli.json.j2 +10 -0
- package/templates/kits/nestjs-standard/package.json.j2 +75 -0
- package/templates/kits/nestjs-standard/rapidkit.j2 +5 -0
- package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +12 -0
- package/templates/kits/nestjs-standard/src/app.module.ts.j2 +23 -0
- package/templates/kits/nestjs-standard/src/app.service.ts.j2 +11 -0
- package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +9 -0
- package/templates/kits/nestjs-standard/src/config/index.ts.j2 +2 -0
- package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +11 -0
- package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +11 -0
- package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +24 -0
- package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +10 -0
- package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +33 -0
- package/templates/kits/nestjs-standard/src/main.ts.j2 +51 -0
- package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +3 -0
- package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +22 -0
- package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +48 -0
- package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +28 -0
- package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +15 -0
- package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +12 -0
- package/templates/kits/nestjs-standard/tsconfig.json.j2 +26 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# RapidKit CLI - Local project commands
|
|
3
|
+
# This wrapper delegates to .rapidkit/cli.py with smart Python detection
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
CLI_PY="${SCRIPT_DIR}/.rapidkit/cli.py"
|
|
9
|
+
|
|
10
|
+
# Find the best Python to use
|
|
11
|
+
find_python() {
|
|
12
|
+
# 1. Project venv
|
|
13
|
+
if [ -x "${SCRIPT_DIR}/.venv/bin/python" ]; then
|
|
14
|
+
echo "${SCRIPT_DIR}/.venv/bin/python"
|
|
15
|
+
return 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# 2. Poetry's python
|
|
19
|
+
if command -v poetry >/dev/null 2>&1; then
|
|
20
|
+
POETRY_PY="$(poetry env info --executable 2>/dev/null || true)"
|
|
21
|
+
if [ -n "$POETRY_PY" ] && [ -x "$POETRY_PY" ]; then
|
|
22
|
+
echo "$POETRY_PY"
|
|
23
|
+
return 0
|
|
24
|
+
fi
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# 3. System python3
|
|
28
|
+
if command -v python3 >/dev/null 2>&1; then
|
|
29
|
+
echo "python3"
|
|
30
|
+
return 0
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# 4. System python
|
|
34
|
+
if command -v python >/dev/null 2>&1; then
|
|
35
|
+
echo "python"
|
|
36
|
+
return 0
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Find Python
|
|
43
|
+
PYTHON_CMD="$(find_python)" || {
|
|
44
|
+
echo "❌ No Python interpreter found."
|
|
45
|
+
echo "💡 Install Python 3.11+ and try again."
|
|
46
|
+
exit 127
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# Execute the CLI
|
|
50
|
+
exec "$PYTHON_CMD" "$CLI_PY" "$@"
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from contextlib import asynccontextmanager
|
|
6
|
+
from typing import AsyncIterator
|
|
7
|
+
|
|
5
8
|
from fastapi import FastAPI
|
|
6
9
|
from fastapi.middleware.cors import CORSMiddleware
|
|
7
10
|
|
|
@@ -9,12 +12,24 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
|
9
12
|
|
|
10
13
|
from .routing import api_router
|
|
11
14
|
|
|
15
|
+
|
|
16
|
+
@asynccontextmanager
|
|
17
|
+
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|
18
|
+
"""Application lifespan context manager for startup/shutdown events."""
|
|
19
|
+
# Startup
|
|
20
|
+
# <<<inject:startup>>>
|
|
21
|
+
yield
|
|
22
|
+
# Shutdown
|
|
23
|
+
# <<<inject:shutdown>>>
|
|
24
|
+
|
|
25
|
+
|
|
12
26
|
app = FastAPI(
|
|
13
27
|
title="{{ project_name }}",
|
|
14
28
|
description="{{ description }}",
|
|
15
29
|
version="{{ app_version }}",
|
|
16
30
|
docs_url="/docs",
|
|
17
31
|
redoc_url="/redoc",
|
|
32
|
+
lifespan=lifespan,
|
|
18
33
|
)
|
|
19
34
|
|
|
20
35
|
app.add_middleware(
|
|
@@ -27,15 +42,3 @@ app.add_middleware(
|
|
|
27
42
|
|
|
28
43
|
app.include_router(api_router, prefix="/api")
|
|
29
44
|
# <<<inject:routes>>>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@app.on_event("startup")
|
|
33
|
-
async def _on_startup() -> None:
|
|
34
|
-
"""Execute startup hooks provided by modules."""
|
|
35
|
-
# <<<inject:startup>>>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@app.on_event("shutdown")
|
|
39
|
-
async def _on_shutdown() -> None:
|
|
40
|
-
"""Execute shutdown hooks provided by modules."""
|
|
41
|
-
# <<<inject:shutdown>>>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Application
|
|
2
|
+
APP_NAME={{ project_name | upper | replace('-', '_') }}
|
|
3
|
+
PORT=8000
|
|
4
|
+
HOST=0.0.0.0
|
|
5
|
+
NODE_ENV=development
|
|
6
|
+
|
|
7
|
+
# Security
|
|
8
|
+
JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
|
9
|
+
JWT_EXPIRATION=1h
|
|
10
|
+
|
|
11
|
+
# Database (optional)
|
|
12
|
+
# DATABASE_URL=postgresql://user:password@localhost:5432/{{ project_name | replace('-', '_') }}
|
|
13
|
+
|
|
14
|
+
# Redis (optional)
|
|
15
|
+
# REDIS_HOST=localhost
|
|
16
|
+
# REDIS_PORT=6379
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: ['tsconfig.json'],
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Node artifacts
|
|
2
|
+
node_modules/
|
|
3
|
+
dist/
|
|
4
|
+
.tmp/
|
|
5
|
+
.env
|
|
6
|
+
.env.*
|
|
7
|
+
!.env.example
|
|
8
|
+
|
|
9
|
+
# Logs
|
|
10
|
+
logs/
|
|
11
|
+
*.log
|
|
12
|
+
npm-debug.log*
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
pnpm-debug.log*
|
|
16
|
+
|
|
17
|
+
# OS
|
|
18
|
+
.DS_Store
|
|
19
|
+
Thumbs.db
|
|
20
|
+
|
|
21
|
+
# IDEs
|
|
22
|
+
.idea/
|
|
23
|
+
.vscode/
|
|
24
|
+
|
|
25
|
+
# Coverage
|
|
26
|
+
coverage/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# RapidKit Environment Activation
|
|
3
|
+
# Usage: source .rapidkit/activate
|
|
4
|
+
|
|
5
|
+
# Get the directory where this script is located
|
|
6
|
+
RAPIDKIT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
PROJECT_ROOT="$(dirname "$RAPIDKIT_DIR")"
|
|
8
|
+
|
|
9
|
+
# Add project root to PATH (where rapidkit script lives)
|
|
10
|
+
if [[ ":$PATH:" != *":$PROJECT_ROOT:"* ]]; then
|
|
11
|
+
export PATH="$PROJECT_ROOT:$PATH"
|
|
12
|
+
echo "✅ RapidKit activated! You can now use 'rapidkit' commands directly."
|
|
13
|
+
else
|
|
14
|
+
echo "ℹ️ RapidKit already activated."
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Show available commands
|
|
18
|
+
echo ""
|
|
19
|
+
echo "📚 Available commands:"
|
|
20
|
+
echo " rapidkit dev - Start development server"
|
|
21
|
+
echo " rapidkit init - Install dependencies"
|
|
22
|
+
echo " rapidkit build - Build for production"
|
|
23
|
+
echo " rapidkit test - Run tests"
|
|
24
|
+
echo " rapidkit --help - Show all commands"
|
|
25
|
+
echo ""
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# RapidKit CLI wrapper for NestJS projects (npm demo template)
|
|
3
|
+
# This script provides local commands that mirror the full RapidKit engine.
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
8
|
+
cd "$PROJECT_ROOT"
|
|
9
|
+
|
|
10
|
+
print_banner() {
|
|
11
|
+
local emoji="$1"
|
|
12
|
+
local message="$2"
|
|
13
|
+
echo "$emoji $message"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
check_node() {
|
|
17
|
+
if ! command -v node &> /dev/null; then
|
|
18
|
+
echo "❌ Node.js not found. Please install Node.js first."
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
check_npm_or_pnpm() {
|
|
24
|
+
if command -v pnpm &> /dev/null; then
|
|
25
|
+
echo "pnpm"
|
|
26
|
+
elif command -v npm &> /dev/null; then
|
|
27
|
+
echo "npm"
|
|
28
|
+
else
|
|
29
|
+
echo "❌ Neither npm nor pnpm found. Please install Node.js first."
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
cmd_init() {
|
|
35
|
+
print_banner "📦" "Bootstrapping NestJS project (installing dependencies)"
|
|
36
|
+
check_node
|
|
37
|
+
|
|
38
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
39
|
+
|
|
40
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
41
|
+
pnpm install
|
|
42
|
+
else
|
|
43
|
+
npm install
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
echo "✅ Dependencies installed successfully!"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
cmd_dev() {
|
|
50
|
+
local port="${1:-8000}"
|
|
51
|
+
local host="${2:-0.0.0.0}"
|
|
52
|
+
|
|
53
|
+
print_banner "🚀" "Starting NestJS development server with hot reload..."
|
|
54
|
+
check_node
|
|
55
|
+
|
|
56
|
+
if [ ! -d "node_modules" ]; then
|
|
57
|
+
echo "❌ node_modules not found. Run 'rapidkit init' first."
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
62
|
+
|
|
63
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
64
|
+
PORT="$port" HOST="$host" pnpm run start:dev
|
|
65
|
+
else
|
|
66
|
+
PORT="$port" HOST="$host" npm run start:dev
|
|
67
|
+
fi
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cmd_start() {
|
|
71
|
+
local port="${1:-8000}"
|
|
72
|
+
local host="${2:-0.0.0.0}"
|
|
73
|
+
|
|
74
|
+
print_banner "⚡" "Starting NestJS production server..."
|
|
75
|
+
check_node
|
|
76
|
+
|
|
77
|
+
if [ ! -d "node_modules" ]; then
|
|
78
|
+
echo "❌ node_modules not found. Run 'rapidkit init' first."
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
83
|
+
|
|
84
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
85
|
+
PORT="$port" HOST="$host" pnpm run start:prod
|
|
86
|
+
else
|
|
87
|
+
PORT="$port" HOST="$host" npm run start:prod
|
|
88
|
+
fi
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
cmd_build() {
|
|
92
|
+
print_banner "📦" "Building NestJS project..."
|
|
93
|
+
check_node
|
|
94
|
+
|
|
95
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
96
|
+
|
|
97
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
98
|
+
pnpm run build
|
|
99
|
+
else
|
|
100
|
+
npm run build
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
echo "✅ Build completed!"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
cmd_test() {
|
|
107
|
+
print_banner "🧪" "Running tests..."
|
|
108
|
+
check_node
|
|
109
|
+
|
|
110
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
111
|
+
|
|
112
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
113
|
+
pnpm run test
|
|
114
|
+
else
|
|
115
|
+
npm run test
|
|
116
|
+
fi
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
cmd_lint() {
|
|
120
|
+
print_banner "🔧" "Running ESLint..."
|
|
121
|
+
check_node
|
|
122
|
+
|
|
123
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
124
|
+
|
|
125
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
126
|
+
pnpm run lint
|
|
127
|
+
else
|
|
128
|
+
npm run lint
|
|
129
|
+
fi
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
cmd_format() {
|
|
133
|
+
print_banner "✨" "Formatting code with Prettier..."
|
|
134
|
+
check_node
|
|
135
|
+
|
|
136
|
+
local pkg_manager=$(check_npm_or_pnpm)
|
|
137
|
+
|
|
138
|
+
if [ "$pkg_manager" = "pnpm" ]; then
|
|
139
|
+
pnpm run format
|
|
140
|
+
else
|
|
141
|
+
npm run format
|
|
142
|
+
fi
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
cmd_help() {
|
|
146
|
+
print_banner "📚" "RapidKit NestJS Project Commands"
|
|
147
|
+
echo ""
|
|
148
|
+
echo "Usage: rapidkit <command> [options]"
|
|
149
|
+
echo ""
|
|
150
|
+
echo "Commands:"
|
|
151
|
+
echo " init 📦 Initialize project (install dependencies)"
|
|
152
|
+
echo " dev 🚀 Start development server with hot reload"
|
|
153
|
+
echo " start ⚡ Start production server"
|
|
154
|
+
echo " build 📦 Build for production"
|
|
155
|
+
echo " test 🧪 Run tests"
|
|
156
|
+
echo " lint 🔧 Lint code"
|
|
157
|
+
echo " format ✨ Format code"
|
|
158
|
+
echo " help 📚 Show this help"
|
|
159
|
+
echo ""
|
|
160
|
+
echo "Options for dev/start:"
|
|
161
|
+
echo " -p, --port <port> Port number (default: 8000)"
|
|
162
|
+
echo " --host <host> Host address (default: 0.0.0.0)"
|
|
163
|
+
echo ""
|
|
164
|
+
echo "💡 Note: This is a demo project. For full RapidKit features:"
|
|
165
|
+
echo " pipx install rapidkit"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# Parse command
|
|
169
|
+
COMMAND="${1:-help}"
|
|
170
|
+
shift || true
|
|
171
|
+
|
|
172
|
+
# Parse options
|
|
173
|
+
PORT="8000"
|
|
174
|
+
HOST="0.0.0.0"
|
|
175
|
+
|
|
176
|
+
while [[ $# -gt 0 ]]; do
|
|
177
|
+
case $1 in
|
|
178
|
+
-p|--port)
|
|
179
|
+
PORT="$2"
|
|
180
|
+
shift 2
|
|
181
|
+
;;
|
|
182
|
+
--host)
|
|
183
|
+
HOST="$2"
|
|
184
|
+
shift 2
|
|
185
|
+
;;
|
|
186
|
+
-h|--help)
|
|
187
|
+
cmd_help
|
|
188
|
+
exit 0
|
|
189
|
+
;;
|
|
190
|
+
*)
|
|
191
|
+
shift
|
|
192
|
+
;;
|
|
193
|
+
esac
|
|
194
|
+
done
|
|
195
|
+
|
|
196
|
+
case "$COMMAND" in
|
|
197
|
+
init)
|
|
198
|
+
cmd_init
|
|
199
|
+
;;
|
|
200
|
+
dev)
|
|
201
|
+
cmd_dev "$PORT" "$HOST"
|
|
202
|
+
;;
|
|
203
|
+
start)
|
|
204
|
+
cmd_start "$PORT" "$HOST"
|
|
205
|
+
;;
|
|
206
|
+
build)
|
|
207
|
+
cmd_build
|
|
208
|
+
;;
|
|
209
|
+
test)
|
|
210
|
+
cmd_test
|
|
211
|
+
;;
|
|
212
|
+
lint)
|
|
213
|
+
cmd_lint
|
|
214
|
+
;;
|
|
215
|
+
format)
|
|
216
|
+
cmd_format
|
|
217
|
+
;;
|
|
218
|
+
help|-h|--help)
|
|
219
|
+
cmd_help
|
|
220
|
+
;;
|
|
221
|
+
*)
|
|
222
|
+
echo "❌ Unknown command: $COMMAND"
|
|
223
|
+
echo ""
|
|
224
|
+
cmd_help
|
|
225
|
+
exit 1
|
|
226
|
+
;;
|
|
227
|
+
esac
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# {{ project_name | replace('-', ' ') | title }}
|
|
2
|
+
|
|
3
|
+
{{ description }}
|
|
4
|
+
|
|
5
|
+
A production-ready NestJS 11 application generated with RapidKit.
|
|
6
|
+
|
|
7
|
+
## 🚀 Getting Started
|
|
8
|
+
|
|
9
|
+
### Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js >= 20 (check with `node --version`)
|
|
12
|
+
- {{ package_manager }} package manager
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install dependencies
|
|
18
|
+
{{ package_manager }} install
|
|
19
|
+
|
|
20
|
+
# Copy environment file
|
|
21
|
+
cp .env.example .env
|
|
22
|
+
|
|
23
|
+
# Start development server
|
|
24
|
+
{{ package_manager }} run dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Your API will be available at `http://localhost:8000`
|
|
28
|
+
API docs available at `http://localhost:8000/docs`
|
|
29
|
+
|
|
30
|
+
## 📚 Available Scripts
|
|
31
|
+
|
|
32
|
+
| Command | Description |
|
|
33
|
+
|---------|-------------|
|
|
34
|
+
| `{{ package_manager }} run dev` | Start development server with hot reload |
|
|
35
|
+
| `{{ package_manager }} run build` | Build for production |
|
|
36
|
+
| `{{ package_manager }} start` | Start production server |
|
|
37
|
+
| `{{ package_manager }} test` | Run unit tests |
|
|
38
|
+
| `{{ package_manager }} run test:e2e` | Run e2e tests |
|
|
39
|
+
| `{{ package_manager }} run test:cov` | Run tests with coverage |
|
|
40
|
+
| `{{ package_manager }} run lint` | Lint and fix code |
|
|
41
|
+
| `{{ package_manager }} run format` | Format code with Prettier |
|
|
42
|
+
|
|
43
|
+
## 📁 Project Structure
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
{{ project_name }}/
|
|
47
|
+
├── src/
|
|
48
|
+
│ ├── main.ts # Application entry point
|
|
49
|
+
│ ├── app.module.ts # Root module
|
|
50
|
+
│ ├── app.controller.ts # Root controller
|
|
51
|
+
│ ├── app.service.ts # Root service
|
|
52
|
+
│ ├── config/ # Configuration module
|
|
53
|
+
│ ├── examples/ # Example feature module
|
|
54
|
+
│ └── modules/ # RapidKit modules
|
|
55
|
+
├── test/ # Test files
|
|
56
|
+
├── package.json # Dependencies
|
|
57
|
+
├── tsconfig.json # TypeScript config
|
|
58
|
+
└── nest-cli.json # NestJS CLI config
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 🔧 Configuration
|
|
62
|
+
|
|
63
|
+
Environment variables are managed through `.env` file:
|
|
64
|
+
|
|
65
|
+
- `APP_NAME` - Application name
|
|
66
|
+
- `PORT` - Server port (default: 8000)
|
|
67
|
+
- `HOST` - Server host (default: 0.0.0.0)
|
|
68
|
+
- `NODE_ENV` - Environment (development/production/test)
|
|
69
|
+
|
|
70
|
+
## 🧪 Example API
|
|
71
|
+
|
|
72
|
+
The scaffold includes an example Notes API:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Create a note
|
|
76
|
+
curl -X POST http://localhost:8000/examples/notes \
|
|
77
|
+
-H "Content-Type: application/json" \
|
|
78
|
+
-d '{"title":"Hello","body":"World"}'
|
|
79
|
+
|
|
80
|
+
# List all notes
|
|
81
|
+
curl http://localhost:8000/examples/notes
|
|
82
|
+
|
|
83
|
+
# Get health status
|
|
84
|
+
curl http://localhost:8000/health
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 📖 Learn More
|
|
88
|
+
|
|
89
|
+
- [NestJS Documentation](https://docs.nestjs.com)
|
|
90
|
+
- [RapidKit Documentation](https://rapidkit.top)
|
|
91
|
+
|
|
92
|
+
## 📄 License
|
|
93
|
+
|
|
94
|
+
This project is licensed under the {{ license }} License.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
Generated with ❤️ by RapidKit
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
const config: Config = {
|
|
4
|
+
moduleFileExtensions: ['js', 'json', 'ts'],
|
|
5
|
+
rootDir: '.',
|
|
6
|
+
testEnvironment: 'node',
|
|
7
|
+
testRegex: '.*\\.spec.ts$',
|
|
8
|
+
transform: {
|
|
9
|
+
'^.+\\.ts$': 'ts-jest',
|
|
10
|
+
},
|
|
11
|
+
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.module.ts'],
|
|
12
|
+
coverageDirectory: './coverage',
|
|
13
|
+
moduleNameMapper: {
|
|
14
|
+
'^@config/(.*)$': '<rootDir>/src/config/$1',
|
|
15
|
+
'^@modules/(.*)$': '<rootDir>/src/modules/$1',
|
|
16
|
+
'^@shared/(.*)$': '<rootDir>/src/shared/$1',
|
|
17
|
+
},
|
|
18
|
+
setupFiles: ['dotenv/config'],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default config;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ project_name | replace('_', '-') | lower }}",
|
|
3
|
+
"version": "{{ app_version }}",
|
|
4
|
+
"description": "{{ description }}",
|
|
5
|
+
"license": "{{ license }}",
|
|
6
|
+
"author": "{{ author }}",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"private": true,
|
|
11
|
+
"scripts": {
|
|
12
|
+
"rapidkit": "./.rapidkit/rapidkit",
|
|
13
|
+
"rapidkit:init": "npm install",
|
|
14
|
+
"rapidkit:dev": "./.rapidkit/rapidkit dev",
|
|
15
|
+
"rapidkit:start": "./.rapidkit/rapidkit start",
|
|
16
|
+
"rapidkit:build": "./.rapidkit/rapidkit build",
|
|
17
|
+
"rapidkit:test": "./.rapidkit/rapidkit test",
|
|
18
|
+
"rapidkit:lint": "./.rapidkit/rapidkit lint",
|
|
19
|
+
"rapidkit:format": "./.rapidkit/rapidkit format",
|
|
20
|
+
"start": "node dist/main",
|
|
21
|
+
"dev": "nest start --watch",
|
|
22
|
+
"start:dev": "nest start --watch",
|
|
23
|
+
"start:debug": "nest start --debug --watch",
|
|
24
|
+
"start:prod": "node dist/main",
|
|
25
|
+
"build": "nest build",
|
|
26
|
+
"lint": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
27
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch",
|
|
30
|
+
"test:cov": "jest --coverage",
|
|
31
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@nestjs/common": "^11.1.6",
|
|
35
|
+
"@nestjs/config": "^4.0.2",
|
|
36
|
+
"@nestjs/core": "^11.1.6",
|
|
37
|
+
"@nestjs/platform-express": "^11.1.6",
|
|
38
|
+
"@nestjs/swagger": "^11.2.3",
|
|
39
|
+
"class-transformer": "^0.5.1",
|
|
40
|
+
"class-validator": "^0.14.0",
|
|
41
|
+
"reflect-metadata": "^0.2.1",
|
|
42
|
+
"rxjs": "^7.8.1",
|
|
43
|
+
"helmet": "^7.0.0",
|
|
44
|
+
"compression": "^1.7.4",
|
|
45
|
+
"winston": "^3.11.0",
|
|
46
|
+
"joi": "^17.12.1",
|
|
47
|
+
"@nestjs/terminus": "^11.0.0",
|
|
48
|
+
"dotenv": "^16.3.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@nestjs/cli": "^11.0.10",
|
|
52
|
+
"@nestjs/schematics": "^11.0.7",
|
|
53
|
+
"@nestjs/testing": "^11.1.6",
|
|
54
|
+
"@types/compression": "^1.7.5",
|
|
55
|
+
"@types/express": "^4.17.21",
|
|
56
|
+
"@types/jest": "^29.5.12",
|
|
57
|
+
"@types/node": "^22.8.5",
|
|
58
|
+
"@types/supertest": "^2.0.16",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
60
|
+
"@typescript-eslint/parser": "^8.46.1",
|
|
61
|
+
"eslint": "^8.57.1",
|
|
62
|
+
"eslint-config-prettier": "^10.1.8",
|
|
63
|
+
"eslint-plugin-import": "^2.32.0",
|
|
64
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
65
|
+
"jest": "^29.7.0",
|
|
66
|
+
"prettier": "^3.6.2",
|
|
67
|
+
"source-map-support": "^0.5.21",
|
|
68
|
+
"supertest": "^7.1.4",
|
|
69
|
+
"ts-jest": "^29.4.5",
|
|
70
|
+
"ts-loader": "^9.5.4",
|
|
71
|
+
"ts-node": "^10.9.2",
|
|
72
|
+
"tsconfig-paths": "^4.2.0",
|
|
73
|
+
"typescript": "^5.9.3"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Controller, Get } from '@nestjs/common';
|
|
2
|
+
import { AppService } from './app.service';
|
|
3
|
+
|
|
4
|
+
@Controller()
|
|
5
|
+
export class AppController {
|
|
6
|
+
constructor(private readonly appService: AppService) {}
|
|
7
|
+
|
|
8
|
+
@Get('health')
|
|
9
|
+
getHealth() {
|
|
10
|
+
return this.appService.getHealth();
|
|
11
|
+
}
|
|
12
|
+
}
|