instaserve 0.1.14 → 0.1.15

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/bun/http.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import {existsSync} from 'fs'
2
- import routes from '../routes.mjs'
3
- console.log(routes)
2
+ import { pathToFileURL } from 'node:url'
3
+ import { resolve } from 'node:path'
4
+ const routesfile = resolve(process.env.routes || '../routes.mjs')
5
+ const routesurl = pathToFileURL(routesfile).href
6
+
7
+ const routes = (await import(routesurl)).default
8
+ const port = process.env.port || 3000
4
9
 
5
10
  class s {
6
11
  end(s) {
@@ -9,7 +14,7 @@ class s {
9
14
  }
10
15
 
11
16
  Bun.serve({
12
- port: 3000,
17
+ port: port,
13
18
  async fetch(r) {
14
19
 
15
20
  let url = new URL(r.url).pathname
@@ -42,4 +47,4 @@ Bun.serve({
42
47
  }
43
48
  })
44
49
 
45
- console.log('Running on 3000')
50
+ console.log(`Started on: ${port}, using routes: ${Object.keys(routes)}`)
package/deno/server.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { existsSync } from "https://deno.land/std/fs/mod.ts";
2
- import routes from '../routes.mjs'
3
- console.log(routes)
2
+
3
+ const routesfile = Deno.env.get('routes') || '../routes.mjs'
4
+ const port = Deno.env.get('port') || 3000
5
+ const routes = (await import(routesfile)).default
4
6
 
5
7
  class s {
6
8
  end(s) {
@@ -32,4 +34,6 @@ Deno.serve(async (r) => {
32
34
 
33
35
  return new Response('', { status: 404 })
34
36
 
35
- }, {port: 3000})
37
+ }, {port: port})
38
+
39
+ console.log(`routes: ${Object.keys(routes)}`)
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "instaserve",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Instant web stack",
5
5
  "main": "module.mjs",
6
6
  "bin": "./server.mjs",
7
7
  "scripts": {
8
8
  "start": "node server.mjs",
9
- "deno": "deno run --unstable --allow-net --allow-read deno/server.js",
9
+ "deno": "deno run --allow-env --unstable --allow-net --allow-read deno/server.js",
10
10
  "bun": "bun run bun/http.js",
11
11
  "test": "node --no-warnings test.mjs"
12
12
  }