Skip to content

Commit a28c800

Browse files
committed
first commit
0 parents  commit a28c800

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+18293
-0
lines changed

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# ignore .vscode folder
4+
.vscode
5+
6+
# dependencies
7+
/node_modules
8+
/.pnp
9+
.pnp.js
10+
11+
# testing
12+
/coverage
13+
14+
# production
15+
/build
16+
17+
# misc
18+
.DS_Store
19+
.env.local
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*

api/__init__.py

Whitespace-only changes.
171 Bytes
Binary file not shown.

api/__pycache__/admin.cpython-311.pyc

374 Bytes
Binary file not shown.

api/__pycache__/apps.cpython-311.pyc

536 Bytes
Binary file not shown.
918 Bytes
Binary file not shown.
808 Bytes
Binary file not shown.

api/__pycache__/urls.cpython-311.pyc

785 Bytes
Binary file not shown.

api/__pycache__/views.cpython-311.pyc

3.59 KB
Binary file not shown.

api/admin.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
from .models import Note
3+
4+
# Register your models here.
5+
admin.site.register(Note)

api/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ApiConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'api'

api/migrations/0001_initial.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.1.5 on 2023-01-20 07:38
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Note',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('body', models.TextField(blank=True, null=True)),
19+
('updated', models.DateTimeField(auto_now=True)),
20+
('created', models.DateTimeField(auto_now_add=True)),
21+
],
22+
),
23+
]

api/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
182 Bytes
Binary file not shown.

api/models.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
5+
class Note(models.Model):
6+
body = models.TextField(null=True, blank=True)
7+
updated = models.DateTimeField(auto_now=True)
8+
created = models.DateTimeField(auto_now_add=True)
9+
def __str__(self):
10+
return self.body[0:69]

api/serializers.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from rest_framework.serializers import ModelSerializer
2+
from .models import Note
3+
4+
class NoteSerializer(ModelSerializer):
5+
class Meta:
6+
model = Note
7+
fields = '__all__'

api/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

api/urls.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.urls import path
2+
from .views import *
3+
4+
urlpatterns = [
5+
path('', getRoutes, name="routes"),
6+
path('notes/', getNotes, name="notes"),
7+
path('notes/<str:pk>/update/', updateNote, name="update-note"),
8+
path('notes/<str:pk>/delete/', deleteNote, name="delete-note"),
9+
path('notes/create/', createNote, name="create-note"),
10+
path('notes/<str:pk>/', getNote, name="note"),
11+
]

api/views.py

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from django.shortcuts import render
2+
from rest_framework.decorators import api_view
3+
from rest_framework.response import Response
4+
from .serializers import NoteSerializer
5+
from .models import Note
6+
7+
# Create your views here.
8+
9+
@api_view(['GET'])
10+
def getRoutes(request):
11+
routes = [
12+
{
13+
'Endpoint': '/notes/',
14+
'method': 'GET',
15+
'body': None,
16+
'description': 'Returns an array of notes'
17+
},
18+
{
19+
'Endpoint': '/notes/id',
20+
'method': 'GET',
21+
'body': None,
22+
'description': 'Returns a single note object'
23+
},
24+
{
25+
'Endpoint': '/notes/create/',
26+
'method': 'POST',
27+
'body': {'body': ""},
28+
'description': 'Creates new note with data sent in post request'
29+
},
30+
{
31+
'Endpoint': '/notes/id/update/',
32+
'method': 'PUT',
33+
'body': {'body': ""},
34+
'description': 'Creates an existing note with data sent in post request'
35+
},
36+
{
37+
'Endpoint': '/notes/id/delete/',
38+
'method': 'DELETE',
39+
'body': None,
40+
'description': 'Deletes and exiting note'
41+
},
42+
]
43+
return Response(routes)
44+
45+
@api_view(['GET'])
46+
def getNotes(request):
47+
notes = Note.objects.all().order_by('-created')
48+
serializer = NoteSerializer(notes, many=True)
49+
return Response(serializer.data)
50+
51+
@api_view(['GET'])
52+
def getNote(request, pk):
53+
note = Note.objects.get(id=pk)
54+
serializer = NoteSerializer(note, many=False)
55+
return Response(serializer.data)
56+
57+
@api_view(['PUT'])
58+
def updateNote(request, pk):
59+
note = Note.objects.get(id=pk)
60+
serializer = NoteSerializer(instance=note, data=request.data)
61+
if serializer.is_valid():
62+
serializer.save()
63+
return Response(serializer.data)
64+
65+
@api_view(['DELETE'])
66+
def deleteNote(request, pk):
67+
note = Note.objects.get(id=pk)
68+
note.delete()
69+
return Response('Note was deleted!')
70+
71+
@api_view(['POST'])
72+
def createNote(request):
73+
data = request.data
74+
note = Note.objects.create(
75+
body=data['body']
76+
)
77+
serializer = NoteSerializer(note, many=False)
78+
return Response(serializer.data)

db.sqlite3

132 KB
Binary file not shown.

manage.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'notesapp.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

mynotes/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

mynotes/build/asset-manifest.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"files": {
3+
"main.css": "/static/css/main.e7772a38.css",
4+
"main.js": "/static/js/main.d825d148.js",
5+
"index.html": "/index.html",
6+
"static/media/add.svg": "/static/media/add.ebf598626c6f9b2211b0578a435aaa6b.svg",
7+
"static/media/arrow-left.svg": "/static/media/arrow-left.b553318e4fdaed1113efb091889b7f47.svg",
8+
"main.e7772a38.css.map": "/static/css/main.e7772a38.css.map",
9+
"main.d825d148.js.map": "/static/js/main.d825d148.js.map"
10+
},
11+
"entrypoints": [
12+
"static/css/main.e7772a38.css",
13+
"static/js/main.d825d148.js"
14+
]
15+
}

mynotes/build/favicon.ico

3.78 KB
Binary file not shown.

mynotes/build/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.d825d148.js"></script><link href="/static/css/main.e7772a38.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

mynotes/build/logo192.png

5.22 KB
Loading

mynotes/build/logo512.png

9.44 KB
Loading

mynotes/build/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

mynotes/build/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

mynotes/build/static/css/main.e7772a38.css

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mynotes/build/static/css/main.e7772a38.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mynotes/build/static/js/main.d825d148.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2+
3+
/**
4+
* @license React
5+
* react-dom.production.min.js
6+
*
7+
* Copyright (c) Facebook, Inc. and its affiliates.
8+
*
9+
* This source code is licensed under the MIT license found in the
10+
* LICENSE file in the root directory of this source tree.
11+
*/
12+
13+
/**
14+
* @license React
15+
* react-jsx-runtime.production.min.js
16+
*
17+
* Copyright (c) Facebook, Inc. and its affiliates.
18+
*
19+
* This source code is licensed under the MIT license found in the
20+
* LICENSE file in the root directory of this source tree.
21+
*/
22+
23+
/**
24+
* @license React
25+
* react.production.min.js
26+
*
27+
* Copyright (c) Facebook, Inc. and its affiliates.
28+
*
29+
* This source code is licensed under the MIT license found in the
30+
* LICENSE file in the root directory of this source tree.
31+
*/
32+
33+
/**
34+
* @license React
35+
* scheduler.production.min.js
36+
*
37+
* Copyright (c) Facebook, Inc. and its affiliates.
38+
*
39+
* This source code is licensed under the MIT license found in the
40+
* LICENSE file in the root directory of this source tree.
41+
*/
42+
43+
/**
44+
* @remix-run/router v1.3.0
45+
*
46+
* Copyright (c) Remix Software Inc.
47+
*
48+
* This source code is licensed under the MIT license found in the
49+
* LICENSE.md file in the root directory of this source tree.
50+
*
51+
* @license MIT
52+
*/
53+
54+
/**
55+
* React Router DOM v6.7.0
56+
*
57+
* Copyright (c) Remix Software Inc.
58+
*
59+
* This source code is licensed under the MIT license found in the
60+
* LICENSE.md file in the root directory of this source tree.
61+
*
62+
* @license MIT
63+
*/
64+
65+
/**
66+
* React Router v6.7.0
67+
*
68+
* Copyright (c) Remix Software Inc.
69+
*
70+
* This source code is licensed under the MIT license found in the
71+
* LICENSE.md file in the root directory of this source tree.
72+
*
73+
* @license MIT
74+
*/

mynotes/build/static/js/main.d825d148.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Loading

mynotes/db.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"notes": [
3+
{
4+
"body": "hello there this is a super long title cause this is not actually a title\n\nthis is actually the body\nthis is the body tho RIP\nthis is a new line ",
5+
"updated": "2023-01-20T06:47:31.575Z",
6+
"id": 1
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)