Skip to content

Initial Store + Store Reducer #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions back/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/devcontainers/python:3.13

ENV PYTHONUNBUFFERED 1

# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

#[Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client



Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
// README at: https://github.com/devcontainers/templates/tree/main/src/postgres
{
"name": "React + Vite",
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-20",
"customizations": {
"extensions": [
"vscode-eslint",
"vscode-jest"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.validate": [
"javascript",
"typescript"
],
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}
}
},
"name": "Python 3 & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
Expand All @@ -30,13 +15,26 @@
"version": "lts"
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
"forwardPorts": [
3000
],
"onCreateCommand": "npm ci && (cp .env.example .env || echo \".env creation failed\")",
"postCreateCommand": "npm install -g pnpm"
"forwardPorts": [3000, 3001],

"onCreateCommand": "(cp .env.example .env || echo \".env creation failed\"); (pipenv install || echo \"pipenv install failed\"); (bash database.sh || echo \"database.sh failed\");",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "python docs/assets/greeting.py both > /workspaces/.codespaces/shared/first-run-notice.txt && npm install",
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"ms-python.autopep8"
]
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
35 changes: 35 additions & 0 deletions back/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: gitpod
POSTGRES_DB: example
POSTGRES_PASSWORD: postgres

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
postgres-data:
14 changes: 14 additions & 0 deletions back/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file includes global variables that will be available inside your project
# 1. In the front end code you can access this variables like this: console.log(import.meta.env.VARIABLE_NAME)
# 1. In the back end code you access the variable by importing os and then typing print(os.getenv('VARIABLE_NAME'))

# Back-End Variables
DATABASE_URL=postgres://gitpod:postgres@localhost:5432/example
FLASK_APP_KEY="any key works"
FLASK_APP=src/app.py
FLASK_DEBUG=1
DEBUG=TRUE

# Front-End Variables
VITE_BASENAME=/
#VITE_BACKEND_URL=
31 changes: 31 additions & 0 deletions back/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"parser": "@babel/eslint-parser",
"plugins": [
"react"
],
"env": {
"browser": true,
"es6": true
},
"extends": [ "plugin:react/recommended"],
"rules": {
"strict":0,
"no-unused-vars": 0,
"no-console": 1,
"no-mixed-spaces-and-tabs": 0,
"no-debugger": 0,
"semi": ["error", "always"],
"allowImportExportEverywhere": false,
"indent": "off",
"react/jsx-indent": "off",
"react/jsx-indent-props": "off",
"comma-dangle": [1, { //when to use the last comma
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "ignore",
}],
"react/prop-types": [2]
}
}
27 changes: 27 additions & 0 deletions back/.github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repository:
has_wiki: false

# Labels: define labels for Issues and Pull Requests
labels:
- name: "bug"
color: c10000
- name: ":nerd_face: 4geeks student"
color: 7057ff
- name: "enhancement"
color: a2eeef
- name: "first-timers-only"
color: 69db89
- name: "good first issue"
color: 7057ff
- name: "help wanted"
color: 008672
- name: ":star: P1"
color: fbca04
- name: ":star: P2"
color: fbca04
- name: ":memo: bc-writter"
color: 98bde2
- name: ":computer: bc-coder"
color: 98bde2
- name: ":beetle: bc-inspector"
color: 98bde2
82 changes: 82 additions & 0 deletions back/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ignore all files starting with .
.*

# track this file .gitignore (i.e. do NOT ignore it)
!.gitignore
!.github
php_errorlog
.log

# do not ignore gitpod and render files
!.gitpod.Dockerfile
!.welcome
!.devcontainer
!.devcontainer/*
!Dockerfile.render
!.gitpod.yml
!render.yml
!.render-buildpacks.json

# track webpack configs (i.e. do NOT ignore it)
!composer.json
!webpack.config.js
!package.json
!webpack.production.js
!webpack.development.js

# track readme.md in the root (i.e. do NOT ignore it)
!README.md

# ignore OS generated files
ehthumbs.db
Thumbs.db

# ignore Editor files
*.sublime-project
*.sublime-workspace
*.komodoproject

# ignore log files and databases
*.log
*.sql
*.sqlite

# ignore compiled files
*.com
*.class
*.dll
*.exe
*.o
*.so

# ignore packaged files
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# ignore node/grunt dependency directories
node_modules/

# webpack output
dist/*
!public/
!public/*

# ignore the dist directory were our bundle files are going to be
!.gitkeep
!.htaccess
!.eslintrc
!.env.example
.now

# backend stuff
.venv
database.database
database.db
diagram.png
__pycache__/
27 changes: 27 additions & 0 deletions back/.gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM gitpod/workspace-postgres:latest

SHELL ["/bin/bash", "-c"]

RUN sudo apt-get update \
&& sudo apt-get update \
&& sudo apt-get install -y redis-server \
&& sudo apt-get clean \
&& sudo rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*

# That Gitpod install pyenv for me? no, thanks
WORKDIR /home/gitpod/
RUN rm .pyenv -Rf
RUN rm .gp_pyenv.d -Rf
RUN curl https://pyenv.run | bash


RUN pyenv update && pyenv install 3.10.7 && pyenv global 3.10.7
RUN pip install pipenv yapf
RUN npm i heroku -g

# remove PIP_USER environment
USER gitpod
RUN if ! grep -q "export PIP_USER=no" "$HOME/.bashrc"; then printf '%s\n' "export PIP_USER=no" >> "$HOME/.bashrc"; fi
RUN echo "" >> $HOME/.bashrc
RUN echo "unset DATABASE_URL" >> $HOME/.bashrc
RUN echo "export DATABASE_URL" >> $HOME/.bashrc
28 changes: 28 additions & 0 deletions back/.gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
image:
file: .gitpod.Dockerfile
ports:
- port: 3000
onOpen: open-browser
visibility: public
- port: 3001
onOpen: open-preview
visibility: public
- port: 5432
onOpen: ignore
tasks:
- init: >
(cp .env.example .env || true) &&
pipenv install &&
psql -U gitpod -c 'CREATE DATABASE example;' &&
psql -U gitpod -c 'CREATE EXTENSION unaccent;' -d example &&
psql -c "ALTER USER gitpod PASSWORD 'postgres';" &&
bash database.sh &&
python docs/assets/greeting.py back
- command: >
npm install &&
python docs/assets/greeting.py front
openMode: split-right

vscode:
extensions:
- esbenp.prettier-vscode
0 4geeks.ico → back/4geeks.ico
100755 → 100644
File renamed without changes.
13 changes: 13 additions & 0 deletions back/Dockerfile.render
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16

RUN apt update \
&& apt install software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt update \
&& apt install python3.10

WORKDIR /opt/app
COPY --from=build /opt/app/venv /venv

ENV PATH="/opt/app/venv/bin:$PATH"
ENV NODE_ENV=container
36 changes: 36 additions & 0 deletions back/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
flask = "*"
flask-sqlalchemy = "*"
flask-migrate = "*"
flask-swagger = "*"
psycopg2-binary = "*"
python-dotenv = "*"
flask-cors = "*"
gunicorn = "*"
cloudinary = "*"
flask-admin = "*"
typing-extensions = "*"
flask-jwt-extended = "==4.6.0"
wtforms = "==3.1.2"
sqlalchemy = "*"

[requires]
python_version = "3.13"

[scripts]
start="flask run -p 3001 -h 0.0.0.0"
init="flask db init"
migrate="flask db migrate"
local="heroku local"
upgrade="flask db upgrade"
downgrade="flask db downgrade"
insert-test-data="flask insert-test-data"
reset_db="bash ./docs/assets/reset_migrations.bash"
deploy="echo 'Please follow this 3 steps to deploy: https://github.com/4GeeksAcademy/flask-rest-hello/blob/master/README.md#deploy-your-website-to-heroku' "
Loading