kaelum 1.8.1 → 1.8.2
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.
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Simple in-memory controller for Kaelum API demonstration
|
|
3
3
|
|
|
4
4
|
const users = [
|
|
5
|
-
{ id: 1, name: "
|
|
6
|
-
{ id: 2, name: "
|
|
5
|
+
{ id: 1, name: "Alice", role: "admin" },
|
|
6
|
+
{ id: 2, name: "Bob", role: "user" },
|
|
7
7
|
];
|
|
8
8
|
|
|
9
9
|
exports.list = (req, res) => res.json(users);
|
|
@@ -15,7 +15,7 @@ exports.create = (req, res) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
exports.get = (req, res) => {
|
|
18
|
-
const user = users.find((u) => u.id
|
|
18
|
+
const user = users.find((u) => u.id === Number(req.params.id));
|
|
19
19
|
return user ? res.json(user) : res.status(404).json({ error: "User not found" });
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// routes.js
|
|
2
2
|
const users = require("./controllers/usersController");
|
|
3
3
|
const auth = require("./middlewares/authMock");
|
|
4
|
+
const { version } = require("./package.json");
|
|
4
5
|
|
|
5
6
|
module.exports = (app) => {
|
|
6
7
|
// Global middleware for /users path
|
|
@@ -28,6 +29,6 @@ module.exports = (app) => {
|
|
|
28
29
|
|
|
29
30
|
// Metadata endpoint
|
|
30
31
|
app.addRoute("/meta", {
|
|
31
|
-
get: (req, res) => res.json({ version
|
|
32
|
+
get: (req, res) => res.json({ version, framework: "Kaelum" }),
|
|
32
33
|
});
|
|
33
34
|
};
|
|
@@ -8,8 +8,8 @@ interface User {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const users: User[] = [
|
|
11
|
-
{ id: 1, name: "
|
|
12
|
-
{ id: 2, name: "
|
|
11
|
+
{ id: 1, name: "Alice", role: "admin" },
|
|
12
|
+
{ id: 2, name: "Bob", role: "user" },
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
const list = (req: any, res: any): void => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const users = require("./controllers/usersController");
|
|
2
2
|
const { authMock } = require("./middlewares/authMock");
|
|
3
|
+
const { version } = require("../../package.json");
|
|
3
4
|
|
|
4
5
|
const routes = (app: any): void => {
|
|
5
6
|
// Global middleware for /users path
|
|
@@ -28,7 +29,7 @@ const routes = (app: any): void => {
|
|
|
28
29
|
// Metadata endpoint
|
|
29
30
|
app.addRoute("/meta", {
|
|
30
31
|
get: (req: any, res: any) =>
|
|
31
|
-
res.json({ version
|
|
32
|
+
res.json({ version, framework: "Kaelum" }),
|
|
32
33
|
});
|
|
33
34
|
};
|
|
34
35
|
|