Yjohn / edesia

Glasgow Graduation Project - Food Drivers System

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

edesia

Glasgow Graduation Project - Food Drivers System

Getting started

  1. Add upstream repo git@github.com:CodeYourFuture/edesia.git
  2. Check if upstream has been added git remote -v
  • Locally, run npm run dev from server directory to have hot reload.
  1. Create branch git checkout -b setup Do everything in your branch
  2. Create a new react app create-react-app client
  3. Do cd client npm start
  4. Lets commit everything stage git add . commit git commit -m "setup react app" push : git push origin setup
  5. Open pull request
  6. The rest team members should pull from upstream git pull upstream master
  7. Create a new branch git check -b setupserver
  8. create a folder with the name server
  9. Go inside server and install package.json npm init and follow the command
  10. install express npm install express -- save
  11. create app.js file within the server folder
  12. 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!))
  1. open the app node app.js
  2. Go to package.json and add this code to script "start": "node app.js"
  3. Install nodemon npm install --save-dev nodemon
  4. Add Alias "npm run dev": "nodemon app.js
  5. Run npm install --save body-parser cors express-handlebars knex pg sqlite3
  6. Change the test exit in package.json from 1 to 0
  7. Commit, push and create pull request
  8. 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"
  9. run ./node_modules/.bin/knex init in server folder in terminal
  10. run npm run create-migration status then npm create-seed status
  11. 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' }])
  })
} ``

Workflow

Our workflow is a variation of Gitflow

  1. Pick a card from trello (assign it to yourself and make sure there is enough description)

  2. Locally, switch to master, then git pull upstream master. NOTE: If you get a merge message, that means you made a mistake and you worked on master by accident. Clean your master (i.e. git reset --hard previous_commit - ask a mentor to help)

  3. 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.

  1. Work on the branch (add, commit and push)

  2. Create a Pull Request when you are finished.

  3. Repeat.

Database

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

Migrations

We use knex for migrations, but we created alias helpers on package.json to make it easier to run the commands.

knex

  1. Create a migration npm run create-migration table_name
  2. Create a seed npm run create-seed table_name
  3. To

About

Glasgow Graduation Project - Food Drivers System


Languages

Language:JavaScript 87.0%Language:HTML 7.9%Language:CSS 5.1%