stackkit 0.3.0 → 0.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stackkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Production-ready CLI to create and extend JavaScript or TypeScript apps with modular stacks.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -80,4 +80,4 @@
|
|
|
80
80
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
81
81
|
"typescript": "^5.3.3"
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|
|
@@ -31,6 +31,87 @@ npm run dev
|
|
|
31
31
|
|
|
32
32
|
Use a `.env` file or environment variables for configuration. See `.env.example` for available keys.
|
|
33
33
|
|
|
34
|
+
## Recommended Folder & File Structure
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
express-api/
|
|
38
|
+
├── src/
|
|
39
|
+
│ ├── app.ts
|
|
40
|
+
│ ├── server.ts
|
|
41
|
+
│
|
|
42
|
+
│ ├── config/
|
|
43
|
+
│ │ ├── env.ts
|
|
44
|
+
│ │ ├── cors.ts
|
|
45
|
+
│ │ ├── rateLimit.ts
|
|
46
|
+
│ │ └── logger.ts # (optional)
|
|
47
|
+
│
|
|
48
|
+
│ ├── database/
|
|
49
|
+
│ │ └── prisma.ts # PrismaClient singleton
|
|
50
|
+
│
|
|
51
|
+
│ ├── lib/
|
|
52
|
+
│ └── auth.ts # Auth server config
|
|
53
|
+
│
|
|
54
|
+
│ ├── shared/
|
|
55
|
+
│ │ ├── middlewares/
|
|
56
|
+
│ │ │ ├── authorize.middleware.ts # reads session + attaches req.user
|
|
57
|
+
│ │ │ ├── error.middleware.ts
|
|
58
|
+
│ │ │ └── notFound.middleware.ts
|
|
59
|
+
│ │ ├── errors/
|
|
60
|
+
│ │ │ ├── ApiError.ts
|
|
61
|
+
│ │ │ └── errorCodes.ts
|
|
62
|
+
│ │ ├── utils/
|
|
63
|
+
│ │ │ ├── catchAsync.ts
|
|
64
|
+
│ │ │ ├── sendResponse.ts
|
|
65
|
+
│ │ │ └── pagination.ts
|
|
66
|
+
│ │ └── logger/
|
|
67
|
+
│ │ └── logger.ts
|
|
68
|
+
│
|
|
69
|
+
│ ├── modules/
|
|
70
|
+
│ │ ├── auth/
|
|
71
|
+
│ │ │ ├── auth.routes.ts
|
|
72
|
+
│ │ │ ├── auth.controller.ts
|
|
73
|
+
│ │ │ ├── auth.service.ts
|
|
74
|
+
│ │ │ ├── auth.validator.ts
|
|
75
|
+
│ │ │ └── auth.types.ts
|
|
76
|
+
│ │ ├── users/
|
|
77
|
+
│ │ │ ├── users.routes.ts
|
|
78
|
+
│ │ │ ├── users.controller.ts
|
|
79
|
+
│ │ │ ├── users.service.ts
|
|
80
|
+
│ │ │ ├── users.repository.ts
|
|
81
|
+
│ │ │ ├── users.validator.ts
|
|
82
|
+
│ │ │ └── users.types.ts
|
|
83
|
+
│ │ └── products/
|
|
84
|
+
│ │ ├── products.routes.ts
|
|
85
|
+
│ │ ├── products.controller.ts
|
|
86
|
+
│ │ ├── products.service.ts
|
|
87
|
+
│ │ ├── products.repository.ts
|
|
88
|
+
│ │ ├── products.validator.ts
|
|
89
|
+
│ │ └── products.types.ts
|
|
90
|
+
│
|
|
91
|
+
│ ├── routes/
|
|
92
|
+
│ │ └── index.ts # mounts all module routes
|
|
93
|
+
│ │
|
|
94
|
+
│ └── types/
|
|
95
|
+
│ └── express.d.ts # Request typing (req.user)
|
|
96
|
+
│
|
|
97
|
+
├── prisma/
|
|
98
|
+
│ ├── schema.prisma
|
|
99
|
+
│ ├── migrations/
|
|
100
|
+
│ └── seed.ts
|
|
101
|
+
│
|
|
102
|
+
├── tests/
|
|
103
|
+
│ ├── unit/
|
|
104
|
+
│ └── integration/
|
|
105
|
+
│
|
|
106
|
+
├── Dockerfile
|
|
107
|
+
├── docker-compose.yml
|
|
108
|
+
├── package.json
|
|
109
|
+
├── tsconfig.json
|
|
110
|
+
├── eslint.config.js
|
|
111
|
+
├── .env.example
|
|
112
|
+
└── README.md
|
|
113
|
+
```
|
|
114
|
+
|
|
34
115
|
---
|
|
35
116
|
|
|
36
117
|
## Generated with StackKit
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { Server } from "http";
|
|
1
2
|
import { app } from "./app";
|
|
2
3
|
import { envVars } from "./config/env";
|
|
3
4
|
|
|
5
|
+
let server: Server | null = null;
|
|
6
|
+
|
|
4
7
|
const bootstrap = async () => {
|
|
5
8
|
try {
|
|
6
|
-
app.listen(envVars.PORT, () => {
|
|
9
|
+
server = app.listen(envVars.PORT, () => {
|
|
7
10
|
console.log(`Server is running on http://localhost:${envVars.PORT}`);
|
|
8
11
|
});
|
|
9
12
|
} catch (error) {
|
|
@@ -11,4 +14,50 @@ const bootstrap = async () => {
|
|
|
11
14
|
}
|
|
12
15
|
};
|
|
13
16
|
|
|
17
|
+
process.on("SIGTERM", () => {
|
|
18
|
+
console.log("SIGTERM signal received: closing HTTP server");
|
|
19
|
+
if (server) {
|
|
20
|
+
server.close(() => {
|
|
21
|
+
console.log("HTTP server closed");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
process.on("SIGINT", () => {
|
|
29
|
+
console.log("SIGINT signal received: closing HTTP server");
|
|
30
|
+
if (server) {
|
|
31
|
+
server.close(() => {
|
|
32
|
+
console.log("HTTP server closed");
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
process.exit(0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
process.on("uncaughtException", (err) => {
|
|
40
|
+
console.error("Uncaught Exception:", err);
|
|
41
|
+
|
|
42
|
+
if (server) {
|
|
43
|
+
server.close(() => {
|
|
44
|
+
console.log("HTTP server closed due to uncaught exception");
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.exit(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
52
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
53
|
+
|
|
54
|
+
if (server) {
|
|
55
|
+
server.close(() => {
|
|
56
|
+
console.log("HTTP server closed due to unhandled rejection");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
14
63
|
bootstrap();
|
|
@@ -50,6 +50,102 @@ lib/
|
|
|
50
50
|
public/ # Static assets
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## Recommended Folder & File Structure
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
next-app/
|
|
57
|
+
├── src/
|
|
58
|
+
│ ├── app/
|
|
59
|
+
│ │ ├── (public)/
|
|
60
|
+
│ │ │ ├── layout.tsx
|
|
61
|
+
│ │ │ ├── page.tsx
|
|
62
|
+
│ │ │ └── pricing/page.tsx
|
|
63
|
+
│ │ ├── (dashboard)/
|
|
64
|
+
│ │ │ ├── layout.tsx
|
|
65
|
+
│ │ │ ├── dashboard/page.tsx
|
|
66
|
+
│ │ │ ├── products/page.tsx
|
|
67
|
+
│ │ │ └── orders/page.tsx
|
|
68
|
+
│ │ ├── api/
|
|
69
|
+
│ │ │ ├── health/route.ts
|
|
70
|
+
│ │ │ └── auth/route.ts # (optional) if you expose auth endpoints
|
|
71
|
+
│ │ ├── layout.tsx
|
|
72
|
+
│ │ ├── globals.css
|
|
73
|
+
│ │ ├── error.tsx
|
|
74
|
+
│ │ └── not-found.tsx
|
|
75
|
+
│ │
|
|
76
|
+
│ ├── features/
|
|
77
|
+
│ │ ├── auth/
|
|
78
|
+
│ │ │ ├── components/
|
|
79
|
+
│ │ │ ├── actions/
|
|
80
|
+
│ │ │ ├── schemas/
|
|
81
|
+
│ │ │ ├── types/
|
|
82
|
+
│ │ │ └── index.ts
|
|
83
|
+
│ │ ├── products/
|
|
84
|
+
│ │ │ ├── components/
|
|
85
|
+
│ │ │ ├── actions/
|
|
86
|
+
│ │ │ ├── queries/
|
|
87
|
+
│ │ │ ├── schemas/
|
|
88
|
+
│ │ │ ├── types/
|
|
89
|
+
│ │ │ └── index.ts
|
|
90
|
+
│ │ └── orders/
|
|
91
|
+
│ │ ├── components/
|
|
92
|
+
│ │ ├── actions/
|
|
93
|
+
│ │ ├── queries/
|
|
94
|
+
│ │ ├── schemas/
|
|
95
|
+
│ │ ├── types/
|
|
96
|
+
│ │ └── index.ts
|
|
97
|
+
│ │
|
|
98
|
+
│ ├── components/
|
|
99
|
+
│ │ ├── ui/ # shadcn/ui only
|
|
100
|
+
│ │ └── shared/
|
|
101
|
+
│ │ ├── Header.tsx
|
|
102
|
+
│ │ ├── Footer.tsx
|
|
103
|
+
│ │ └── Sidebar.tsx
|
|
104
|
+
│ │
|
|
105
|
+
│ ├── server/ # server-only boundary
|
|
106
|
+
│ │ ├── auth/
|
|
107
|
+
│ │ │ ├── auth.ts # Auth (server config)
|
|
108
|
+
│ │ │ └── guards.ts
|
|
109
|
+
│ │ ├── db/
|
|
110
|
+
│ │ │ └── prisma.ts # PrismaClient singleton
|
|
111
|
+
│ │ ├── repositories/
|
|
112
|
+
│ │ │ ├── product.repo.ts
|
|
113
|
+
│ │ │ └── order.repo.ts
|
|
114
|
+
│ │ └── services/
|
|
115
|
+
│ │ ├── email.service.ts
|
|
116
|
+
│ │ └── storage.service.ts
|
|
117
|
+
│ │
|
|
118
|
+
│ ├── lib/
|
|
119
|
+
│ │ ├── env.ts
|
|
120
|
+
│ │ ├── utils.ts
|
|
121
|
+
│ │ ├── logger.ts
|
|
122
|
+
│ │ └── auth/
|
|
123
|
+
│ │ └── auth-client.ts # Auth (client helper)
|
|
124
|
+
│ │
|
|
125
|
+
│ ├── hooks/
|
|
126
|
+
│ │ └── useDebounce.ts
|
|
127
|
+
│ │
|
|
128
|
+
│ └── types/
|
|
129
|
+
│ └── global.d.ts
|
|
130
|
+
│
|
|
131
|
+
├── prisma/
|
|
132
|
+
│ ├── schema.prisma
|
|
133
|
+
│ ├── migrations/
|
|
134
|
+
│ └── seed.ts
|
|
135
|
+
│
|
|
136
|
+
├── public/
|
|
137
|
+
├── tests/
|
|
138
|
+
│ ├── unit/
|
|
139
|
+
│ └── e2e/
|
|
140
|
+
│
|
|
141
|
+
├── middleware.ts
|
|
142
|
+
├── next.config.js
|
|
143
|
+
├── package.json
|
|
144
|
+
├── tsconfig.json
|
|
145
|
+
├── .env.example
|
|
146
|
+
└── README.md
|
|
147
|
+
```
|
|
148
|
+
|
|
53
149
|
## Environment Variables
|
|
54
150
|
|
|
55
151
|
Create a `.env.local` (Next.js) file for local environment variables. Keep secrets out of the repository.
|
|
@@ -61,6 +61,62 @@ src/
|
|
|
61
61
|
└── utils/ # Helper functions
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Recommended Folder & File Structure
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
react-vite-app/
|
|
68
|
+
├── src/
|
|
69
|
+
│ ├── app/
|
|
70
|
+
│ │ ├── router.tsx
|
|
71
|
+
│ │ ├── providers.tsx
|
|
72
|
+
│ │ └── layouts/
|
|
73
|
+
│ │ ├── PublicLayout.tsx
|
|
74
|
+
│ │ └── DashboardLayout.tsx
|
|
75
|
+
│
|
|
76
|
+
│ ├── features/
|
|
77
|
+
│ │ ├── auth/
|
|
78
|
+
│ │ │ ├── pages/
|
|
79
|
+
│ │ │ │ ├── LoginPage.tsx
|
|
80
|
+
│ │ │ │ └── SignupPage.tsx
|
|
81
|
+
│ │ │ ├── components/
|
|
82
|
+
│ │ │ ├── api/
|
|
83
|
+
│ │ │ │ └── auth.api.ts
|
|
84
|
+
│ │ │ ├── hooks/
|
|
85
|
+
│ │ │ │ └── useAuth.ts
|
|
86
|
+
│ │ │ ├── schemas/
|
|
87
|
+
│ │ │ ├── types/
|
|
88
|
+
│ │ │ └── index.ts
|
|
89
|
+
│ │ ├── products/
|
|
90
|
+
│ │ └── orders/
|
|
91
|
+
│
|
|
92
|
+
│ ├── shared/
|
|
93
|
+
│ │ ├── ui/
|
|
94
|
+
│ │ ├── components/
|
|
95
|
+
│ │ │ ├── Header.tsx
|
|
96
|
+
│ │ │ └── Sidebar.tsx
|
|
97
|
+
│ │ ├── api/
|
|
98
|
+
│ │ │ ├── http.ts # axios/fetch client
|
|
99
|
+
│ │ │ └── endpoints.ts
|
|
100
|
+
│ │ └── lib/
|
|
101
|
+
│ │ ├── env.ts
|
|
102
|
+
│ │ ├── utils.ts
|
|
103
|
+
│ │ └── auth-client.ts # Auth client helper
|
|
104
|
+
│
|
|
105
|
+
│ ├── assets/
|
|
106
|
+
│ ├── main.tsx
|
|
107
|
+
│ └── index.css
|
|
108
|
+
│
|
|
109
|
+
├── public/
|
|
110
|
+
├── tests/
|
|
111
|
+
│ ├── unit/
|
|
112
|
+
│ └── e2e/
|
|
113
|
+
├── vite.config.ts
|
|
114
|
+
├── tsconfig.json
|
|
115
|
+
├── package.json
|
|
116
|
+
├── .env.example
|
|
117
|
+
└── README.md
|
|
118
|
+
```
|
|
119
|
+
|
|
64
120
|
## Deployment
|
|
65
121
|
|
|
66
122
|
Build for production and serve or deploy the static output:
|