Last active
October 26, 2017 08:54
-
-
Save Falieson/83593ae9b9a658441f8ab4589264ffc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// db/postgres.config.js | |
module.exports = { | |
client: 'pg', | |
connection: 'postgres://postgres@localhost:5432/ult1706', | |
migrations: { | |
directory: __dirname + "/migrations", | |
tableName: 'migrations', | |
}, | |
seeds: { | |
directory: __dirname + "/seeds", | |
}, | |
debug: true, | |
pool: { | |
min: 2, | |
max: 10 | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "universal-redux", | |
"version": "0.1.0", | |
"private": true, | |
"scripts": { | |
"start": "babel-node src/server/express", | |
"commit": "git-cz", | |
"db:setup": "/bin/sh db/postgres-initdb.sh", | |
"db:setupComplete": "npm run db:setup && npm run db:latest && npm run db:seed", | |
"db:latest": "knex migrate:latest", | |
"db:seed": "knex seed:run" | |
}, | |
"dependencies": { | |
"babel-runtime": "^6.23.0", | |
"body-parser": "^1.17.2", | |
"express": "^4.15.3", | |
"farce": "^0.2.1", | |
"found": "^0.3.0", | |
"knex": "^0.13.0", | |
"knex-migrate": "^1.3.0", | |
"morgan": "^1.8.2", | |
"pg": "^6.2.4", | |
"prop-types": "^15.5.10", | |
"react": "^15.5.4", | |
"react-dom": "^15.5.4", | |
"react-redux": "^5.0.5", | |
"redux": "^3.6.0", | |
"redux-devtools-extension": "^2.13.2", | |
"redux-thunk": "^2.2.0", | |
"serialize-javascript": "^1.3.0", | |
"webpack": "^2.6.1", | |
"webpack-dev-middleware": "^1.10.2" | |
}, | |
"devDependencies": { | |
"babel-cli": "^6.24.1", | |
"babel-loader": "^7.0.0", | |
"babel-plugin-transform-object-rest-spread": "^6.23.0", | |
"babel-plugin-transform-runtime": "^6.23.0", | |
"babel-polyfill": "^6.23.0", | |
"babel-preset-latest": "^6.24.1", | |
"babel-preset-react": "^6.24.1", | |
"babel-preset-stage-1": "^6.24.1", | |
"commitizen": "^2.9.6", | |
"cz-conventional-changelog": "^2.0.0" | |
}, | |
"config": { | |
"commitizen": { | |
"path": "./node_modules/cz-conventional-changelog" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// redux/actions.js | |
function getCounterRecords() { | |
// === FETCH COUNTER | |
const counterRecords = (records) => ({ | |
type: TYPES.COUNTERS_FETCH, | |
payload: { records }, | |
meta: {}, | |
error: false | |
}) | |
return function thunk(dispatch) { | |
const allCounters = postgres.select().from('counters').timeout(1000) | |
allCounters.then(res => { | |
dispatch(counterRecords(res)) | |
}) | |
return true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server/postgres.js | |
import knex from 'knex' | |
import config from '../../db/postgres.config' | |
module.exports = knex(config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment