Glasgow Graduation Project - Food Drivers System
- Add upstream repo
[email protected]:CodeYourFuture/edesia.git
- Check if upstream has been added
git remote -v
- Locally, run
npm run dev
fromserver
directory to have hot reload.
- Create branch
git checkout -b setup
Do everything in your branch - Create a new react app
create-react-app client
- Do
cd client
npm start
- Lets commit everything
stage
git add .
commitgit commit -m "setup react app"
push :git push origin setup
- Open pull request
- The rest team members should pull from upstream
git pull upstream master
- Create a new branch
git check -b setupserver
- create a folder with the name
server
- Go inside server and install package.json
npm init
and follow the command - install express
npm install express -- save
- create
app.js
file within the server folder - Paste some code inside the app.js, code can be found
http://expressjs.com/en/starter/hello-world.html
const SERVER_PORT = process.env.PORT || 3000
const express = require(‘express’)
const app = express()
app.get(‘/’, (req, res) => res.send(‘Hello World!’))
app.listen(SERVER_PORT, () => console.log(‘Example app listening on port 3000!’))
- open the app
node app.js
- Go to package.json and add this code to script
"start": "node app.js"
- Install nodemon
npm install --save-dev nodemon
- Add Alias
"npm run dev": "nodemon app.js
- Run
npm install --save body-parser cors express-handlebars knex pg sqlite3
- Change the test exit in package.json from 1 to 0
- Commit, push and create pull request
- add this code to package.json script
"migrate": "knex migrate:latest && knex seed:run",
"create-migration": "knex migrate:make $1",
"create-seed": "knex seed:make $1"
- run
./node_modules/.bin/knex init
inserver
folder in terminal - run
npm run create-migration status
thennpm create-seed status
- copy paste this
module.exports = {
development: {
client: 'sqlite3',
connection: {
filename: './dev.sqlite3'
}
},
staging: {
client: 'postgresql',
connection: {
host: process.env.DB_HOST,
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},
production: {
client: 'postgresql',
connection: {
host: process.env.DB_HOST,
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}
}``
26. copy paste this
`` js exports.up = function (knex, Promise) {
return knex.raw(
`
CREATE TABLE status (
status varchar(200)
)
`
)
}
exports.down = function (knex, Promise) { }``
27. copy paste this
``js exports.seed = function (knex, Promise) {
// Deletes ALL existing entries
return knex('status').del().then(function () {
// Inserts seed entries
return knex('status').insert([{ status: 'OK' }])
})
} ``
Our workflow is a variation of Gitflow
-
Pick a card from trello (assign it to yourself and make sure there is enough description)
-
Locally, switch to
master
, thengit pull upstream master
. NOTE: If you get a merge message, that means you made a mistake and you worked onmaster
by accident. Clean your master (i.e.git reset --hard previous_commit
- ask a mentor to help) -
Create a branch based on the story
git checkout -b feature-title
.
If you're working on a feature for adding a student, then name the branch add-student
for example.
-
Work on the branch (add, commit and push)
-
Create a Pull Request when you are finished.
-
Repeat.
The first time you create the database, you will need to run these commands (three of them separately) in postgres
DROP ROLE IF EXISTS cyf;
CREATE USER cyf WITH PASSWORD 'password';
CREATE DATABASE ediesia OWNER cyf;
Command for getting into ediesia database psql -U cyf edesia
We use knex
for migrations, but we created alias helpers on package.json
to make it easier to run the commands.
- Create a migration
npm run create-migration table_name
- Create a seed
npm run create-seed table_name
- To