Commit dd64a0d510ecc727cffa7698d15154b14189b73c
empty
Michael Williams committed on 11/27/2015, 11:46:16 AMParent: a51858b13e497beda1e5deb1c48381c361a0ccfa
Files changed
app/server.js | changed |
app/services/index.js | changed |
app/services/static.js | changed |
package.json | changed |
.babelrc | added |
client.js | added |
server.js | added |
spec/index.js | added |
app/server.js | ||
---|---|---|
@@ -1,5 +1,11 @@ | ||
1 | 1 | const feathers = require('feathers') |
2 | +const { mapObj, reduce } = require('ramda') | |
2 | 3 | |
3 | -const { createServices } = require('./services') | |
4 | +const createServices = require('./services') | |
4 | 5 | |
5 | -createServices() | |
6 | +function start (config) { | |
7 | + const services = mapObj( | |
8 | + (serviceCreator, name) => serveCreator(config[name]), | |
9 | + serviceCreators | |
10 | + ) | |
11 | +} |
app/services/index.js | ||
---|---|---|
@@ -1,7 +1,23 @@ | ||
1 | -var fs = require('fs') | |
2 | -var { filter } = require('rambda') | |
1 | +const fs = require('fs') | |
2 | +const { map, filter, invoker, zip } = require('ramda') | |
3 | +const { join, basename } = require('path') | |
3 | 4 | |
4 | -filter( | |
5 | - fs.readdirSync(__dirname), | |
6 | - (name) => name.endsWith('index.js') | |
5 | +const serviceCreatorNames = filter( | |
6 | + (name) => name !== 'index', | |
7 | + map( | |
8 | + basename, | |
9 | + fs.readdirSync(__dirname) | |
10 | + ) | |
7 | 11 | ) |
12 | + | |
13 | +const serviceCreators = zip( | |
14 | + serviceCreatorNames, | |
15 | + map( | |
16 | + (name) => { | |
17 | + require(join(__dirname, name)) | |
18 | + }, | |
19 | + serviceCreatorNames | |
20 | + ) | |
21 | +) | |
22 | + | |
23 | +module.exports = serviceCreators |
app/services/static.js | ||
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | const serveStatic = require('serve-static') |
2 | 2 | |
3 | +module.exports = createStaticService | |
4 | + | |
3 | 5 | function createStaticService (config) { |
4 | 6 | return serveStatic(config.root, config) |
5 | 7 | } |
package.json | ||
---|---|---|
@@ -8,13 +8,12 @@ | ||
8 | 8 | "format": "snazzy --format", |
9 | 9 | "test": "(npm run spec & npm run feature)", |
10 | 10 | "spec": "node spec", |
11 | 11 | "feature": "node feature", |
12 | - "dev-server": "nodemon app/server", | |
13 | - "prod-server": "node app/server", | |
14 | - "dev-client": "budo app/client.js -d --serve bundle.js --live", | |
15 | - "prod-client": "browserify app/client.js -o bundle.js -g uglifyify" | |
16 | - | |
12 | + "dev-server": "nodemon server", | |
13 | + "prod-server": "node server", | |
14 | + "dev-client": "budo client -d --serve bundle.js --live", | |
15 | + "prod-client": "browserify client -o bundle.js -g uglifyify" | |
17 | 16 | }, |
18 | 17 | "repository": { |
19 | 18 | "type": "git", |
20 | 19 | "url": "git+https://github.com/ahdinosaur/craftworks-todomvc.git" |
@@ -44,7 +43,12 @@ | ||
44 | 43 | "nodemon": "^1.8.1", |
45 | 44 | "tape": "^4.2.2" |
46 | 45 | }, |
47 | 46 | "dependencies": { |
47 | + "babel-core": "^6.2.1", | |
48 | + "babel-plugin-transform-object-rest-spread": "^6.1.18", | |
49 | + "babel-preset-es2015": "^6.1.18", | |
50 | + "babel-preset-react": "^6.1.18", | |
51 | + "feathers": "^1.2.0", | |
48 | 52 | "ramda": "^0.18.0" |
49 | 53 | } |
50 | 54 | } |
.babelrc | ||
---|---|---|
@@ -1,0 +1,9 @@ | ||
1 | +{ | |
2 | + "presets": [ | |
3 | + "es2015", | |
4 | + "react" | |
5 | + ], | |
6 | + "plugins": [ | |
7 | + "transform-object-rest-spread" | |
8 | + ] | |
9 | +} |
client.js | ||
---|---|---|
@@ -1,0 +1,1 @@ | ||
1 | +require('./app/client') |
spec/index.js |
---|
Built with git-ssb-web