instaserve 0.0.19 → 1.0.20

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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import http from 'node:http'
3
3
  import fs from 'node:fs'
4
- import {pathToFileURL} from 'node:url'
4
+ import { pathToFileURL } from 'node:url'
5
5
  import { resolve } from 'node:path'
6
6
 
7
7
  const routesfile = resolve('routes.mjs')
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "instaserve",
3
- "version": "0.0.19",
3
+ "version": "1.0.20",
4
4
  "bin": "./index.mjs"
5
- }
5
+ }
package/db.json DELETED
@@ -1 +0,0 @@
1
- [["user:admin",{"type":"user","name":"admin","pass":"01b613da484bee91c3f3806b52a6f40fd61ade874b5ffc0f62a2091cce38158b","id":"user:admin"}]]
package/routes.mjs DELETED
@@ -1,5 +0,0 @@
1
- export default {
2
- _debug: ({ r, s, db }) => console.log(r.url, r.method),
3
- '/': ({ s }) => s.endJSON({ message: 'hello index' }),
4
- 'tables': name => ([k, v]) => k.match(`${name}:`)
5
- }
package/vastdb.mjs DELETED
@@ -1,42 +0,0 @@
1
- import fs from 'node:fs'
2
- export default class VastDB extends Map {
3
- constructor(v) {
4
- super();
5
- this.filename = `${process.cwd()}/db.json`;
6
- this.views = v
7
- if (!fs.existsSync(this.filename)) {
8
- this.set({
9
- type: 'user',
10
- name: 'admin',
11
- pass: '01b613da484bee91c3f3806b52a6f40fd61ade874b5ffc0f62a2091cce38158b',
12
- });
13
- console.log('creating db');
14
- } else {
15
- const sf = JSON.parse(fs.readFileSync(this.filename, 'utf8'));
16
- sf.map(([k, v]) => {
17
- v.id = k;
18
- this.set(v);
19
- });
20
- }
21
- }
22
- query(q = () => false) {
23
- return [...this].filter(q).map(([k, v]) => v)
24
- }
25
- getView(name, param) {
26
- const res = [...this].filter(this.views[name](param));
27
- return res.map(([k, v]) => v);
28
- }
29
- set(arr) {
30
- if (!arr.push) arr = [arr];
31
- for (const o of arr) {
32
- if (!o.name || !o.type) return false;
33
- if (!o.id) o.id = o.type + ':' + o.name;
34
- }
35
- arr.map((o) => super.set(o.id, o));
36
- if(this.event) this.event(arr)
37
- this.save();
38
- }
39
- save() {
40
- fs.writeFileSync(this.filename, JSON.stringify([...this.entries()]));
41
- }
42
- }