nv-id-info-local-srv
v1.0.3
Published
nv-id-info-local-srv ======================= - a http-service for small scale data (read much, write less, such as config-info)
Downloads
2
Readme
nv-id-info-local-srv
- a http-service for small scale data (read much, write less, such as config-info)
install
- npm install nv-id-info-local-srv
- npm install -g nv-id-info-local-srv 【if need use cli】
usage
const x = require("nv-id-info-local-srv");
example
//server:
var x = require("nv-id-info-local-srv")
> var srv await x.creat_on_dflt()
listen on: /home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___
success: {
front_url: '/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___#',
workdir: '/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_workdir___'
}
front_lib
const creat_client= require("nv-id-info-local-nd-client");
var auth_data = new Map([["aaa","bbb"],["ccc",{}]]);
var c = creat_client("/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___#",auth_data);
await c.join() -> [Boolean,info]
await c.exit() -> [Boolean,info]
await c.updt(new_auth_data)-> [Boolean,info]
await c.list(offset.limit) -> Array<uint32_t> | Error
Srv {
cfg: OtherCfg {
using_uwebsocket: false,
other_handle: [AsyncFunction: DFLT_OTHER_HANDLE],
chown_to_user: 'www-data',
key_buf: undefined,
cert_buf: undefined,
max_cnt: 1048576,
each_group_cnt: 1024,
auth_func: [AsyncFunction: auth_func]
}
}
// client
const creat_client= require("nv-id-info-local-nd-client");
var auth_data = new Map([["aaa","bbb"],["ccc",{}]]);
var c = creat_client("/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___#",auth_data);
> c
Client {
nvurl: '/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___#',
auth_data: Map(2) { 'aaa' => 'bbb', 'ccc' => {} },
joined: false,
id: 0,
f64passwd: null
}
>
>
> await c.join()
[ true, { id: 7, f64passwd: 1713874946104.5366 } ]
>
> c
Client {
nvurl: '/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_usock___#',
auth_data: Map(2) { 'aaa' => 'bbb', 'ccc' => {} },
joined: true,
id: 7,
f64passwd: 1713874946104.5366
}
>
//on server :
> srv.db_.memd[0]
{
'1713868067660.616': { id: 1, f64passwd: 1713868067660.616, data: [ 1, 2, 3 ] },
'1713868072937.5935': { id: 2, f64passwd: 1713868072937.5935, data: [ 1, 2, 3 ] },
'1713869260961.5337': { id: 3, f64passwd: 1713869260961.5337, data: [ 888 ] },
'1713872338975.5935': { id: 4, f64passwd: 1713872338975.5935, data: { uname: 123 } },
'1713872433136.774': { id: 5, f64passwd: 1713872433136.774, data: { uname: 123 } },
'1713874785343.325': { id: 6, f64passwd: 1713874785343.325, data: {} },
'1713874946104.5366': {
id: 7,
f64passwd: 1713874946104.5366,
data: Map(2) { 'aaa' => 'bbb', 'ccc' => {} }
}
}
> srv.db_.memd[0]['1713874946104.5366']
{
id: 7,
f64passwd: 1713874946104.5366,
data: Map(2) { 'aaa' => 'bbb', 'ccc' => {} }
}
>
//cli :
nv_cli_show_id_info_srv_data "./___nv_id_info_local_srv_workdir___/g0"
/home/cu-lib/nv-id-info-local-srv/___nv_id_info_local_srv_workdir___/g0
{
'1713868067660.616': { id: 1, f64passwd: 1713868067660.616, data: [ 1, 2, 3 ] },
'1713868072937.5935': { id: 2, f64passwd: 1713868072937.5935, data: [ 1, 2, 3 ] },
'1713869260961.5337': { id: 3, f64passwd: 1713869260961.5337, data: [ 888 ] },
'1713872338975.5935': { id: 4, f64passwd: 1713872338975.5935, data: { uname: 123 } },
'1713872433136.774': { id: 5, f64passwd: 1713872433136.774, data: { uname: 123 } },
'1713874785343.325': { id: 6, f64passwd: 1713874785343.325, data: {} },
'1713874946104.5366': {
id: 7,
f64passwd: 1713874946104.5366,
data: Map(2) { 'aaa' => 'bbb', 'ccc' => {} }
}
}
METHODS
APIS
LICENSE
- ISC