Skip to content

Commit

Permalink
Setup dat-daemon-protocol module as per #7 discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Feb 21, 2018
1 parent 8ca84e7 commit 4c748da
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path')
const argv = require('minimist')(process.argv.slice(2))
const net = require('net')
const config = require('../lib/config')()
const {Instruction, Answer} = require('../lib/proto')
const {Instruction, Answer} = require('../protocol')
const {datResolve} = require('../lib/dat')
const help = require('../lib/help')

Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ function joinNetworks () {
}

module.exports.joinNetworks = joinNetworks

module.exports.config = require('./lib/config')
module.exports.protocol = require('./protocol')
3 changes: 3 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ if (!fs.existsSync(CONFIG_PATH)) {
fs.writeFileSync(CONFIG_PATH, JSON.stringify({
data: `${CONFIG_DIR}`,
database: 'database',
port: 8477,
http: false,
socket: 'datdaemon.sock'
}, null, 2))
}
Expand Down Expand Up @@ -47,6 +49,7 @@ function parseConfiguration () {
} catch (e) {}

config.socket = `${config.data}/${config.socket}`
config.port = config.port || 8477
config.database = `${config.data}/${config.database}`

if (process.env.DEBUG) {
Expand Down
2 changes: 1 addition & 1 deletion lib/database.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const level = require('level')
const config = require('./config')()
const db = level(config.database)
const {List} = require('../lib/proto')
const {List} = require('../protocol')

const KEY = 'list'

Expand Down
2 changes: 1 addition & 1 deletion lib/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {Instruction} = require('../lib/proto')
const {Instruction} = require('../protocol')

module.exports = help

Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions protocol/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "dat-daemon-protocol",
"version": "1.0.0",
"description": "Dat daemon protocol buffer",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/soyuka/dat-daemon.git"
},
"keywords": [
"dat",
"daemon"
],
"author": "soyuka",
"license": "MIT",
"bugs": {
"url": "https://github.com/soyuka/dat-daemon/issues"
},
"homepage": "https://github.com/soyuka/dat-daemon#readme"
}
2 changes: 1 addition & 1 deletion test/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('rimraf').sync(process.env.DATDAEMON_CONFIG)
const tape = require('tape')
const {create} = require('../lib/dat.js')
const {onmessage} = require('..')
const {Instruction, Answer} = require('../lib/proto')
const {Instruction, Answer} = require('../protocol')
const DAT_DIR = `${__dirname}/fixtures/dat`
const ACTION_REQUIRE_KEY = [Instruction.Action.REMOVE, Instruction.Action.START, Instruction.Action.PAUSE, Instruction.Action.STATISTICS]

Expand Down

0 comments on commit 4c748da

Please sign in to comment.