Skip to content
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
4 changes: 0 additions & 4 deletions fact-bounty-client/.env.example

This file was deleted.

8,264 changes: 8,264 additions & 0 deletions fact-bounty-client/npm-audit.html

Large diffs are not rendered by default.

60,689 changes: 60,689 additions & 0 deletions fact-bounty-client/npmaudit.txt

Large diffs are not rendered by default.

6,553 changes: 2,156 additions & 4,397 deletions fact-bounty-client/package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions fact-bounty-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^3.9.0",
"@material-ui/core": "^3.9.4",
"@material-ui/icons": "^3.0.2",
"axios": "^0.19.0",
"bootstrap": "^4.3.1",
"classnames": "^2.2.6",
"axios": "^0.22.0",
"bootstrap": "^4.6.0",
"classnames": "^2.3.1",
"font-awesome": "^4.7.0",
"is-empty": "^1.2.0",
"jwt-decode": "^2.2.0",
"moment": "^2.24.0",
"moment": "^2.29.1",
"node-sass": "^4.12.0",
"prettier": "^1.16.4",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"prettier": "^1.19.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-facebook-login": "^4.1.1",
"react-google-login": "^5.0.2",
"react-icons": "^3.5.0",
"react-google-login": "^5.2.2",
"react-icons": "^3.11.0",
"react-infinite-scroller": "^1.2.4",
"react-lines-ellipsis": "^0.14.0",
"react-lines-ellipsis": "^0.14.1",
"react-redux": "^6.0.0",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.8",
"react-swipeable-views": "^0.13.3",
"react-swipeable-views": "^0.13.9",
"recompose": "^0.30.0",
"redux": "^4.0.1",
"redux-form": "^8.1.0",
"redux": "^4.1.1",
"redux-form": "^8.3.7",
"redux-thunk": "^2.3.0",
"typeface-roboto": "0.0.54"
},
Expand All @@ -49,10 +49,10 @@
],
"devDependencies": {
"babel-eslint": "9.0.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.4.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.5"
"lint-staged": "^8.2.1"
},
"husky": {
"hooks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class ContactUsForm extends Component {
/>
<input
type="number"
step="1"
min="100000000"
minLength="9"
maxLength="13"
name="phone"
value={phone}
placeholder="Phone Number"
Expand Down
9 changes: 9 additions & 0 deletions fact-bounty-flask/.pyre_configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"source_directories": [
{
"import_root": ".",
"source": "api"
}
],
"taint_models_path": "/home/sampath/mis/fact-bounty/env/pysa/lib"
}
5 changes: 4 additions & 1 deletion fact-bounty-flask/api/admin/controller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations
import psutil
import os
import time
from flask import make_response, jsonify
from flask.views import MethodView
from flask.wrappers import Response
from typing import Tuple

PERIOD = 1 # 1 sec


class SystemPanel(MethodView):
def get(self):
def get(self) -> Tuple[Response, int]:

io_data_start = psutil.net_io_counters()

Expand Down
13 changes: 8 additions & 5 deletions fact-bounty-flask/api/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import os

from flask import Flask
Expand All @@ -12,9 +13,11 @@
from api import admin, user, stories, crawler, util
from api.config import config
from api.extensions import db, mail, pagedown, login_manager, migrate, jwt
from flask.app import Flask
from typing import Optional


def create_app(config_name):
def create_app(config_name: str) -> Optional[Flask]:
try:
# create and configure the app
app = Flask(
Expand All @@ -39,7 +42,7 @@ def create_tables():
print("Error occured:", err)


def register_extensions(app):
def register_extensions(app) -> None:
"""Register Flask extensions"""
CORS(app)
db.init_app(app)
Expand All @@ -65,7 +68,7 @@ def register_extensions(app):
jwt.init_app(app)


def register_blueprint(app):
def register_blueprint(app) -> None:
"""Register Flask blueprints."""
app.register_blueprint(user.views.userprint, url_prefix="/api/users")
app.register_blueprint(stories.views.storyprint, url_prefix="/api/stories")
Expand All @@ -75,7 +78,7 @@ def register_blueprint(app):
return None


def register_commands(app):
def register_commands(app) -> None:
"""Register Click commands."""
app.cli.add_command(commands.test)
app.cli.add_command(commands.lint)
Expand All @@ -85,7 +88,7 @@ def register_commands(app):
app.cli.add_command(commands.create_admin)


def register_shellcontext(app):
def register_shellcontext(app) -> None:
"""Register shell context objects."""

def shell_context():
Expand Down
17 changes: 10 additions & 7 deletions fact-bounty-flask/api/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
"""Click commands."""
from __future__ import annotations
from typing import Dict, Optional

import os
from glob import glob
from subprocess import call
Expand Down Expand Up @@ -28,7 +31,7 @@
"""


def check(email):
def check(email) -> bool:
"""
pass the regualar expression
and the string in search() method
Expand All @@ -46,7 +49,7 @@ def check(email):
default=False,
help="Run tests under code coverage.",
)
def test(coverage):
def test(coverage) -> Optional[int]:
"""Run the unit tests."""
if coverage and not os.environ.get("FLASK_COVERAGE"):
import subprocess
Expand Down Expand Up @@ -83,7 +86,7 @@ def test(coverage):
is_flag=True,
help="Fix imports using isort, before linting",
)
def lint(fix_imports):
def lint(fix_imports) -> None:
"""Lint and check code style with flake8 and isort."""
skip = ["requirements", "venv", "migrations", "__pycache__"]
root_files = glob("*.py")
Expand All @@ -108,7 +111,7 @@ def execute_tool(description, *args):


@click.command()
def clean():
def clean() -> None:
"""Remove *.pyc and *.pyo files recursively starting at current directory.

Borrowed from Flask-Script, converted to use Click.
Expand All @@ -131,7 +134,7 @@ def clean():
help="Property on Rule to order by (default: rule)",
)
@with_appcontext
def urls(url, order):
def urls(url, order) -> None:
"""Display all of the url matching routes for the project.

Borrowed from Flask-Script, converted to use Click.
Expand Down Expand Up @@ -191,7 +194,7 @@ def urls(url, order):


@click.command()
def deploy():
def deploy() -> None:
"""
migrate database to latest revision
"""
Expand All @@ -200,7 +203,7 @@ def deploy():

@click.command(name="create_admin")
@with_appcontext
def create_admin():
def create_admin() -> Optional[Dict[str, str]]:
"""
create an admin user
"""
Expand Down
7 changes: 4 additions & 3 deletions fact-bounty-flask/api/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from __future__ import annotations

basedir = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -39,7 +40,7 @@ class Config:
}

@staticmethod
def init_app(app):
def init_app(app) -> None:
pass


Expand Down Expand Up @@ -70,7 +71,7 @@ class ProductionConfig(Config):
ES_PASSWORD = os.environ.get("ELASTIC_SEARCH_PASSWORD")

@classmethod
def init_app(cls, app):
def init_app(cls, app) -> None:
Config.init_app(app)

# email errors to the administrators
Expand All @@ -97,7 +98,7 @@ def init_app(cls, app):

class DockerConfig(Config):
@classmethod
def init_app(cls, app):
def init_app(cls, app) -> None:
ProductionConfig.init_app(app)

# log to stderr
Expand Down
13 changes: 8 additions & 5 deletions fact-bounty-flask/api/crawler/controller.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations
from flask.views import MethodView
from flask import make_response, request, jsonify, current_app
import dateutil.parser as dparser
from datetime import datetime
from .utils import cron_crawlers
from flask.wrappers import Response
from typing import Tuple


class SetCronJob(MethodView):
def get(self):
def get(self) -> Tuple[Response, int]:
try:
jobs = []
for job in current_app.scheduler.get_jobs():
Expand All @@ -29,7 +32,7 @@ def get(self):
}
return make_response(jsonify(response)), 404

def post(self):
def post(self) -> Tuple[Response, int]:
try:
data = request.get_json(silent=True)

Expand All @@ -51,7 +54,7 @@ def post(self):
}
return make_response(jsonify(response)), 404

def put(self):
def put(self) -> Tuple[Response, int]:
try:
data = request.get_json(silent=True)

Expand All @@ -74,7 +77,7 @@ def put(self):
}
return make_response(jsonify(response)), 404

def delete(self):
def delete(self) -> Tuple[Response, int]:
try:
data = request.get_json(silent=True)

Expand All @@ -95,7 +98,7 @@ def delete(self):


class CrawlByDate(MethodView):
def get(self):
def get(self) -> Tuple[Response, int]:
scrapyd = current_app.scrapy
try:
data = request.get_json(silent=True)
Expand Down
15 changes: 9 additions & 6 deletions fact-bounty-flask/api/extensions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from flask_jwt_extended import JWTManager
from flask_login import LoginManager
from flask_migrate import Migrate
Expand All @@ -6,6 +7,8 @@
from flask_sqlalchemy import SQLAlchemy
from flask import jsonify, make_response
from api import user
from flask.wrappers import Response
from typing import Tuple

db = SQLAlchemy()
mail = Mail()
Expand All @@ -20,20 +23,20 @@

# This method will check if a token is blacklisted, and will be called automatically when blacklist is enabled
@jwt.token_in_blacklist_loader
def check_if_token_is_blacklist(decypted_token):
def check_if_token_is_blacklist(decypted_token) -> bool:
jti = decypted_token["jti"]
return user.model.RevokedToken.is_jti_blacklisted(jti)


# The following callbacks are used for customizing jwt response/error messages.
@jwt.expired_token_loader
def expired_token_callback():
def expired_token_callback() -> Tuple[Response, int]:
response = {"message": "The token has expired.", "error": "token_expired"}
return make_response(jsonify(response)), 401


@jwt.invalid_token_loader
def invalid_token_callback(error):
def invalid_token_callback(error) -> Tuple[Response, int]:
# we have to keep the argument here, since it's passed in by the caller internally
response = {
"message": "Signature verification failed.",
Expand All @@ -43,7 +46,7 @@ def invalid_token_callback(error):


@jwt.unauthorized_loader
def missing_token_callback(error):
def missing_token_callback(error) -> Tuple[Response, int]:
response = {
"message": "Request does not contain an access token.",
"error": "authorization_required",
Expand All @@ -52,7 +55,7 @@ def missing_token_callback(error):


@jwt.needs_fresh_token_loader
def token_not_fresh_callback():
def token_not_fresh_callback() -> Tuple[Response, int]:
response = {
"message": "The token is not fresh.",
"error": "fresh_token_required",
Expand All @@ -61,7 +64,7 @@ def token_not_fresh_callback():


@jwt.revoked_token_loader
def revoked_token_callback():
def revoked_token_callback() -> Tuple[Response, int]:
response = {
"message": "The token has been revoked.",
"error": "token_revoked",
Expand Down
Loading