Skip to content

Commit

Permalink
mock notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Endorf committed Jul 29, 2023
1 parent 73d76a0 commit 10e22ba
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions app/main/routes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
import json
from app import app

from authlib.integrations.flask_oauth2 import ResourceProtector
from flask import jsonify
from app.auth.token_validator import ClientTokenValidator
from app.service.common.status import HTTP_200_OK

require_auth = ResourceProtector()
validator = ClientTokenValidator("http://localhost:8080/realms/myorg")
validator = ClientTokenValidator(app.config.get('OAUTH2_ISSUER'))
require_auth.register_token_validator(validator)

class Note:
def __init__(self, username, email, tag_index, title, details):
self.username = username
self.email = email
self.tag_index = tag_index
self.title = title
self.details = details

# 0: General
# 1: Metaphor
# 2: Quote
_notes = [
Note("Skylinn", "skylinn@email.com", 1, "Why did Atlas shrug?", None),
Note("Francisco d'Anconia", "franco@email.com", 0, "What do you think about contradictions?", "Contradictions do not exist. Whenever you think that you are facing a contradiction, check your premises. You will find that one of them is wrong."),
Note("Quintus Horatius Flaccus", "flaccus@email.com", 0, "Carpe diem, quam minimum credula postero", None),
Note("John Connor", "connor@email.com", 2, "The future is not set. There is no fate but what we make for oursalves.", "My father told it to my mom"),
Note("John Galt", "galt@email.com", 0, "Existence is identity, consciousness is identification.", None),
Note("user 747", "user747@email.com", 2, "Try to be a rainbow in someone's clouds.", None),
]


def _note_to_dict(person):
return {
'username': person.username,
'email': person.email,
'tag_index': person.tag_index,
'title': person.title,
'details': person.details
}



@app.route("/api/public")
def public():
Expand All @@ -26,7 +59,11 @@ def private():
@require_auth(None)
def notes():
response = "Everything fine! Notes here"
return jsonify(message=response)
return (
json.dumps(_notes, default=_note_to_dict, indent=4),
HTTP_200_OK,
{'ContentType':'application/json'}
)


@app.route("/api/scoped")
Expand Down

0 comments on commit 10e22ba

Please sign in to comment.