Commit 33c8c3ea806c7b24197e47850836a31c48daefd6
setup todos service
Michael Williams committed on 1/8/2016, 3:19:03 AMParent: d7bb4a1cb809f7db3135cc7d21052d9c2636bd45
Files changed
.gitignore | changed |
app/api.js | changed |
app/todos/service.js | changed |
config/development.js | changed |
package.json | changed |
knexfile.js | added |
migrations/20160108004846_create_todos.js | added |
app/api.js | ||
---|---|---|
@@ -4,27 +4,29 @@ | ||
4 | 4 | import rest from 'feathers-rest' |
5 | 5 | import bodyParser from 'body-parser' |
6 | 6 | import { map, mapObjIndexed, reduce, toPairs } from 'ramda' |
7 | 7 | |
8 | -const services = { | |
9 | - ...map( | |
8 | +import memory from 'feathers-memory' | |
9 | + | |
10 | +const services = Object.assign( | |
11 | + map( | |
10 | 12 | (module) => module.service.default, |
11 | 13 | bulk(__dirname, '*/service.js') |
12 | 14 | ), |
13 | - ...map( | |
15 | + map( | |
14 | 16 | (module) => module.services.map(m => m.default), |
15 | 17 | bulk(__dirname, '*/services/*.js') |
16 | 18 | ) |
17 | -} | |
19 | +) | |
18 | 20 | |
19 | 21 | export default module.exports = createApi |
20 | 22 | |
21 | 23 | function createApi (config) { |
22 | 24 | const app = feathers() |
23 | 25 | .configure(rest()) |
24 | - .configure(hooks()) | |
25 | 26 | .use(bodyParser.json()) |
26 | 27 | .use(bodyParser.urlencoded({ extended: true })) |
28 | + .configure(hooks()) | |
27 | 29 | |
28 | 30 | useAll(app, services) |
29 | 31 | |
30 | 32 | return app |
app/todos/service.js | ||
---|---|---|
@@ -7,10 +7,10 @@ | ||
7 | 7 | |
8 | 8 | export default knexService({ |
9 | 9 | Model: db, |
10 | 10 | name: 'todos' |
11 | -}).extend({ | |
12 | - setup: function (app) { | |
13 | - this._super && this._super(app) | |
14 | - validate(app.service('todos'), Todo) | |
15 | - } | |
16 | 11 | }) |
12 | +//.extend({ | |
13 | +// setup: function (app) { | |
14 | +// validate(app.service('todos'), Todo) | |
15 | +// } | |
16 | +//}) |
config/development.js | ||
---|---|---|
@@ -1,10 +1,17 @@ | ||
1 | 1 | const join = require('path').join |
2 | 2 | |
3 | 3 | module.exports = { |
4 | 4 | db: { |
5 | - client: 'sqlite3', | |
5 | + client: 'pg', | |
6 | 6 | connection: { |
7 | - filename: join(__dirname, '..', 'db.sqlite') | |
7 | + host : 'localhost', | |
8 | + user : 'postgres', | |
9 | + //password : 'postgres', | |
10 | + database : 'postgres' | |
11 | + }, | |
12 | + pool: { | |
13 | + min: 0, | |
14 | + max: 1 | |
8 | 15 | } |
9 | 16 | } |
10 | 17 | } |
package.json | ||
---|---|---|
@@ -2,8 +2,9 @@ | ||
2 | 2 | "name": "business-stack", |
3 | 3 | "version": "0.0.0", |
4 | 4 | "description": "real-world production-quality TodoMVC example", |
5 | 5 | "scripts": { |
6 | + "knex": "knex", | |
6 | 7 | "postinstall": "lnfs app node_modules/app", |
7 | 8 | "lint": "snazzy", |
8 | 9 | "format": "snazzy --format", |
9 | 10 | "test": "npm-run-all -p test:*", |
@@ -61,8 +62,9 @@ | ||
61 | 62 | "babel-plugin-react-transform": "^2.0.0", |
62 | 63 | "browserify-hmr": "^0.3.1", |
63 | 64 | "cuke-tap": "^1.0.2", |
64 | 65 | "ecstatic-lr": "^1.0.1", |
66 | + "feathers-memory": "^0.5.1", | |
65 | 67 | "garnish": "^5.0.1", |
66 | 68 | "glob": "^6.0.2", |
67 | 69 | "jsdom": "^7.1.0", |
68 | 70 | "node-dev": "^2.7.1", |
@@ -95,15 +97,17 @@ | ||
95 | 97 | "cssify": "github:ahdinosaur/cssify", |
96 | 98 | "ecstatic": "^1.4.0", |
97 | 99 | "envify": "^3.4.0", |
98 | 100 | "evalify": "^1.0.1", |
99 | - "feathers": "^1.2.0", | |
101 | + "feathers": "^2.0.0-pre.1", | |
100 | 102 | "feathers-hooks": "^0.5.1", |
103 | + "feathers-knex": "^2.0.0", | |
101 | 104 | "feathers-rest": "^1.0.0", |
102 | 105 | "feathers-tcomb": "^1.0.0", |
103 | 106 | "history": "^1.13.1", |
104 | 107 | "lnfs-cli": "^1.0.1", |
105 | 108 | "npm-run-all": "^1.3.2", |
109 | + "pg": "^4.4.3", | |
106 | 110 | "pinkie-promise": "^2.0.0", |
107 | 111 | "predirect": "^1.1.0", |
108 | 112 | "ramda": "^0.18.0", |
109 | 113 | "react": "^0.14.3", |
knexfile.js | ||
---|---|---|
@@ -1,0 +1,1 @@ | ||
1 | +module.exports = require('app/config').db |
migrations/20160108004846_create_todos.js | ||
---|---|---|
@@ -1,0 +1,11 @@ | ||
1 | +exports.up = function(knex, Promise) { | |
2 | + return knex.schema.createTableIfNotExists('todos', function(table) { | |
3 | + table.increments('id') | |
4 | + table.string('text') | |
5 | + table.boolean('complete') | |
6 | + }) | |
7 | +} | |
8 | + | |
9 | +exports.down = function(knex, Promise) { | |
10 | + return knex.schema.dropTableIfExists('todos') | |
11 | +} |
Built with git-ssb-web