Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
f7c18df
Remove new from throws
AlexanderOtavka Nov 26, 2017
a95a502
Switch to using named volumes
AlexanderOtavka Dec 18, 2017
47ba1de
Switch to isCompleted for compat with webapp
AlexanderOtavka Dec 25, 2017
a096748
isCompleted -> isComplete
AlexanderOtavka Dec 25, 2017
fdf3469
Remove dev.dockerfile
AlexanderOtavka Dec 25, 2017
84b0a52
Add production docker configuration
AlexanderOtavka Nov 23, 2017
aaf848c
Add develoment dockerfile
AlexanderOtavka Nov 23, 2017
560cbf7
Remove environment variable nonsense
AlexanderOtavka Nov 24, 2017
eab5447
Add mongo to handlers
AlexanderOtavka Nov 24, 2017
31a9987
Switch to using named volumes
AlexanderOtavka Dec 18, 2017
e865cea
Add production docker configuration
AlexanderOtavka Nov 23, 2017
0c2733a
Add develoment dockerfile
AlexanderOtavka Nov 23, 2017
276984b
Remove environment variable nonsense
AlexanderOtavka Nov 24, 2017
7fc761a
Remove working dir from docker compose
AlexanderOtavka Nov 24, 2017
675723f
Add put operation
AlexanderOtavka Nov 26, 2017
0a6f7da
Add delete
AlexanderOtavka Nov 26, 2017
8113055
Switch put to patch
AlexanderOtavka Nov 26, 2017
17adacc
Moving error handling to separate function
AlexanderOtavka Nov 26, 2017
00832f1
Add express-async-errors
AlexanderOtavka Nov 26, 2017
4c28ae3
Add runWithDB abstraction
AlexanderOtavka Nov 26, 2017
7d42532
Fix whitespace
AlexanderOtavka Nov 26, 2017
51eef1e
Remove new from throws
AlexanderOtavka Nov 26, 2017
7d859ec
Fix messed up rebase
AlexanderOtavka Dec 25, 2017
1e2b9b3
Remove dev.dockerfile
AlexanderOtavka Dec 25, 2017
df227db
Merge day-5 -> day-6
AlexanderOtavka Dec 25, 2017
7b10d6a
Merge day-6 -> day-7
AlexanderOtavka Dec 25, 2017
677852d
Add server and dockerfile to webapp
AlexanderOtavka Dec 26, 2017
4c0353b
Merge branch 'day-1' into day-2
AlexanderOtavka Dec 26, 2017
2b0a969
Enable customizing port for webapp
AlexanderOtavka Dec 26, 2017
eda9bb4
Rename server -> api
AlexanderOtavka Dec 26, 2017
bff46a6
Add production docker configuration
AlexanderOtavka Nov 23, 2017
008b202
Add develoment dockerfile
AlexanderOtavka Nov 23, 2017
0a91bac
Add docker-compose file
AlexanderOtavka Nov 24, 2017
a55e994
Remove environment variable nonsense
AlexanderOtavka Nov 24, 2017
ad3e51f
Remove DB stuff from docker compose
AlexanderOtavka Nov 24, 2017
72bbcf8
Fix port number and EOF newline in docker config
AlexanderOtavka Nov 24, 2017
6c435b9
Add .dockerignore
AlexanderOtavka Nov 25, 2017
7423b6e
Update readme
AlexanderOtavka Nov 25, 2017
24cb9af
Fix api root in dockerfile
AlexanderOtavka Dec 25, 2017
df86e80
Split production and dev api roots
AlexanderOtavka Dec 25, 2017
be27b10
Remove static server from api
AlexanderOtavka Dec 26, 2017
90f3617
Merge branch 'day-2' into day-3
AlexanderOtavka Dec 26, 2017
f5abf42
Move root Dockerfile into api/
AlexanderOtavka Dec 26, 2017
d09032a
Remove port message from api server
AlexanderOtavka Dec 26, 2017
8ed9da4
Merge branch 'day-2' into day-3
AlexanderOtavka Dec 26, 2017
40262ab
Rename server -> api
AlexanderOtavka Dec 26, 2017
b2a1f6a
Merge day-3 -> day-4
AlexanderOtavka Dec 26, 2017
dd790b4
Remove root dockerfile again
AlexanderOtavka Dec 26, 2017
56984fe
Add webapp to networks
AlexanderOtavka Dec 26, 2017
f265317
Fix volume
AlexanderOtavka Dec 26, 2017
c0f7d8f
Rename mongodb service -> apidb
AlexanderOtavka Dec 26, 2017
2cc72f0
Rename network local-bridge -> api-bridge
AlexanderOtavka Dec 26, 2017
54d0979
Sort newest to oldest
AlexanderOtavka Dec 26, 2017
b92109b
Add develoment dockerfile
AlexanderOtavka Nov 23, 2017
f22facf
Add mongo to handlers
AlexanderOtavka Nov 24, 2017
114b963
Switch to using named volumes
AlexanderOtavka Dec 18, 2017
88b268d
Add put operation
AlexanderOtavka Nov 26, 2017
9a7767d
Add delete
AlexanderOtavka Nov 26, 2017
f405a60
Switch put to patch
AlexanderOtavka Nov 26, 2017
636013b
Moving error handling to separate function
AlexanderOtavka Nov 26, 2017
72eac96
Add express-async-errors
AlexanderOtavka Nov 26, 2017
53b130b
Add runWithDB abstraction
AlexanderOtavka Nov 26, 2017
58b7a5d
Fix whitespace
AlexanderOtavka Nov 26, 2017
f9264f3
Remove new from throws
AlexanderOtavka Nov 26, 2017
8559b59
Remove dev.dockerfile
AlexanderOtavka Dec 25, 2017
54b2939
Rename server -> api
AlexanderOtavka Dec 26, 2017
9434510
Merge day-5 -> day-6
AlexanderOtavka Dec 26, 2017
73984f4
Rename server -> api
AlexanderOtavka Dec 26, 2017
f972346
Merge day-6 -> day-7
AlexanderOtavka Dec 26, 2017
23bad10
Rename debug script -> start
AlexanderOtavka Dec 26, 2017
ab236be
Add dockerignore to webapp
AlexanderOtavka Dec 26, 2017
1d9fcb0
Merge branch 'day-1' into day-2
AlexanderOtavka Dec 26, 2017
62dd669
Fix serving message
AlexanderOtavka Dec 26, 2017
f6b432a
Remove cors when it's just a get handler
AlexanderOtavka Dec 26, 2017
8316d37
Merge day-2 -> day-3
AlexanderOtavka Dec 26, 2017
201f222
Fix lockfile
AlexanderOtavka Dec 26, 2017
7a1a24a
Move dockerignore up into api
AlexanderOtavka Dec 26, 2017
055dc22
Merge day-3 -> day-4
AlexanderOtavka Dec 26, 2017
7022ba1
Merge branch 'day-4' into day-5
AlexanderOtavka Dec 26, 2017
ff0f279
Merge branch 'day-5' into day-6
AlexanderOtavka Dec 26, 2017
cdee278
Merge branch 'day-6' into day-7
AlexanderOtavka Dec 26, 2017
5fe2f83
Update yarn.lock
AlexanderOtavka Jan 13, 2018
d629cc5
Add typings for cors
AlexanderOtavka Jan 13, 2018
daa4260
Validate inputs according to a schema
AlexanderOtavka Jan 15, 2018
706d846
Remove jsconfig because it is annoying
AlexanderOtavka Jan 15, 2018
ebe2b61
Remove cors typings
AlexanderOtavka Jan 15, 2018
602b6aa
Remove tsignore directive
AlexanderOtavka Jan 15, 2018
23e6c3f
Update readme
AlexanderOtavka Jan 15, 2018
a46bde1
Validate querys and params as single chunks
AlexanderOtavka Jan 15, 2018
de79f37
Refactor code out into separate files
AlexanderOtavka Jan 15, 2018
3cc7a44
Remove wrapper object from response
AlexanderOtavka Jan 15, 2018
e4c3415
Merge branch 'day-2' into day-3
AlexanderOtavka Jan 15, 2018
f231103
Remove wrapper objects and fix error handling
AlexanderOtavka Jan 15, 2018
8e4b0f1
Bring back default for isComplete
AlexanderOtavka Jan 15, 2018
94e670c
Merge day-4 -> day-5
AlexanderOtavka Jan 15, 2018
bd71868
Send 204 for delete
AlexanderOtavka Jan 15, 2018
801eeea
Merge day-5 -> day-6
AlexanderOtavka Jan 15, 2018
ed7f6da
Remove special error in dev
AlexanderOtavka Jan 15, 2018
b9269b5
Merge day-5 -> day-6
AlexanderOtavka Jan 15, 2018
a73cd0f
Remove wrapper objects from errors
AlexanderOtavka Jan 15, 2018
ac6ef42
Use link headers for pagination
AlexanderOtavka Jan 15, 2018
3fdffe2
Merge day-6 -> day-7
AlexanderOtavka Jan 15, 2018
1e16e89
Add new keyord for ObjectId
AlexanderOtavka Jan 15, 2018
211b9d4
Add new keyword to errors
AlexanderOtavka Jan 15, 2018
fe58123
Merge day-5 -> day-6
AlexanderOtavka Jan 15, 2018
7d0ba67
Git merge day-6 -> day-7
AlexanderOtavka Jan 15, 2018
583c94c
Add else branching when throwing
AlexanderOtavka Jan 15, 2018
d81118b
Merge day-4 -> day-5
AlexanderOtavka Jan 15, 2018
afb780f
Merge branch 'day-5' into day-6
AlexanderOtavka Jan 15, 2018
68c4ae2
Merge day-6 -> day-7
AlexanderOtavka Jan 15, 2018
203266a
Merge day-7 -> day-8
AlexanderOtavka Jan 15, 2018
8722555
Fix inconsistencies with day-7
AlexanderOtavka Jan 15, 2018
87615c8
Tweak naming
AlexanderOtavka Jan 15, 2018
4c8549f
Ignore request and response in 404 handler
AlexanderOtavka Jan 15, 2018
7fdf30b
Remove error wrapper objects
AlexanderOtavka Jan 15, 2018
6ae5dad
Tweak formatting
AlexanderOtavka Jan 15, 2018
154cf0a
Remove wrapper objects
AlexanderOtavka Jan 15, 2018
6d6ef23
Add querystring import
AlexanderOtavka Jan 16, 2018
8bf3baa
Add swagger docs
AlexanderOtavka Jan 16, 2018
d0c28d1
Clean up debug statements
AlexanderOtavka Jan 16, 2018
0c991a7
Add .editorconfig
AlexanderOtavka Jan 16, 2018
e7ad695
Merge branch 'day-1' into day-2
AlexanderOtavka Jan 16, 2018
3e22407
Merge branch 'day-2' into day-3
AlexanderOtavka Jan 16, 2018
0054d08
Merge day-3 -> day-4
AlexanderOtavka Jan 16, 2018
66ea1bb
Remove body parser
AlexanderOtavka Jan 16, 2018
ff03e83
Merge day-4 -> day-5
AlexanderOtavka Jan 16, 2018
16338b8
Merge day-5 -> day-6
AlexanderOtavka Jan 16, 2018
ef67771
Merge day-6 -> day-7
AlexanderOtavka Jan 16, 2018
74d416a
Merge day-7 -> day-8
AlexanderOtavka Jan 16, 2018
df829fe
Merge day-8 -> day-9
AlexanderOtavka Jan 16, 2018
8939464
Add readings
AlexanderOtavka Jan 16, 2018
e59ee1c
Update readme
AlexanderOtavka Jan 16, 2018
7f6e75d
Add comments to reading
AlexanderOtavka Jan 16, 2018
efece03
Update readme
AlexanderOtavka Jan 16, 2018
c362ce0
Update readme
AlexanderOtavka Jan 16, 2018
38bacd0
Update readme
AlexanderOtavka Jan 16, 2018
66b7873
Update readme
AlexanderOtavka Jan 16, 2018
77d00c7
Update readme
AlexanderOtavka Jan 16, 2018
42e06a4
Update readme again
AlexanderOtavka Jan 16, 2018
e1f677c
Proxy api through webapp
AlexanderOtavka Jan 17, 2018
0d220c8
Merge branch 'day-1' into day-2
AlexanderOtavka Jan 17, 2018
701d775
Change api to port 80
AlexanderOtavka Jan 17, 2018
78ce2c7
Merge branch 'day-2' into day-3
AlexanderOtavka Jan 17, 2018
3c49982
Update expose port
AlexanderOtavka Jan 17, 2018
8344da3
Merge branch 'day-1' into day-2
AlexanderOtavka Jan 17, 2018
fd17769
Setup docker compose to allow proxy
AlexanderOtavka Jan 17, 2018
0c12974
Remove network
AlexanderOtavka Jan 17, 2018
b4b8322
Merge day-3 -> day-4
AlexanderOtavka Jan 17, 2018
c6bfd7d
Remove unneeded links and networks
AlexanderOtavka Jan 17, 2018
4acbef6
Merge day-4 -> day-5
AlexanderOtavka Jan 17, 2018
8c12cb4
Merge branch 'day-2' into day-3
AlexanderOtavka Jan 17, 2018
14ba77c
Merge branch 'day-3' into day-4
AlexanderOtavka Jan 17, 2018
324e22a
Merge branch 'day-4' into day-5
AlexanderOtavka Jan 17, 2018
d077023
Merge branch 'day-5' into day-6
AlexanderOtavka Jan 17, 2018
2521094
Remove cors
AlexanderOtavka Jan 17, 2018
8c9cc35
Merge branch 'day-4' into day-5
AlexanderOtavka Jan 17, 2018
f662900
Merge branch 'day-5' into day-6
AlexanderOtavka Jan 17, 2018
03bea5a
Merge branch 'day-6' into day-7
AlexanderOtavka Jan 17, 2018
8c7802f
Fix start command in dockerfile
AlexanderOtavka Jan 17, 2018
17881c4
Remove unneeded environment vars
AlexanderOtavka Jan 17, 2018
def890f
Merge branch 'day-1' into day-2
AlexanderOtavka Jan 17, 2018
1acde6f
Merge branch 'day-2' into day-3
AlexanderOtavka Jan 17, 2018
fd02682
Merge branch 'day-3' into day-4
AlexanderOtavka Jan 17, 2018
023e236
Merge branch 'day-4' into day-5
AlexanderOtavka Jan 17, 2018
f7860e6
Merge branch 'day-5' into day-6
AlexanderOtavka Jan 17, 2018
d6cd7f6
Merge branch 'day-6' into day-7
AlexanderOtavka Jan 17, 2018
a5d0eeb
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
9654490
Fix port
AlexanderOtavka Jan 17, 2018
fd7a6b6
Change 404 handler to "*" path
AlexanderOtavka Jan 17, 2018
8422d72
Merge branch 'day-6' into day-7
AlexanderOtavka Jan 17, 2018
058e956
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
8cc38dd
Change module.exports to just exports
AlexanderOtavka Jan 17, 2018
2cb83dc
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
19e7f83
Fix query schema for GET /tasks
AlexanderOtavka Jan 17, 2018
57f715a
Change description -> summary where needed
AlexanderOtavka Jan 17, 2018
cb9d9bb
Fix pagination bug
AlexanderOtavka Jan 17, 2018
563f2ff
Merge branch 'day-6' into day-7
AlexanderOtavka Jan 17, 2018
a97ca62
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
9eadc1d
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
ea92299
Handle invalid page tokens
AlexanderOtavka Jan 17, 2018
63c82d8
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
b1c59c4
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
a8a93bf
Change err -> error
AlexanderOtavka Jan 17, 2018
69d08f5
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
1197b7c
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
e666070
Fix bug when not sending page token
AlexanderOtavka Jan 17, 2018
621302b
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
77100cd
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
a49dd3b
Enable restart when attached to docker
AlexanderOtavka Jan 17, 2018
1880798
Remove launch debug config
AlexanderOtavka Jan 17, 2018
553a81b
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
24f0163
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
422d24e
Update error descriptions
AlexanderOtavka Jan 17, 2018
23af275
Simplify docker image naming
AlexanderOtavka Jan 17, 2018
9641fa9
Merge branch 'day-3' into day-4
AlexanderOtavka Jan 17, 2018
9081205
Merge branch 'day-4' into day-5
AlexanderOtavka Jan 17, 2018
df9fee0
Merge branch 'day-5' into day-6
AlexanderOtavka Jan 17, 2018
1929084
Merge branch 'day-6' into day-7
AlexanderOtavka Jan 17, 2018
3db9052
Merge branch 'day-7' into day-8
AlexanderOtavka Jan 17, 2018
4ccbf7f
Merge branch 'day-8' into day-9
AlexanderOtavka Jan 17, 2018
e50712e
Make link header relative
AlexanderOtavka Jan 23, 2018
24305f3
Merge branch 'day-06' into day-07
AlexanderOtavka Jan 23, 2018
ebea710
Merge branch 'day-07' into day-08
AlexanderOtavka Jan 23, 2018
2548a43
Merge branch 'day-08' into day-09
AlexanderOtavka Jan 23, 2018
c509927
Document link header
AlexanderOtavka Jan 23, 2018
8ff8905
Add .gitignore for api
AlexanderOtavka Jan 28, 2018
c78dbc3
Add webapp
AlexanderOtavka Jan 28, 2018
fd7764a
Merge branch 'day-01' into day-02
AlexanderOtavka Jan 29, 2018
9b0f365
Fix naming of fields
AlexanderOtavka Jan 29, 2018
97ea0f0
Merge branch 'day-02' into day-03
AlexanderOtavka Jan 29, 2018
741b584
Merge branch 'day-03' into day-04
AlexanderOtavka Jan 29, 2018
c815084
Merge branch 'day-04' into day-05
AlexanderOtavka Jan 29, 2018
f03aeca
Merge branch 'day-05' into day-06
AlexanderOtavka Jan 29, 2018
e4d5069
Merge branch 'day-06' into day-07
AlexanderOtavka Jan 29, 2018
2c66646
Merge branch 'day-07' into day-08
AlexanderOtavka Jan 29, 2018
d9e7a91
Merge branch 'day-08' into day-09
AlexanderOtavka Jan 29, 2018
bef07e3
Merge branch 'master' into day-01
AlexanderOtavka Feb 1, 2018
15b3577
Merge branch 'day-01' into day-02
AlexanderOtavka Feb 1, 2018
6dc155a
Merge branch 'day-02' into day-03
AlexanderOtavka Feb 1, 2018
c0b85e0
Merge branch 'day-03' into day-04
AlexanderOtavka Feb 1, 2018
a61bc1a
Merge branch 'day-04' into day-05
AlexanderOtavka Feb 1, 2018
23c1183
Merge branch 'day-05' into day-06
AlexanderOtavka Feb 1, 2018
bbd1ad3
Merge branch 'day-06' into day-07
AlexanderOtavka Feb 1, 2018
be9b31d
Merge branch 'day-07' into day-08
AlexanderOtavka Feb 1, 2018
3b925f5
Merge branch 'day-08' into day-09
AlexanderOtavka Feb 1, 2018
4e1f9a9
Fix bolding of readme
AlexanderOtavka Feb 1, 2018
68caa90
Merge branch 'day-01' into day-02
AlexanderOtavka Feb 1, 2018
ddd3a3b
Merge branch 'day-02' into day-03
AlexanderOtavka Feb 1, 2018
eea5632
Merge branch 'day-03' into day-04
AlexanderOtavka Feb 1, 2018
93b61c3
Merge branch 'day-04' into day-05
AlexanderOtavka Feb 1, 2018
6947ee7
Merge branch 'day-05' into day-06
AlexanderOtavka Feb 1, 2018
959bf5b
Merge branch 'day-06' into day-07
AlexanderOtavka Feb 1, 2018
73f58b9
Merge branch 'day-07' into day-08
AlexanderOtavka Feb 1, 2018
8849082
Merge branch 'day-08' into day-09
AlexanderOtavka Feb 1, 2018
837bf90
Switch up docker prod config
AlexanderOtavka Feb 10, 2018
3e9b8a6
Merge branch 'day-03' into day-04
AlexanderOtavka Feb 10, 2018
4f7d32b
Merge branch 'day-04' into day-05
AlexanderOtavka Feb 10, 2018
55e55e5
Merge branch 'day-05' into day-06
AlexanderOtavka Feb 10, 2018
f7cf9e4
Merge branch 'day-06' into day-07
AlexanderOtavka Feb 10, 2018
122dc06
Merge branch 'day-07' into day-08
AlexanderOtavka Feb 10, 2018
7ed978f
Merge branch 'day-08' into day-09
AlexanderOtavka Feb 10, 2018
c148e33
Add restart policy
AlexanderOtavka Feb 10, 2018
cff5e69
Merge branch 'day-03' into day-04
AlexanderOtavka Feb 10, 2018
154967e
Add restart to db
AlexanderOtavka Feb 10, 2018
a7e863e
Merge branch 'day-04' into day-05
AlexanderOtavka Feb 10, 2018
ced9404
Merge branch 'day-05' into day-06
AlexanderOtavka Feb 10, 2018
fbd30ac
Merge branch 'day-06' into day-07
AlexanderOtavka Feb 10, 2018
cb69204
Merge branch 'day-07' into day-08
AlexanderOtavka Feb 10, 2018
7317419
Merge branch 'day-08' into day-09
AlexanderOtavka Feb 10, 2018
e1e1f27
Detail project
AlexanderOtavka May 8, 2018
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
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to API",
"protocol": "inspector",
"address": "localhost",
"port": 9222,
"localRoot": "${workspaceFolder}/api",
"remoteRoot": "/var/api",
"restart": true
}
]
}
147 changes: 114 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,129 @@
# AppDev Cloud Services Training
# AppDev Cloud Services Training: Final Project 2018 Spring

Welcome to AppDev training! We are excited that you chose to learn about cloud
services, and we hope you enjoy the training. Please read through these
instructions to get an idea of how this course works, and don't hesitate to
reach out to Zander if you are confused about anything.
**Due:** June 4th (Contact Yash if you need an extension)

## How This Training Works
## Submitting

This repository will serve as the website for the training. There is a section
(also called a branch) for each day. You can jump to any section in the [table
of contents][#table-of-contents] below. Each section has the recommended
readings to be done before the session that day, as well as starter code for
that day for reference. Generally, you shouldn't replace the code you already
have with our starter code unless you miss a day of class. It is better for you
to get used to your own code.
You will submit this project with GitHub.

## Getting Started
1. [Fork this repository.](https://help.github.com/articles/fork-a-repo/)
2. [Clone the fork you just made.](https://help.github.com/articles/cloning-a-repository/)
3. Switch to the `final-project-2018-spring` branch.
* _If you are using Visual Studio Code:_ Click the button at the far left of
the bottom bar and pick the branch from the dropdown.
* _If you are using the terminal:_ Make sure you are in the directory that
you just cloned. Then, run `git checkout final-project-2018-spring`.
4. Split off a new branch. You might name it `my-final-project` or something.
* _If you are using Visual Studio Code:_ Click the branch button again, but
this time, select `+ Create new branch`. Then type in the new branch name.
* _If you are using the terminal:_ Run `git checkout -b my-final-project` to
create the new branch and switch to it in one go.
5. Make your changes and commit them.
* _If you are using Visual Studio Code:_ Switch to git panel on the left
sidebar. Write a commit message in the textbox describing your changes.
Then click the check mark button on the top bar.
* _If you are using the terminal:_ Run `git commit --all --message="Describe your changes here"`
to commit all your changes with the given message. If that is too wordy
for you, you can run `git commit -am "And describe your changes here"`
which is a shortcut for the above.
6. Push your changes.
* _If you are using Visual Studio Code:_ Click the button with up/down
arrows right next to the branch button.
* _If you are using the terminal:_ Run `git push origin my-final-project` to
send your changes to the repository your cloned from (called `origin`
here), and to the branch `my-final-project`.
7. [Create a pull request.](https://help.github.com/articles/creating-a-pull-request/)

**If you know nothing about git or GitHub**, or maybe you just aren't very
confident with them, then don't worry. We will learn some of the basics later in
this training, but for now, you can just download [the starter code for day
1][day1] as a .zip file with the green download button in the top right.
You may repeat steps 5 and 6 multiple times if you find that you have
multiple sets of changes. For example, you might write the documentation,
commit and push it, then write your code and commit and push that.

**If you are already familiar with git and GitHub**, you should have no problem
getting started. Just clone this repository and switch to [the day-1
branch][day1]. We recommend that you then split off a new branch from there,
just in case you want to refer back to day 1 at some point, but that is up to
you.
## The Assignment

### Required Tools
You will be writing documentation for and implementing a new request handler.
You should start with the documentation, because the documentation page
allows you to test your code.

You should try to install all of these before the first day of training. If you
have trouble getting any of them working, you can get help on the first day.
Your new handler should be able to accept get requests in the form:
`GET /tasks/123` where `123` is the ID of a particular task. This handler
should behave similarly to the one we wrote for `GET /tasks`, except instead
of returning a list of tasks, you should just return the task with the ID
that they gave you.

* [Yarn](https://yarnpkg.com/en/docs/install) lets us use code published by
other people.
* [Docker](https://www.docker.com/community-edition) allows us to run our code
on any system we need to.
* [Visual Studio Code](https://code.visualstudio.com/download), or if you
already have a favorite code editor, you can use that instead.
Don't forget to validate the request to make sure they send a valid object ID
and such. Also, if the task they asked for does not exist, be sure to send a
`404` status with an appropriate message.

## Examples

Note that the error messages don't have the be exactly the same as mine, they
should just get the point across of what went wrong.

### 1. The task exists

**Request**

_Method_: GET

_Path_: /tasks/123

**Response**

_Status_: 200

_Body_:

```
{
"_id": "123",
"text": "My task",
"isComplete": false
}
```

### 2. Invalid request

**Request**

_Method_: GET

_Path_: /tasks/this_is_not_a_valid_id

**Response**

_Status_: 400

_Body_:

```
{
"message": "Invalid request: Path Params.taskId does not match the format 'objectId'"
}
```

### 3. Task does not exist

**Request**

_Method_: GET

_Path_: /tasks/456

**Response**

_Status_: 404

_Body_:

```
{
"message": "No task with id '456'"
}
```

## Table of Contents

* [**Introduction**][intro]
* [Introduction][intro]
* [Day 1][day1]
* [Day 2][day2]
* [Day 3][day3]
Expand Down
1 change: 1 addition & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
11 changes: 11 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:8.9

COPY . /var/api
WORKDIR /var/api
RUN yarn install

ENV NODE_ENV=production

EXPOSE 80

CMD ["node", "index.js"]
44 changes: 44 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const express = require("express")
const swaggerJSDoc = require("swagger-jsdoc")
const swaggerUI = require("swagger-ui-express")
const readYAML = require("read-yaml")

require("express-async-errors")

const tasksRouter = require("./tasks")
const { HTTPError } = require("./util")

const PORT = 80

const swaggerSpec = swaggerJSDoc({
swaggerDefinition: readYAML.sync("./open-api.yml"),
apis: ["./tasks.js"]
})

express()
.use(express.json())

.get("/", (request, response) => response.redirect("/docs"))
.use("/docs", swaggerUI.serve, swaggerUI.setup(swaggerSpec))
.get("/docs.json", (request, response) =>
response.status(200).send(swaggerSpec)
)

.use("/tasks", tasksRouter)

.all("*", () => {
throw new HTTPError(404, "Not found")
})

.use((error, request, response, next) => {
if (error instanceof HTTPError) {
response.status(error.status).send({ message: error.message })
} else {
console.error(error)
response.status(500).send({ message: "Server error" })
}
})

.listen(PORT, () => {
console.log("API serving.")
})
76 changes: 76 additions & 0 deletions api/open-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
openapi: 3.0.0

info:
title: Cloud Services Training API
version: 1.0.0

components:
propSchemas:
TaskId:
type: string
description: The unique ID of the task.
format: objectId
TaskText:
type: string
description: The text content of the task.
TaskIsComplete:
type: boolean
description: Whether the task has been checked off.

schemas:
TaskCreate:
type: object
properties:
text:
$ref: "#/components/propSchemas/TaskText"
required:
- text
additionalProperties: false

TaskEdit:
type: object
properties:
text:
$ref: "#/components/propSchemas/TaskText"
isComplete:
$ref: "#/components/propSchemas/TaskIsComplete"
additionalProperties: false

Task:
type: object
properties:
_id:
$ref: "#/components/propSchemas/TaskId"
text:
$ref: "#/components/propSchemas/TaskText"
isComplete:
$ref: "#/components/propSchemas/TaskIsComplete"
required:
- _id
- text
- isComplete
additionalProperties: false

Error:
type: object
properties:
message:
type: string
required:
- message
additionalProperties: false

responses:
BadRequest:
description: The request is incorrectly formatted.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"

NotFound:
description: The requested resource could not be found.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
21 changes: 21 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "server",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "nodemon --inspect=0.0.0.0:9222 index.js"
},
"dependencies": {
"express": "^4.16.2",
"express-async-errors": "^2.1.0",
"jsonschema": "^1.2.2",
"mongodb": "^2.2.33",
"read-yaml": "^1.1.0",
"swagger-jsdoc": "^1.9.7",
"swagger-ui-express": "^2.0.14",
"urlsafe-base64": "^1.0.0"
},
"devDependencies": {
"nodemon": "^1.12.1"
}
}
Loading