@stanlemon/app-template 0.2.4 → 0.2.5
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/app.js +17 -5
- package/package.json +9 -2
package/app.js
CHANGED
|
@@ -3,16 +3,28 @@ import {
|
|
|
3
3
|
asyncJsonHandler as handler,
|
|
4
4
|
SimpleUsersDao,
|
|
5
5
|
} from "@stanlemon/server-with-auth";
|
|
6
|
-
|
|
7
|
-
const users = new SimpleUsersDao();
|
|
6
|
+
import { Low, JSONFile } from "lowdb";
|
|
8
7
|
|
|
9
8
|
const app = createAppServer({
|
|
10
9
|
webpack: "http://localhost:8080",
|
|
11
10
|
secure: ["/api/"],
|
|
12
|
-
...
|
|
11
|
+
...new SimpleUsersDao(),
|
|
13
12
|
});
|
|
14
13
|
|
|
14
|
+
const db = new Low(new JSONFile("./db.json"));
|
|
15
|
+
await db.read();
|
|
16
|
+
db.data.items ||= [];
|
|
17
|
+
|
|
15
18
|
app.get(
|
|
16
|
-
"/api/
|
|
17
|
-
handler(() => ({
|
|
19
|
+
"/api/items",
|
|
20
|
+
handler(() => ({ items: db.data.items }))
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
app.post(
|
|
24
|
+
"/api/items",
|
|
25
|
+
handler(async (item) => {
|
|
26
|
+
db.data.items.push(item);
|
|
27
|
+
await db.write();
|
|
28
|
+
return db.data.items;
|
|
29
|
+
})
|
|
18
30
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanlemon/app-template",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A template for creating apps using the webdev package.",
|
|
5
5
|
"author": "Stan Lemon <stanlemon@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,14 @@
|
|
|
18
18
|
"lint:format": "eslint --fix --ext js,jsx,ts,tsx ./src/"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@stanlemon/server-with-auth": "0.1.4",
|
|
21
22
|
"@stanlemon/webdev": "*",
|
|
22
|
-
"
|
|
23
|
+
"react": "^18.0.0",
|
|
24
|
+
"react-dom": "^18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@testing-library/react": "^13.1.1",
|
|
28
|
+
"@types/react": "^18.0.5",
|
|
29
|
+
"@types/react-dom": "^18.0.1"
|
|
23
30
|
}
|
|
24
31
|
}
|