miolo 3.0.0-beta.183 → 3.0.0-beta.185

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.
@@ -45,7 +45,8 @@ export default async function (
45
45
  )
46
46
 
47
47
  // 4. Build Backend: Node server
48
- await miolo_build_server(appName, pkgPath, config, srvEntry, srvDest, srvExt)
48
+ const srvName = appName
49
+ await miolo_build_server(appName, pkgPath, config, srvEntry, srvDest, srvName, srvExt)
49
50
 
50
51
  console.log(`[${appName}][build] Build process completed successfully!`)
51
52
  process.exit(0)
@@ -0,0 +1,17 @@
1
+ import { cleanFolder } from "../util.mjs"
2
+ import { miolo_build_server } from "./server/index.mjs"
3
+
4
+ export default async function (appName, binEntry, binDest, binName, binExt) {
5
+ console.log(`[${appName}][build-bin] Starting full build process...`)
6
+
7
+ const pkgPath = process.cwd()
8
+
9
+ // 1. Clean destination folder
10
+ cleanFolder(binDest)
11
+
12
+ // 2. Build Backend script
13
+ await miolo_build_server(appName, pkgPath, {}, binEntry, binDest, binName, binExt)
14
+
15
+ console.log(`[${appName}][build-bin] Build process completed successfully!`)
16
+ process.exit(0)
17
+ }
@@ -4,23 +4,40 @@ import { miolo_bundle } from "./bundle.mjs"
4
4
  import { miolo_fix_prod_build } from "./fix.mjs"
5
5
  import { miolo_build_options_for_server } from "./options.mjs"
6
6
 
7
- async function _miolo_build_server(appName, pkgPath, srvEntry, srvDest, srvExt, watch = false) {
7
+ async function _miolo_build_server(
8
+ appName,
9
+ pkgPath,
10
+ srvEntry,
11
+ srvDest,
12
+ srvName,
13
+ srvExt,
14
+ watch = false
15
+ ) {
8
16
  const [esmnInputOptions, esmnOutputs, outputFile] = await miolo_build_options_for_server(
9
17
  appName,
10
18
  pkgPath,
11
19
  srvEntry,
12
20
  srvDest,
21
+ srvName,
13
22
  srvExt
14
23
  )
15
24
  await miolo_bundle(appName, pkgPath, esmnInputOptions, esmnOutputs, watch)
16
25
  await miolo_fix_prod_build(appName, outputFile)
17
26
  }
18
27
 
19
- export async function miolo_build_server(appName, pkgPath, _config, srvEntry, srvDest, srvExt) {
28
+ export async function miolo_build_server(
29
+ appName,
30
+ pkgPath,
31
+ _config,
32
+ srvEntry,
33
+ srvDest,
34
+ srvName,
35
+ srvExt
36
+ ) {
20
37
  // const watch = config.build.dev.watcher?.enabled === true
21
38
  const watch = false
22
39
 
23
- await _miolo_build_server(appName, pkgPath, srvEntry, srvDest, srvExt, watch)
40
+ await _miolo_build_server(appName, pkgPath, srvEntry, srvDest, srvName, srvExt, watch)
24
41
 
25
42
  if (watch) {
26
43
  const srcFolder = path.join(pkgPath, "src")
@@ -16,15 +16,16 @@ import { miolo_build_banner } from "./banner.mjs"
16
16
  const NODE_ENV = process.env?.NODE_ENV || "production"
17
17
 
18
18
  export async function miolo_build_options_for_server(
19
- appName,
19
+ _appName,
20
20
  pkgPath,
21
21
  srvEntry,
22
22
  srvDest,
23
+ srvName,
23
24
  srvExt,
24
25
  bundleDeps = true
25
26
  ) {
26
27
  const input = path.join(pkgPath, srvEntry)
27
- const outputFile = path.join(pkgPath, srvDest, `${appName}.${srvExt}`)
28
+ const outputFile = path.join(pkgPath, srvDest, `${srvName}.${srvExt}`)
28
29
 
29
30
  const inputOptions = {
30
31
  input,
package/bin/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import path from "node:path"
2
3
  import yargs from "yargs-parser"
3
4
  import { init_env_config } from "../src/config/env.mjs"
4
5
 
@@ -42,6 +43,11 @@ async function main() {
42
43
  const srvExt = args["server-ext"] || process.env.MIOLO_BUILD_SERVER_EXT || "node.bundle.mjs"
43
44
  const ssrEntry = args["ssr-entry"] || process.env.MIOLO_BUILD_SERVER_SSR_ENTRY
44
45
  const ssrDest = args["ssr-dest"] || process.env.MIOLO_BUILD_SERVER_DEST || "./build/server"
46
+ const binDest = args["bin-dest"] || "./build/bin"
47
+ const binEntry = args["bin-entry"]
48
+ const binName =
49
+ args["bin-name"] || (binEntry ? path.basename(binEntry, path.extname(binEntry)) : "")
50
+ const binExt = args["bin-ext"] || "node.bundle.mjs"
45
51
 
46
52
  switch (command) {
47
53
  case "dev": {
@@ -76,6 +82,12 @@ async function main() {
76
82
  break
77
83
  }
78
84
 
85
+ case "build-bin": {
86
+ const buildHandler = (await import("./build/build_bin.mjs")).default
87
+ await buildHandler(appName, binEntry, binDest, binName, binExt)
88
+ break
89
+ }
90
+
79
91
  case "start": {
80
92
  const startHandler = (await import("./run/start.mjs")).default
81
93
  await startHandler(appName, srvDest, srvExt)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miolo",
3
- "version": "3.0.0-beta.183",
3
+ "version": "3.0.0-beta.185",
4
4
  "description": "all-in-one koa-based server",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -19,6 +19,12 @@ export default function make_config_defaults() {
19
19
  ? process.env?.MIOLO_HOSTNAME_DOCKER || "0.0.0.0"
20
20
  : process.env?.MIOLO_HOSTNAME || "localhost",
21
21
 
22
+ ssl: undefined,
23
+ //ssl: {
24
+ // key: fs.readFileSync('.../key.pem'),
25
+ // cert: fs.readFileSync('.../cert.pem'),
26
+ // }
27
+
22
28
  catcher_url: "/sys/jserror",
23
29
 
24
30
  static: {
@@ -1,4 +1,5 @@
1
1
  import http from "node:http"
2
+ import https from "node:https"
2
3
  //import util from 'util'
3
4
  import { createHttpTerminator } from "http-terminator"
4
5
 
@@ -37,7 +38,14 @@ export function init_http_server(app, config) {
37
38
  }
38
39
 
39
40
  // Init server
40
- const server = http.createServer(app.callback())
41
+ const server =
42
+ config?.ssl === undefined
43
+ ? http.createServer(app.callback())
44
+ : https
45
+ .createServer(config.ssl, app.callback())
46
+ .listen(config.port, config.hostname, () => {
47
+ logger.info("[http][start] Server running at https://localhost:8010")
48
+ })
41
49
 
42
50
  // Init terminator
43
51
  const httpTerminator = createHttpTerminator({
@@ -26,7 +26,7 @@ import { init_session_middleware } from "./session/index.mjs"
26
26
 
27
27
  const def_get_user_id = async (user, _ctx) => user?.id
28
28
 
29
- const def_find_user_by_id = async (_id, ctx) => {
29
+ const def_find_user_by_id = async (_id, _ctx) => {
30
30
  throw new Error("You need to define auth.passport.find_user_by_id")
31
31
  }
32
32
 
@@ -13,6 +13,7 @@
13
13
  "deb": "npx miolo deb",
14
14
  "create-bin": "npx miolo create-bin",
15
15
  "build": "rm -fr build/cli/* build/server/* &&npx miolo build && npm run create-bin",
16
+ "build-bin": "npx miolo build-bin --bin-entry=src/server/console/check_today.mjs",
16
17
  "start": "node ./build/server/run.mjs start 1>> /var/log/miolo-sample.log 2>&1",
17
18
  "stop": "node ./build/server/run.mjs stop 1>> /var/log/miolo-sample.log 2>&1",
18
19
  "restart": "node ./build/server/run.mjs restart 1>> /var/log/miolo-sample.log 2>&1"
@@ -44,9 +45,9 @@
44
45
  "intre": "^3.0.0-beta.4",
45
46
  "joi": "^18.1.2",
46
47
  "lucide-react": "^1.14.0",
47
- "miolo-cli": "^3.0.0-beta.183",
48
+ "miolo-cli": "^3.0.0-beta.185",
48
49
  "miolo-model": "file:../miolo-model",
49
- "miolo-react": "^3.0.0-beta.183",
50
+ "miolo-react": "^3.0.0-beta.185",
50
51
  "next-themes": "^0.4.6",
51
52
  "radix-ui": "^1.4.3",
52
53
  "react": "^19.2.5",
@@ -61,7 +62,7 @@
61
62
  },
62
63
  "devDependencies": {
63
64
  "@biomejs/biome": "2.4.14",
64
- "miolo": "^3.0.0-beta.183",
65
+ "miolo": "^3.0.0-beta.185",
65
66
  "sass-embedded": "^1.99.0"
66
67
  },
67
68
  "overrides": {
@@ -0,0 +1,10 @@
1
+ import { intre_now, intre_pretty_long } from "intre"
2
+
3
+ function check_today() {
4
+ const now = intre_now()
5
+ const today = intre_pretty_long(now)
6
+ console.log(`[miolo-sample][check_today] Today is ${today}`)
7
+ return today
8
+ }
9
+
10
+ check_today()
@@ -1,7 +1,7 @@
1
1
  import { db_todo_find } from "#server/db/io/todos/find.mjs"
2
2
  import { db_todo_read } from "#server/db/io/todos/read.mjs"
3
3
 
4
- export async function r_todo_list(ctx, params) {
4
+ export async function r_todo_list(ctx, _params) {
5
5
  try {
6
6
  ctx.miolo.logger.info(`[r_todo_list] Reading todo list`)
7
7
 
@@ -18,4 +18,4 @@
18
18
  "type": "image/png"
19
19
  }
20
20
  ]
21
- }
21
+ }
@@ -2,7 +2,7 @@ const CACHE_NAME = "miolo-sample-cache-v1"
2
2
 
3
3
  // 1. EVENTO INSTALL: Ocurre la primera vez que el usuario entra.
4
4
  // Aquí cacheamos el "App Shell" (lo básico para que la app abra sin red).
5
- self.addEventListener("install", (event) => {
5
+ self.addEventListener("install", (_event) => {
6
6
  /*console.log(`[miolo][sw] installing`)
7
7
  event.waitUntil(
8
8
  caches.open(CACHE_NAME).then((cache) => {
@@ -33,7 +33,7 @@ self.addEventListener("activate", (event) => {
33
33
  })
34
34
 
35
35
  // 3. EVENTO FETCH: El núcleo de tu estrategia
36
- self.addEventListener("fetch", (event) => {
36
+ self.addEventListener("fetch", (_event) => {
37
37
  /*console.log(`[miolo][sw] fetching`)
38
38
  // ESTRATEGIA PARA LLAMADAS POST
39
39
  if (event.request.method === "POST" || event.request.method === "PUT") {