Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jason490 committed Jun 8, 2024
1 parent 5df365a commit 83c0286
Show file tree
Hide file tree
Showing 19 changed files with 488 additions and 29 deletions.
4 changes: 0 additions & 4 deletions .env

This file was deleted.

11 changes: 0 additions & 11 deletions Pipfile

This file was deleted.

3 changes: 3 additions & 0 deletions api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SECRET_KEY='DEVElOPMENTONLY'
SQLALCHEMY_DATABASE_URI='postgresql://usr:pwd@postgres:5432/master'

4 changes: 4 additions & 0 deletions api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ flask = "*"
flask-cors = "*"
flask-bcrypt = "*"
python-dotenv = "*"
flask-sqlalchemy = "*"
psycopg2-binary = "*"

[dev-packages]
pylint = "*"
pylint-flask = "*"

[requires]
python_version = "3.11"
307 changes: 303 additions & 4 deletions api/Pipfile.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions api/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dotenv import load_dotenv
import os

load_dotenv()


class Config(object):
SECRET_KEY = os.getenv('SECRET_KEY')
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI')
FLASK_ENV = 'development'
DEBUG = True
25 changes: 20 additions & 5 deletions api/pollination/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import os
# flake8: noqa
# pylint: skip-file

from flask import Flask
from flask_cors import CORS
from flask_bcrypt import Bcrypt
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import DeclarativeBase
from config import Config


app = Flask(__name__)
CORS(app)
app.config.from_object(Config)
app.app_context().push()

bcrypt = Bcrypt(app)


def create_app():
app = Flask(__name__)
CORS(app)
return app
class Base(DeclarativeBase):
pass


db = SQLAlchemy(model_class=Base)
db.init_app(app)

from pollination import routes # noqa
39 changes: 39 additions & 0 deletions api/pollination/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from uuid import uuid4
from pollination import db
import string
import random


'''
BELOW THIS ARE EXAMPLES
'''


def get_uuid():
'''Returns a unique id in hex'''
return uuid4().hex


def get_basic_id():
'''Returns a unique id of easy typeable string'''
return ''.join(random.choices(string.ascii_uppercase
+ string.ascii_lowercase, k=6))


class Team(db.Model):
'''
Only allows people with the team id to create an account
'''
__tablename__ = "team"
id = db.Column(db.String(32), primary_key=True,
unique=True, default=get_uuid)
alt_id = db.Column(db.String(6), unique=True, default=get_basic_id)

team_name = db.Column(db.String(20), unique=True)
track_value = db.relationship('Track_value', back_populates='team')

user = db.relationship('User', back_populates='team')
# Determine what access level the function is at

def __repr__(self):
return f"Team('{self.team_name}','{ self.alt_id }')"
7 changes: 7 additions & 0 deletions api/pollination/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# from flask import request, jsonify
from pollination import app # , bcrypt, db


@app.route('/api/test', methods=['GET', 'POST'])
def test():
return "This works"
3 changes: 1 addition & 2 deletions api/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Starts the application
'''

from pollination import create_app
from pollination import app

if __name__ == "__main__":
app = create_app()
app.run(host="0.0.0.0", port=5000)
2 changes: 1 addition & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:22-alpine
FROM node:20-alpine

WORKDIR /app

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
88 changes: 88 additions & 0 deletions client/app/test/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import Image from "next/image";

export default function Test() {
return (
<main>
<div>
<p>
Get started by editing&nbsp;
<code>src/app/page.js</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{" "}
<Image
src="/vercel.svg"
alt="Vercel Logo"
width={100}
height={24}
priority
/>
</a>
</div>
</div>

<div>
<Image
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>

<div>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>Don't Do THIS Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
</a>

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>Explore starter templates for Next.js.</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
);
}
2 changes: 1 addition & 1 deletion client/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
"@/*": ["./app/*"]
}
}
}
11 changes: 10 additions & 1 deletion client/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
rewrites: async () => {
return [
{
source: '/api/:path*',
destination: 'http://back-end:5000/api/:path*'
},
]
},
};

export default nextConfig;

0 comments on commit 83c0286

Please sign in to comment.