miolo 3.0.0-beta.167 → 3.0.0-beta.169

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": "miolo",
3
- "version": "3.0.0-beta.167",
3
+ "version": "3.0.0-beta.169",
4
4
  "description": "all-in-one koa-based server",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -47,7 +47,7 @@
47
47
  "@babel/plugin-proposal-decorators": "^7.29.0",
48
48
  "@babel/preset-env": "^7.29.2",
49
49
  "@babel/preset-react": "^7.28.5",
50
- "@dotenvx/dotenvx": "^1.57.0",
50
+ "@dotenvx/dotenvx": "^1.57.2",
51
51
  "@koa/bodyparser": "^6.1.0",
52
52
  "@koa/cors": "^5.0.0",
53
53
  "@koa/router": "^15.4.0",
@@ -70,7 +70,7 @@
70
70
  "http-terminator": "^3.2.0",
71
71
  "intre": "^3.0.0-beta.4",
72
72
  "is-plain-object": "^5.0.0",
73
- "joi": "^18.0.2",
73
+ "joi": "^18.1.1",
74
74
  "jwt-simple": "^0.5.6",
75
75
  "koa": "^3.1.2",
76
76
  "koa-compress": "^5.2.1",
@@ -83,10 +83,10 @@
83
83
  "koa-session": "^7.0.2",
84
84
  "koa-static": "^5.0.0",
85
85
  "nanoid": "^5.1.7",
86
- "nodemailer": "^8.0.3",
86
+ "nodemailer": "^8.0.4",
87
87
  "passport-google-oauth20": "^2.0.0",
88
88
  "passport-local": "^1.0.0",
89
- "rollup": "^4.59.0",
89
+ "rollup": "^4.60.0",
90
90
  "rollup-plugin-node-externals": "^8.1.2",
91
91
  "rollup-plugin-postcss": "^4.0.2",
92
92
  "socket.io": "^4.8.3",
@@ -94,7 +94,7 @@
94
94
  "statuses": "^2.0.2",
95
95
  "tailwindcss": "^4.2.2",
96
96
  "tinguir": "^0.0.7",
97
- "vite": "^8.0.1",
97
+ "vite": "^8.0.2",
98
98
  "winston": "^3.19.0",
99
99
  "winston-daily-rotate-file": "^5.0.0",
100
100
  "yargs-parser": "^22.0.0"
@@ -158,7 +158,9 @@ export default function make_config_defaults() {
158
158
  // error_code: 401
159
159
  // },
160
160
  // before: async (ctx) => {return bool} // If bool false, query callback not run
161
+ // it can also be an array of functions
161
162
  // after : async (ctx, data) => {return modified_data}
163
+ // it can also be an array of functions
162
164
 
163
165
  crud: [
164
166
  {
@@ -206,8 +208,8 @@ export default function make_config_defaults() {
206
208
  // (you may want {keep_body: true})
207
209
  } ,
208
210
  auth: ...,
209
- before: async (ctx) => { return true/false },
210
- after : async (ctx, data) => { return data },
211
+ before: async (ctx) => { return true/false } or array of functions,
212
+ after : async (ctx, data) => { return data } or array of functions,
211
213
  schema: a Joi schema,
212
214
  keep_body: false by default. If true, miolo wont wnsure ctx.body after callback.
213
215
  },
@@ -73,13 +73,22 @@ function attachCrudRoutes(router, crudConfigs, logger) {
73
73
 
74
74
  let goon = true
75
75
  if (route?.before) {
76
- goon = await route.before(ctx)
76
+ if (Array.isArray(route.before)) {
77
+ for (const before of route.before) {
78
+ goon = await before(ctx)
79
+ if (!goon) {
80
+ break
81
+ }
82
+ }
83
+ } else {
84
+ goon = await route.before(ctx)
85
+ }
77
86
  }
78
87
 
79
88
  if (!goon) {
80
89
  ctx.body = {
81
90
  ok: false,
82
- error: "Not allowd"
91
+ error: "Not allowed"
83
92
  }
84
93
  return
85
94
  }
@@ -8,8 +8,8 @@ import { DEFAULT_AUTH_USER, DEFAULT_USE_USER_FIELDS } from "../defaults.mjs"
8
8
 
9
9
  auth,
10
10
  bodyField,
11
- before: (ctx) => {return goon/!goon},
12
- after : (ctx, data) => {return data},
11
+ before: (ctx) => {return goon/!goon} or array of functions,
12
+ after : (ctx, data) => {return data} or array of functions,
13
13
 
14
14
  routes: an array of tables config, where each config can be:
15
15
  - a simple string with the table name
@@ -30,8 +30,8 @@ import { DEFAULT_AUTH_USER, DEFAULT_USE_USER_FIELDS } from "../defaults.mjs"
30
30
 
31
31
  auth,
32
32
  bodyField,
33
- before: (ctx) => {return goon/!goon},
34
- after : (ctx, data) => {return data},
33
+ before: (ctx) => {return goon/!goon} or array of functions,
34
+ after : (ctx, data) => {return data} or array of functions,
35
35
 
36
36
  }
37
37
  }]
@@ -68,7 +68,16 @@ function attachQueriesRoutes(router, queriesConfigs, logger) {
68
68
 
69
69
  let goon = true
70
70
  if (route?.before) {
71
- goon = await route.before(ctx)
71
+ if (Array.isArray(route.before)) {
72
+ for (const before of route.before) {
73
+ goon = await before(ctx)
74
+ if (!goon) {
75
+ break
76
+ }
77
+ }
78
+ } else {
79
+ goon = await route.before(ctx)
80
+ }
72
81
 
73
82
  if (!goon) {
74
83
  ctx.body = {
@@ -6,8 +6,8 @@ import { DEFAULT_AUTH_USER } from "../defaults.mjs"
6
6
  prefix: '/queries',
7
7
 
8
8
  auth,
9
- before: (ctx) => {return goon/!goon},
10
- after : (ctx, data) => {return data},
9
+ before: (ctx) => {return goon/!goon} or array of functions,
10
+ after : (ctx, data) => {return data} or array of functions,
11
11
 
12
12
 
13
13
  routes: [
@@ -25,8 +25,8 @@ import { DEFAULT_AUTH_USER } from "../defaults.mjs"
25
25
  // (you may want {keep_body: true})
26
26
  } ,
27
27
  auth,
28
- before: async (ctx) => { return true/false },
29
- after : async (ctx, data) => { return data },
28
+ before: async (ctx) => { return true/false } or array of functions,
29
+ after : async (ctx, data) => { return data } or array of functions,
30
30
  schema: a Joi schema,
31
31
  keep_body: false by default. If true, miolo wont wnsure ctx.body after callback.
32
32
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
3
3
  "files": {
4
4
  "includes": [
5
5
  "**/*",
@@ -42,17 +42,17 @@
42
42
  "clsx": "^2.1.1",
43
43
  "farrapa": "^3.0.0-beta.10",
44
44
  "intre": "^3.0.0-beta.4",
45
- "joi": "^18.0.2",
46
- "lucide-react": "^0.577.0",
47
- "miolo-cli": "^3.0.0-beta.167",
45
+ "joi": "^18.1.1",
46
+ "lucide-react": "^1.7.0",
47
+ "miolo-cli": "^3.0.0-beta.169",
48
48
  "miolo-model": "file:../miolo-model",
49
- "miolo-react": "^3.0.0-beta.167",
49
+ "miolo-react": "^3.0.0-beta.169",
50
50
  "next-themes": "^0.4.6",
51
51
  "radix-ui": "^1.4.3",
52
52
  "react": "^19.2.4",
53
53
  "react-dom": "^19.2.4",
54
- "react-router": "^7.13.1",
55
- "recharts": "^3.8.0",
54
+ "react-router": "^7.13.2",
55
+ "recharts": "^3.8.1",
56
56
  "sonner": "^2.0.7",
57
57
  "tailwind": "^4.0.0",
58
58
  "tailwind-merge": "^3.5.0",
@@ -60,8 +60,8 @@
60
60
  "tw-animate-css": "^1.4.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@biomejs/biome": "2.4.8",
64
- "miolo": "^3.0.0-beta.167",
63
+ "@biomejs/biome": "2.4.9",
64
+ "miolo": "^3.0.0-beta.169",
65
65
  "sass-embedded": "^1.98.0"
66
66
  },
67
67
  "overrides": {
@@ -4,11 +4,12 @@ import useDataContext from "./useDataContext.mjs"
4
4
  const useBreads = (breadsCallback, dependencies = []) => {
5
5
  const { setTitle, setBreads } = useDataContext()
6
6
 
7
+ // biome-ignore lint/correctness/useExhaustiveDependencies: new function breadsCallback each render
7
8
  useEffect(() => {
8
9
  const nBreads = breadsCallback()
9
10
  setBreads(nBreads)
10
11
  setTitle(nBreads.slice(-1))
11
- }, dependencies) // eslint-disable-line
12
+ }, [setTitle, setBreads, ...dependencies])
12
13
  }
13
14
 
14
15
  export default useBreads
@@ -14,18 +14,21 @@ const TodosProvider = ({ children }) => {
14
14
  refresh: refreshTodoList,
15
15
  ready
16
16
  } = useSsrData("todos", {
17
- loader: async (_context, fetcher) => {
18
- //setStatus("loading")
19
- let data
20
- if (useCrud) {
21
- const res = await fetcher.read("/crud/todo")
22
- data = res.data
23
- } else {
24
- data = await fetcher.get("/api/todo/list")
25
- }
26
- //setStatus("loaded")
27
- return new TodoList(data.sort((a, b) => b.created_at - a.created_at))
28
- }
17
+ loader: useCallback(
18
+ async (_context, fetcher) => {
19
+ //setStatus("loading")
20
+ let data
21
+ if (useCrud) {
22
+ const res = await fetcher.read("/crud/todo")
23
+ data = res.data
24
+ } else {
25
+ data = await fetcher.get("/api/todo/list")
26
+ }
27
+ //setStatus("loaded")
28
+ return new TodoList(data.sort((a, b) => b.created_at - a.created_at))
29
+ },
30
+ [useCrud]
31
+ )
29
32
  })
30
33
 
31
34
  const addTodo = useCallback(
@@ -15,6 +15,7 @@ export async function r_todo_list(ctx, params) {
15
15
  }
16
16
  }
17
17
 
18
+ // biome-ignore lint/correctness/noUnusedFunctionParameters: params is not used
18
19
  export async function r_todo_last(ctx, params) {
19
20
  try {
20
21
  ctx.miolo.logger.info(`[r_todo_last] Reading last todos`)