evikit 2.11.1 → 2.13.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/.woodpecker/test.yaml +38 -38
- package/README.md +38 -7
- package/db.d.ts +272 -265
- package/db.js +128 -128
- package/package.json +11 -1
- package/server.d.ts +1 -1
- package/server.js +128 -19
- package/sqlite.js +34 -18
package/.woodpecker/test.yaml
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
when:
|
|
2
|
-
- event: push
|
|
3
|
-
branch: main
|
|
4
|
-
- event: pull_request
|
|
5
|
-
|
|
6
|
-
steps:
|
|
7
|
-
- name: build
|
|
8
|
-
image: node:24-alpine
|
|
9
|
-
commands:
|
|
10
|
-
- apk add git
|
|
11
|
-
# Are types correct?
|
|
12
|
-
- npm i
|
|
13
|
-
- npm run lint
|
|
14
|
-
- npx tsc
|
|
15
|
-
# Does todo app example build?
|
|
16
|
-
- npm create evikit my-app
|
|
17
|
-
- rm -rf my-app/node_modules/evikit
|
|
18
|
-
- (cd my-app/node_modules; git clone ../.. evikit)
|
|
19
|
-
- (cd my-app; npm run build)
|
|
20
|
-
# Does real-world application pass tests?
|
|
21
|
-
- git clone https://codeberg.org/nykula/lanquiz
|
|
22
|
-
- (cd lanquiz; npm i)
|
|
23
|
-
- rm -rf lanquiz/node_modules/evikit
|
|
24
|
-
- (cd lanquiz/node_modules; git clone ../.. evikit)
|
|
25
|
-
- (cd lanquiz; npm run build)
|
|
26
|
-
- (cd lanquiz; npm test -- --test-concurrency=1)
|
|
27
|
-
# Do other real-world applications build? 1/2
|
|
28
|
-
- git clone https://codeberg.org/nykula/mobhub
|
|
29
|
-
- (cd mobhub; npm i)
|
|
30
|
-
- rm -rf mobhub/node_modules/evikit
|
|
31
|
-
- (cd mobhub/node_modules; git clone ../.. evikit)
|
|
32
|
-
- (cd mobhub; npm run build)
|
|
33
|
-
# Do other real-world applications build? 2/2
|
|
34
|
-
- git clone https://codeberg.org/nykula/yoself
|
|
35
|
-
- (cd yoself; npm i)
|
|
36
|
-
- rm -rf yoself/node_modules/evikit
|
|
37
|
-
- (cd yoself/node_modules; git clone ../.. evikit)
|
|
38
|
-
- (cd yoself; npm run build)
|
|
1
|
+
when:
|
|
2
|
+
- event: push
|
|
3
|
+
branch: main
|
|
4
|
+
- event: pull_request
|
|
5
|
+
|
|
6
|
+
steps:
|
|
7
|
+
- name: build
|
|
8
|
+
image: node:24-alpine
|
|
9
|
+
commands:
|
|
10
|
+
- apk add git
|
|
11
|
+
# Are types correct?
|
|
12
|
+
- npm i
|
|
13
|
+
- npm run lint
|
|
14
|
+
- npx tsc
|
|
15
|
+
# Does todo app example build?
|
|
16
|
+
- npm create evikit my-app
|
|
17
|
+
- rm -rf my-app/node_modules/evikit
|
|
18
|
+
- (cd my-app/node_modules; git clone ../.. evikit)
|
|
19
|
+
- (cd my-app; npm run build)
|
|
20
|
+
# Does real-world application pass tests?
|
|
21
|
+
- git clone https://codeberg.org/nykula/lanquiz
|
|
22
|
+
- (cd lanquiz; npm i)
|
|
23
|
+
- rm -rf lanquiz/node_modules/evikit
|
|
24
|
+
- (cd lanquiz/node_modules; git clone ../.. evikit)
|
|
25
|
+
- (cd lanquiz; npm run build)
|
|
26
|
+
- (cd lanquiz; npm test -- --test-concurrency=1)
|
|
27
|
+
# Do other real-world applications build? 1/2
|
|
28
|
+
- git clone https://codeberg.org/nykula/mobhub
|
|
29
|
+
- (cd mobhub; npm i)
|
|
30
|
+
- rm -rf mobhub/node_modules/evikit
|
|
31
|
+
- (cd mobhub/node_modules; git clone ../.. evikit)
|
|
32
|
+
- (cd mobhub; npm run build)
|
|
33
|
+
# Do other real-world applications build? 2/2
|
|
34
|
+
- git clone https://codeberg.org/nykula/yoself
|
|
35
|
+
- (cd yoself; npm i)
|
|
36
|
+
- rm -rf yoself/node_modules/evikit
|
|
37
|
+
- (cd yoself/node_modules; git clone ../.. evikit)
|
|
38
|
+
- (cd yoself; npm run build)
|
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ Our language will be standard modern JavaScript as supported by Node.js directly
|
|
|
61
61
|
- [Styling](#styling)
|
|
62
62
|
- _TODO_ [Testing](#testing)
|
|
63
63
|
- [Linting](#linting)
|
|
64
|
+
- [esbuild](#esbuild)
|
|
64
65
|
|
|
65
66
|
### Create project
|
|
66
67
|
|
|
@@ -288,7 +289,7 @@ The following commands should work now:
|
|
|
288
289
|
# Run dev server with hot reload for Preact and full restart on API change.
|
|
289
290
|
npx vite dev
|
|
290
291
|
|
|
291
|
-
# Build
|
|
292
|
+
# Build client for production.
|
|
292
293
|
npx tsc
|
|
293
294
|
npx vite build
|
|
294
295
|
```
|
|
@@ -473,8 +474,8 @@ export const QuestionIdServer = {
|
|
|
473
474
|
get: endpoint(QuestionIdGet, async ({ input }) => {
|
|
474
475
|
const i18n = await getI18n(input.lang);
|
|
475
476
|
const [question] = db.Question.select({
|
|
477
|
+
id: input.id,
|
|
476
478
|
with: { Choice: true },
|
|
477
|
-
where: { id: input.id },
|
|
478
479
|
});
|
|
479
480
|
// It maps join results to objects, for example you can get:
|
|
480
481
|
// question?.Choice[0]?.text
|
|
@@ -557,7 +558,7 @@ export const ChoiceServer = {
|
|
|
557
558
|
post: endpoint(ChoicePost, async ({ input }) => {
|
|
558
559
|
const i18n = await getI18n(input.lang);
|
|
559
560
|
|
|
560
|
-
const [question] = db.Question.select({
|
|
561
|
+
const [question] = db.Question.select({ id: input.questionId });
|
|
561
562
|
if (!question) {
|
|
562
563
|
return text(i18n.gettext("Question does not exist"), 400);
|
|
563
564
|
}
|
|
@@ -638,7 +639,7 @@ export const VoteServer = {
|
|
|
638
639
|
post: endpoint(VotePost, async ({ input }) => {
|
|
639
640
|
const i18n = await getI18n(input.lang);
|
|
640
641
|
|
|
641
|
-
const [choice] = db.Choice.select({
|
|
642
|
+
const [choice] = db.Choice.select({ id: input.choiceId });
|
|
642
643
|
if (!choice) {
|
|
643
644
|
return text(i18n.gettext("You didn't select a choice"), 400);
|
|
644
645
|
}
|
|
@@ -648,9 +649,9 @@ export const VoteServer = {
|
|
|
648
649
|
}
|
|
649
650
|
|
|
650
651
|
db.Choice.update({
|
|
652
|
+
id: choice.id,
|
|
651
653
|
set: { votes: choice.votes + 1 },
|
|
652
|
-
|
|
653
|
-
// To update multiple choices, pass an array of ids to `where.id`.
|
|
654
|
+
// To update multiple choices, pass an array of ids to `id`.
|
|
654
655
|
});
|
|
655
656
|
// To delete a choice: `db.Choice.delete({ id: choice.id })`.
|
|
656
657
|
// To delete multiple choices, pass an array of ids to `id`.
|
|
@@ -790,8 +791,8 @@ import { ok } from "node:assert/strict";
|
|
|
790
791
|
// ...
|
|
791
792
|
|
|
792
793
|
const [question] = db.Question.select({
|
|
794
|
+
id: input.id,
|
|
793
795
|
with: { Choice: { with: { iconStorage: true } } },
|
|
794
|
-
where: { id: input.id },
|
|
795
796
|
});
|
|
796
797
|
|
|
797
798
|
// ...
|
|
@@ -1004,6 +1005,36 @@ npx eslint .
|
|
|
1004
1005
|
|
|
1005
1006
|
You can add these commands (without npx) as `format` and `lint` scripts in your `package.json`.
|
|
1006
1007
|
|
|
1008
|
+
## esbuild
|
|
1009
|
+
|
|
1010
|
+
If you don't need Tailwind (e.g. `index.css` is enough for you) or bundle analyzer, and are ok with full-page refresh instead of hot module replacement, you can have EviKit use [esbuild](https://esbuild.github.io/) as a smaller alternative to Vite.
|
|
1011
|
+
|
|
1012
|
+
```sh
|
|
1013
|
+
npm i -D esbuild
|
|
1014
|
+
npm install-scripts approve esbuild
|
|
1015
|
+
npm rm @preact/preset-vite vite vite-bundle-analyzer
|
|
1016
|
+
rm -f vite.config.js
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
Change the `production` call in your `index.js`:
|
|
1020
|
+
|
|
1021
|
+
```js
|
|
1022
|
+
app.use(production({ prerender }));
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
The following commands should work now:
|
|
1026
|
+
|
|
1027
|
+
```sh
|
|
1028
|
+
# Run dev server with watch mode.
|
|
1029
|
+
node --env-file=.env index.js dev
|
|
1030
|
+
|
|
1031
|
+
# Build client for production.
|
|
1032
|
+
npx tsc
|
|
1033
|
+
node --env-file=.env index.js build
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
You can change the `dev` and `build` scripts in your `package.json` accordingly.
|
|
1037
|
+
|
|
1007
1038
|
## License
|
|
1008
1039
|
|
|
1009
1040
|
SPDX-License-Identifier: MIT
|