kaelum 1.3.2 → 1.3.3
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 +52 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# Kaelum
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/kaelum)
|
|
4
|
+
[](https://github.com/MatheusCampagnolo/kaelum/actions)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://matheuscampagnolo.github.io/kaelum/)
|
|
7
|
+
|
|
3
8
|
**Kaelum.JS** — Minimalist Node.js framework to simplify creation of web pages and REST APIs.
|
|
4
9
|
Designed for students and developers who want a fast, opinionated project scaffold and a small, friendly API that encapsulates common Express.js boilerplate.
|
|
5
10
|
|
|
11
|
+
👉 [**Read the full documentation here**](https://matheuscampagnolo.github.io/kaelum/)
|
|
12
|
+
|
|
6
13
|
---
|
|
7
14
|
|
|
8
15
|
## 🚀 Quick start
|
|
@@ -11,7 +18,7 @@ Create a new project (interactive):
|
|
|
11
18
|
|
|
12
19
|
```bash
|
|
13
20
|
npx kaelum create
|
|
14
|
-
|
|
21
|
+
```
|
|
15
22
|
|
|
16
23
|
Or create non-interactively (project name + template):
|
|
17
24
|
|
|
@@ -35,13 +42,14 @@ npm start
|
|
|
35
42
|
|
|
36
43
|
## 📦 What Kaelum provides
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
- CLI that scaffolds a ready-to-run project (Web or API template) using an opinionated **MVC** structure.
|
|
46
|
+
- Thin abstraction layer over **Express.js** that:
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
- automates JSON / URL-encoded parsing by default,
|
|
49
|
+
- automatically configures common security middlewares via `setConfig` (CORS, Helmet),
|
|
50
|
+
- exposes a small, easy-to-learn API for routes, middleware and configuration.
|
|
51
|
+
|
|
52
|
+
- Small set of helpers for common tasks: `start`, `addRoute`, `apiRoute`, `setConfig`, `static`, `redirect`, `healthCheck`, `useErrorHandler`, and more.
|
|
45
53
|
|
|
46
54
|
Kaelum aims to reduce the initial setup burden while keeping flexibility for advanced users.
|
|
47
55
|
|
|
@@ -49,7 +57,7 @@ Kaelum aims to reduce the initial setup burden while keeping flexibility for adv
|
|
|
49
57
|
|
|
50
58
|
## 📁 Template structures
|
|
51
59
|
|
|
52
|
-
### Web template (
|
|
60
|
+
### Web template (`--template web`)
|
|
53
61
|
|
|
54
62
|
```
|
|
55
63
|
my-web-app/
|
|
@@ -81,12 +89,12 @@ my-api-app/
|
|
|
81
89
|
|
|
82
90
|
---
|
|
83
91
|
|
|
84
|
-
## 🧩 Core API
|
|
92
|
+
## 🧩 Core API
|
|
85
93
|
|
|
86
94
|
> Kaelum exposes a factory — use `require('kaelum')` and call it to get an app instance:
|
|
87
95
|
|
|
88
96
|
```js
|
|
89
|
-
const kaelum = require(
|
|
97
|
+
const kaelum = require("kaelum");
|
|
90
98
|
const app = kaelum();
|
|
91
99
|
```
|
|
92
100
|
|
|
@@ -96,17 +104,17 @@ Enable/disable common features:
|
|
|
96
104
|
|
|
97
105
|
```js
|
|
98
106
|
app.setConfig({
|
|
99
|
-
cors: true,
|
|
100
|
-
helmet: true,
|
|
101
|
-
static: "public",
|
|
102
|
-
bodyParser: true,
|
|
103
|
-
logs: false,
|
|
104
|
-
port: 3000
|
|
107
|
+
cors: true, // apply CORS (requires cors package in dependencies)
|
|
108
|
+
helmet: true, // apply Helmet
|
|
109
|
+
static: "public", // serve static files from "public"
|
|
110
|
+
bodyParser: true, // default: enabled (JSON + urlencoded)
|
|
111
|
+
logs: false, // enable request logging via morgan (if installed)
|
|
112
|
+
port: 3000, // prefered port (used when calling app.start() without port)
|
|
105
113
|
});
|
|
106
114
|
```
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
- `setConfig` persists settings to the Kaelum config and will install/remove Kaelum-managed middlewares.
|
|
117
|
+
- Kaelum enables JSON/urlencoded parsing by default so beginners won't forget to parse request bodies.
|
|
110
118
|
|
|
111
119
|
---
|
|
112
120
|
|
|
@@ -115,7 +123,7 @@ app.setConfig({
|
|
|
115
123
|
Starts the HTTP server. If `port` is omitted, Kaelum reads `port` from `setConfig` or falls back to `3000`.
|
|
116
124
|
|
|
117
125
|
```js
|
|
118
|
-
app.start(3000, () => console.log(
|
|
126
|
+
app.start(3000, () => console.log("Running"));
|
|
119
127
|
```
|
|
120
128
|
|
|
121
129
|
---
|
|
@@ -125,20 +133,20 @@ app.start(3000, () => console.log('Running'));
|
|
|
125
133
|
Register routes easily:
|
|
126
134
|
|
|
127
135
|
```js
|
|
128
|
-
app.addRoute(
|
|
129
|
-
get: (req, res) => res.send(
|
|
130
|
-
post: (req, res) => res.send(
|
|
136
|
+
app.addRoute("/home", {
|
|
137
|
+
get: (req, res) => res.send("Welcome!"),
|
|
138
|
+
post: (req, res) => res.send("Posted!"),
|
|
131
139
|
});
|
|
132
140
|
|
|
133
141
|
// apiRoute builds RESTy resources with nested subpaths:
|
|
134
|
-
app.apiRoute(
|
|
142
|
+
app.apiRoute("users", {
|
|
135
143
|
get: listUsers,
|
|
136
144
|
post: createUser,
|
|
137
|
-
|
|
145
|
+
"/:id": {
|
|
138
146
|
get: getUserById,
|
|
139
147
|
put: updateUser,
|
|
140
|
-
delete: deleteUser
|
|
141
|
-
}
|
|
148
|
+
delete: deleteUser,
|
|
149
|
+
},
|
|
142
150
|
});
|
|
143
151
|
```
|
|
144
152
|
|
|
@@ -152,13 +160,13 @@ Flexible helper to register middleware(s):
|
|
|
152
160
|
|
|
153
161
|
```js
|
|
154
162
|
// single middleware
|
|
155
|
-
app.setMiddleware(require(
|
|
163
|
+
app.setMiddleware(require("helmet")());
|
|
156
164
|
|
|
157
165
|
// array of middlewares
|
|
158
166
|
app.setMiddleware([mw1, mw2]);
|
|
159
167
|
|
|
160
168
|
// mount middleware on a path
|
|
161
|
-
app.setMiddleware(
|
|
169
|
+
app.setMiddleware("/admin", authMiddleware);
|
|
162
170
|
```
|
|
163
171
|
|
|
164
172
|
---
|
|
@@ -168,7 +176,7 @@ app.setMiddleware('/admin', authMiddleware);
|
|
|
168
176
|
Register a redirect route:
|
|
169
177
|
|
|
170
178
|
```js
|
|
171
|
-
app.redirect(
|
|
179
|
+
app.redirect("/old-url", "/new-url", 302);
|
|
172
180
|
```
|
|
173
181
|
|
|
174
182
|
---
|
|
@@ -193,45 +201,42 @@ It will return standardized JSON for errors and log server-side errors (5xx) to
|
|
|
193
201
|
|
|
194
202
|
## 🔧 Local development & contributing
|
|
195
203
|
|
|
196
|
-
To develop Kaelum locally and test the CLI:
|
|
197
|
-
|
|
198
204
|
```bash
|
|
199
|
-
# clone
|
|
200
205
|
git clone https://github.com/MatheusCampagnolo/kaelum.git
|
|
201
206
|
cd kaelum
|
|
202
|
-
|
|
203
|
-
# install & link locally
|
|
204
207
|
npm install
|
|
205
208
|
npm link
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Now you can test the CLI locally:
|
|
206
212
|
|
|
207
|
-
|
|
213
|
+
```bash
|
|
208
214
|
npx kaelum create my-test --template web
|
|
209
|
-
# or
|
|
210
|
-
kaelum create my-test # if linked globally
|
|
211
215
|
```
|
|
212
216
|
|
|
213
217
|
---
|
|
214
218
|
|
|
215
|
-
|
|
216
219
|
## 📝 Why Kaelum?
|
|
217
220
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
- Reduces repetitive boilerplate required to start Node/Express web projects.
|
|
222
|
+
- Opinionated scaffolding (MVC) helps beginners adopt better structure.
|
|
223
|
+
- Keeps a small API surface: easy to teach and document.
|
|
224
|
+
- Extensible — `setConfig` and middleware helpers allow adding features without exposing Express internals.
|
|
222
225
|
|
|
223
226
|
---
|
|
224
227
|
|
|
225
228
|
## ✅ Current status
|
|
226
229
|
|
|
227
|
-
> Kaelum is under active development.
|
|
230
|
+
> Kaelum is under active development.
|
|
231
|
+
> CLI scaffolds web and API templates, and the framework includes the MVP helpers (`start`, `addRoute`, `apiRoute`, `setConfig`, `static`, `redirect`, `healthCheck`, `useErrorHandler`) and security toggles for `cors` and `helmet`.
|
|
228
232
|
|
|
229
233
|
---
|
|
230
234
|
|
|
231
235
|
## 📚 Links
|
|
232
236
|
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
- [GitHub](https://github.com/MatheusCampagnolo/kaelum)
|
|
238
|
+
- [npm](https://www.npmjs.com/package/kaelum)
|
|
239
|
+
- [Documentation](https://matheuscampagnolo.github.io/kaelum/)
|
|
235
240
|
|
|
236
241
|
---
|
|
237
242
|
|
|
@@ -243,6 +248,5 @@ MIT — see [LICENSE](LICENSE).
|
|
|
243
248
|
|
|
244
249
|
## ✍️ Notes for maintainers
|
|
245
250
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
* We plan to add full JSDoc for the public API, unit tests (Jest + Supertest) and a docs site in future iterations.
|
|
251
|
+
- Templates use `commonjs` (`require` / `module.exports`).
|
|
252
|
+
- Update template dependencies to reference the correct Kaelum version when releasing new npm versions.
|