Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit ca24a42

Browse files
committed
Merge branch 'release/0.3.0-rc.4-docker'
2 parents 578ff67 + 2aebf35 commit ca24a42

File tree

5 files changed

+77
-42
lines changed

5 files changed

+77
-42
lines changed

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:12
2+
3+
RUN mkdir api
4+
5+
WORKDIR /api
6+
7+
COPY . .
8+
9+
RUN npm ci --only=prod
10+
11+
CMD ["node", "src/cli.js"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- [POST|PUT /db/:dbname/put](#postput-dbdbnameput)
2727
- [POST|PUT /db/:dbname/inc](#postput-dbdbnameinc)
2828
- [POST|PUT /db/:dbname/inc/:val](#postput-dbdbnameincval)
29-
- [POST|PUT /db/:dbname/access/writ](#postput-dbdbnameaccesswrite)
29+
- [POST|PUT /db/:dbname/access/write](#postput-dbdbnameaccesswrite)
3030
- [DELETE /db/:dbname](#delete-dbdbname)
3131
- [DELETE /db/:dbname/:item](#delete-dbdbnameitem)
3232
- [Contribute](#contribute)

package-lock.json

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{
2-
"name": "orbit-db-http-api",
3-
"version": "0.3.0-rc.4",
4-
"description": "An HTTP API Server for the OrbitDB distributed peer-to-peer database",
5-
"main": "src/cli.js",
6-
"keywords": [
7-
"orbitdb",
8-
"orbit-db",
9-
"http",
10-
"api",
11-
"server",
12-
"peer-to-peer",
13-
"database",
14-
"db"
15-
],
16-
"scripts": {
17-
"test": "echo \"Error: no test specified\" && exit 1"
18-
},
19-
"author": "Phillip Mackintosh, Hayden Young",
20-
"license": "MIT",
21-
"repository": {
22-
"type": "git",
23-
"url": "https://github.com/orbitdb/orbit-db-http-api.git"
24-
},
25-
"engines": {
26-
"node": ">=10.0.0"
27-
},
28-
"dependencies": {
29-
"docopt": "~0.6.2",
30-
"hapi": ">17.0.0",
31-
"http2":"^3.2.0",
32-
"ipfs": "^0.36.3",
33-
"ipfs-http-client": "^30.0.0",
34-
"orbit-db": "^0.21.1",
35-
"susie": "^3.0.0"
36-
}
2+
"name": "orbit-db-http-api",
3+
"version": "0.3.0-rc.4",
4+
"description": "An HTTP API Server for the OrbitDB distributed peer-to-peer database",
5+
"main": "src/cli.js",
6+
"keywords": [
7+
"orbitdb",
8+
"orbit-db",
9+
"http",
10+
"api",
11+
"server",
12+
"peer-to-peer",
13+
"database",
14+
"db"
15+
],
16+
"scripts": {
17+
"test": "echo \"Error: no test specified\" && exit 1"
18+
},
19+
"author": "Phillip Mackintosh, Hayden Young",
20+
"license": "MIT",
21+
"repository": {
22+
"type": "git",
23+
"url": "https://github.com/orbitdb/orbit-db-http-api.git"
24+
},
25+
"engines": {
26+
"node": ">=10.0.0"
27+
},
28+
"dependencies": {
29+
"docopt": "~0.6.2",
30+
"hapi": ">17.0.0",
31+
"http2": "^3.2.0",
32+
"ipfs": "^0.36.3",
33+
"ipfs-http-client": "^30.0.0",
34+
"js-logger": "^1.6.0",
35+
"orbit-db": "^0.21.1",
36+
"susie": "^3.0.0"
3737
}
38+
}

src/lib/db-manager.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,25 @@ class DBManager {
5050
return JSON.stringify(db_info_list);
5151
};
5252

53+
let _db_write = (db) => {
54+
return (
55+
db.access.write ||
56+
(typeof db.access.get == 'function' && db.access.get('write')) ||
57+
db.access._options.write ||
58+
'unavaliable'
59+
);
60+
}
61+
62+
this.db_write = (dbn) => {
63+
let db = find_db(dbn);
64+
if (!db) return {};
65+
return _db_write(db);
66+
}
67+
5368
this.db_info = (dbn) => {
5469
let db = find_db(dbn);
5570
if (!db) return {};
71+
let __db_write = _db_write(db)
5672
return {
5773
address: db.address,
5874
dbname: db.dbname,
@@ -66,10 +82,12 @@ class DBManager {
6682
path: db.options.path,
6783
replicate: db.options.replicate,
6884
},
69-
canAppend: db.access.write.includes(orbitdb.identity.id),
70-
write: db.access.write,
85+
canAppend: __db_write.includes(orbitdb.identity.id),
86+
write: __db_write,
7187
type: db.type,
7288
uid: db.uid,
89+
indexLength: db.index.length || Object.keys(db.index).length,
90+
accessControlerType: db.access.type || 'custom',
7391
capabilities: Object.keys( //TODO: cleanup this mess once tc39 object.fromEntries aproved
7492
Object.assign ({}, ... // https://tc39.github.io/proposal-object-from-entries
7593
Object.entries({

0 commit comments

Comments
 (0)