Skip to content

Instantly share code, notes, and snippets.

@Falieson
Last active October 26, 2017 08:54
Show Gist options
  • Save Falieson/83593ae9b9a658441f8ab4589264ffc4 to your computer and use it in GitHub Desktop.
Save Falieson/83593ae9b9a658441f8ab4589264ffc4 to your computer and use it in GitHub Desktop.
// 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
},
};
{
"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"
}
}
}
// 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
}
}
// 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