Skip to content

Commit

Permalink
refactor: rename lib/ to server/
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed May 8, 2016
1 parent f998f01 commit 82897fd
Show file tree
Hide file tree
Showing 43 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions CODING_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ In the root, have
In most cases you will have `index.js` file which is listed in `package.json`
as the `"main"` property.

If you want to split up logic into separate files, move them into a `lib/` folder.
Put reusable, state-less helper methods into `lib/utils/`
If you want to split up logic into separate files, move them into a `server/` folder.
Put reusable, state-less helper methods into `server/utils/`

For tests, create a `test/` folder. If your module becomes a bit more complex,
split up the tests in `test/unit` and `test/integration/`. All files that contain
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Hoodie lets you build apps [without _thinking_ about the backend](http://nobacke
and makes sure that they work great [independent from connectivity](http://offlinefirst.org/).

This is Hoodie’s main repository. It starts a server and serves the client API.
Read more about [how things work](lib).
Read more about [how the Hoodie server works](server).

A good place to start is our [Tracker App](https://github.com/hoodiehq/hoodie-app-tracker).
You can play around with Hoodie’s APIs in the browser console and see how it
Expand Down
2 changes: 1 addition & 1 deletion bin/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var rc = require('rc')
var relative = require('require-relative')
var semver = require('semver')

var getHoodieServer = require('../lib')
var getHoodieServer = require('../server')

var useEmoji = process.platform === 'darwin'

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bin": {
"hoodie": "./bin/start.js"
},
"main": "lib/index.js",
"main": "server/index.js",
"bugs": {
"url": "https://github.com/hoodiehq/hoodie/issues"
},
Expand Down
6 changes: 3 additions & 3 deletions lib/README.md → server/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[back to hoodie](../README.md)

# How Hoodie works
# hoodie/server

After [installing hoodie](../#setup), `npm start` will run [bin/start.js](../bin/start.js)
which reads out [configuration](../#usage) from all the different places using
the [rc](https://www.npmjs.com/package/rc) package, then passes it as options to
`getHoodieServer`, the main function returned by this package, defined in
[lib/index.js](index.js).
[server/index.js](index.js).

Hoodie is built on [Hapi](https://hapijs.com).

Expand All @@ -21,7 +21,7 @@ Hoodie uses [CouchDB](https://couchdb.apache.org/) for data persistence and
authentication. If `options.dbUrl` is not set, it falls back to [PouchDB](https://pouchdb.com/).

Once all configuration is taken care of, the internal plugins are initialised
(see [lib/plugins/index.js](plugins/index.js)). We define simple Hapi plugins
(see [server/plugins/index.js](plugins/index.js)). We define simple Hapi plugins
for [logging](plugins/log.js) and for [serving the app’s public assets and the Hoodie client](plugins/public.js).
We also load the core modules and register them with the Hapi server.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/unit/assure-folders-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var test = require('tap').test
test('assure config folders', function (group) {
group.test('without config.db.prefix', function (t) {
var mkdirpMock = simple.stub().callbackWith(null)
var assureFolders = proxyquire('../../lib/config/assure-folders', {
var assureFolders = proxyquire('../../server/config/assure-folders', {
mkdirp: mkdirpMock
})

Expand All @@ -28,7 +28,7 @@ test('assure config folders', function (group) {

group.test('with config.db.prefix', function (t) {
var mkdirpMock = simple.stub().callbackWith(null)
var assureFolders = proxyquire('../../lib/config/assure-folders', {
var assureFolders = proxyquire('../../server/config/assure-folders', {
mkdirp: mkdirpMock
})

Expand Down
2 changes: 1 addition & 1 deletion test/unit/bundle-client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('bundle client', function (t) {
pipe: simple.stub(),
on: simple.stub()
}
var bundleClient = proxyquire('../../lib/bundle-client', {
var bundleClient = proxyquire('../../server/bundle-client', {
npmlog: {
silly: simple.stub(),
info: simple.stub()
Expand Down
6 changes: 3 additions & 3 deletions test/unit/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('config', function (group) {
var pouchDbConfigMock = simple.stub().callbackWith(null)
var storeConfigMock = simple.stub().callbackWith(null)

var getConfig = proxyquire('../../lib/config', {
var getConfig = proxyquire('../../server/config', {
'./account': accountConfigMock,
'./assure-folders': assureFolders,
'./db/couchdb': couchDbConfigMock,
Expand Down Expand Up @@ -74,7 +74,7 @@ test('config', function (group) {
var pouchDbConfigMock = simple.stub().callbackWith(null)
var storeConfigMock = simple.stub().callbackWith(null)

var getConfig = proxyquire('../../lib/config', {
var getConfig = proxyquire('../../server/config', {
'./account': accountConfigMock,
'./assure-folders': assureFolders,
'./db/couchdb': couchDbConfigMock,
Expand Down Expand Up @@ -121,7 +121,7 @@ test('config', function (group) {
var pouchDbConfigMock = simple.stub().callbackWith(null)
var storeConfigMock = simple.stub().callbackWith(null)

var getConfig = proxyquire('../../lib/config', {
var getConfig = proxyquire('../../server/config', {
'./account': accountConfigMock,
'./assure-folders': assureFolders,
'./db/couchdb': couchDbConfigMock,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/account-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var test = require('tap').test
var pouchdbUsersStub = {
'@noCallThru': true
}
var accountConfig = proxyquire('../../../lib/config/account', {
var accountConfig = proxyquire('../../../server/config/account', {
'pouchdb-users': pouchdbUsersStub
})

Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/db-couchdb-check-vendor-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var log = require('npmlog')
var test = require('tap').test

var checkVendor = require('../../../lib/config/db/couchdb-check-vendor.js')
var checkVendor = require('../../../server/config/db/couchdb-check-vendor.js')

test('check couch vendor', function (group) {
group.test('request fails', function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/db-couchdb-get-admins-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var test = require('tap').test

var getAdmins = require('../../../lib/config/db/couchdb-get-admins.js')
var getAdmins = require('../../../server/config/db/couchdb-get-admins.js')

test('get couch admins', function (group) {
group.test('request fails', function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/db-couchdb-get-config-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var test = require('tap').test

var getConfig = require('../../../lib/config/db/couchdb-get-config.js')
var getConfig = require('../../../server/config/db/couchdb-get-config.js')

test('get couch config', function (group) {
group.test('request fails', function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/db-couchdb-set-config-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var test = require('tap').test

var setConfig = require('../../../lib/config/db/couchdb-set-config.js')
var setConfig = require('../../../server/config/db/couchdb-set-config.js')

test('set couch config', function (group) {
group.test('request fails', function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/db-couchdb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nock('http://127.0.0.1:5984')
})

test('init couchdb', function (group) {
var couchdb = require('../../../lib/config/db/couchdb')
var couchdb = require('../../../server/config/db/couchdb')

couchdb({
config: {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/config/db-factory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('database api factory', function (group) {
return PouchDB
}

var database = proxyquire('../../../lib/config/db/factory', {
var database = proxyquire('../../../server/config/db/factory', {
pouchdb: PouchDB
})({db: {foo: 'foo'}})

Expand All @@ -36,7 +36,7 @@ test('database api factory', function (group) {
return PouchDB
}

var database = proxyquire('../../../lib/config/db/factory', {
var database = proxyquire('../../../server/config/db/factory', {
pouchdb: PouchDB
})({db: {url: 'http://example.com'}})

Expand Down
4 changes: 2 additions & 2 deletions test/unit/config/db-pouchdb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var proxyquire = require('proxyquire')

test('generate couch config', function (group) {
group.test('read from file', function (t) {
var pouchDbConfig = proxyquire('../../../lib/config/db/pouchdb.js', {
var pouchDbConfig = proxyquire('../../../server/config/db/pouchdb.js', {
fs: {
existsSync: function () {
return true
Expand Down Expand Up @@ -36,7 +36,7 @@ test('generate couch config', function (group) {
})

group.test('generate and write to file', function (t) {
var pouchDbConfig = proxyquire('../../../lib/config/db/pouchdb.js', {
var pouchDbConfig = proxyquire('../../../server/config/db/pouchdb.js', {
fs: {
existsSync: function () {
return false
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/parse-options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var memdownMock = {
'@noCallThru': true
}

var parseOptions = proxyquire('../../../lib/config/parse-options', {
var parseOptions = proxyquire('../../../server/config/parse-options', {
'memdown': memdownMock,
'npmlog': logMock,
'./defaults': getDefaultsMock
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/store-pre-auth-hook-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var test = require('tap').test
var BoomStub = {
'@noCallThru': true
}
var preAuthHook = proxyquire('../../../lib/config/store/pre-auth-hook', {
var preAuthHook = proxyquire('../../../server/config/store/pre-auth-hook', {
'boom': BoomStub
})

Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var test = require('tap').test
var preAuthHookStub = {
'@noCallThru': true
}
var storeConfig = proxyquire('../../../lib/config/store', {
var storeConfig = proxyquire('../../../server/config/store', {
'./pre-auth-hook': preAuthHookStub
})

Expand Down
2 changes: 1 addition & 1 deletion test/unit/plugins-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var simple = require('simple-mock')
var test = require('tap').test
var proxyquire = require('proxyquire').noCallThru()

var registerPlugins = proxyquire('../../lib/plugins', {
var registerPlugins = proxyquire('../../server/plugins', {
'@hoodie/store': function () {},
'@hoodie/account': function () {}
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var test = require('tap').test
require('npmlog').level = 'silent'

var removeAuth = require('../../lib/utils/remove-auth-from-url')
var removeAuth = require('../../server/utils/remove-auth-from-url')

test('utils', function (group) {
group.test('removeAuth', function (group) {
Expand Down

0 comments on commit 82897fd

Please sign in to comment.