Skip to content

Commit 42518c7

Browse files
initial commit.
0 parents  commit 42518c7

32 files changed

+33907
-0
lines changed

.eslintrc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true,
6+
"jest": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:react/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 12,
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react"
21+
],
22+
"rules": {
23+
}
24+
}

.gitignore

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
.parcel-cache
78+
79+
# Next.js build output
80+
.next
81+
out
82+
83+
# Nuxt.js build / generate output
84+
.nuxt
85+
dist
86+
87+
# Gatsby files
88+
.cache/
89+
# Comment in the public line in if your project uses Gatsby and not Next.js
90+
# https://nextjs.org/blog/next-9-1#public-directory-support
91+
# public
92+
93+
# vuepress build output
94+
.vuepress/dist
95+
96+
# Serverless directories
97+
.serverless/
98+
99+
# FuseBox cache
100+
.fusebox/
101+
102+
# DynamoDB Local files
103+
.dynamodb/
104+
105+
# TernJS port file
106+
.tern-port
107+
108+
# Stores VSCode versions used for testing VSCode extensions
109+
.vscode-test
110+
111+
# yarn v2
112+
.yarn/cache
113+
.yarn/unplugged
114+
.yarn/build-state.yml
115+
.yarn/install-state.gz
116+
.pnp.*
117+
118+
.DS_Store
119+
.vscode
120+
# Logs
121+
logs
122+
*.log
123+
npm-debug.log*
124+
yarn-debug.log*
125+
yarn-error.log*
126+
lerna-debug.log*
127+
.pnpm-debug.log*
128+
129+
# Diagnostic reports (https://nodejs.org/api/report.html)
130+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
131+
132+
# Runtime data
133+
pids
134+
*.pid
135+
*.seed
136+
*.pid.lock
137+
138+
# Directory for instrumented libs generated by jscoverage/JSCover
139+
lib-cov
140+
141+
# Coverage directory used by tools like istanbul
142+
coverage
143+
*.lcov
144+
145+
# nyc test coverage
146+
.nyc_output
147+
148+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
149+
.grunt
150+
151+
# Bower dependency directory (https://bower.io/)
152+
bower_components
153+
154+
# node-waf configuration
155+
.lock-wscript
156+
157+
# Compiled binary addons (https://nodejs.org/api/addons.html)
158+
build/Release
159+
160+
# Dependency directories
161+
node_modules/
162+
jspm_packages/
163+
164+
# Snowpack dependency directory (https://snowpack.dev/)
165+
web_modules/
166+
167+
# TypeScript cache
168+
*.tsbuildinfo
169+
170+
# Optional npm cache directory
171+
.npm
172+
173+
# Optional eslint cache
174+
.eslintcache
175+
176+
# Microbundle cache
177+
.rpt2_cache/
178+
.rts2_cache_cjs/
179+
.rts2_cache_es/
180+
.rts2_cache_umd/
181+
182+
# Optional REPL history
183+
.node_repl_history
184+
185+
# Output of 'npm pack'
186+
*.tgz
187+
188+
# Yarn Integrity file
189+
.yarn-integrity
190+
191+
# dotenv environment variables file
192+
.env
193+
.env.test
194+
.env.production
195+
196+
# parcel-bundler cache (https://parceljs.org/)
197+
.cache
198+
.parcel-cache
199+
200+
# Next.js build output
201+
.next
202+
out
203+
204+
# Nuxt.js build / generate output
205+
.nuxt
206+
dist
207+
208+
# Gatsby files
209+
.cache/
210+
# Comment in the public line in if your project uses Gatsby and not Next.js
211+
# https://nextjs.org/blog/next-9-1#public-directory-support
212+
# public
213+
214+
# vuepress build output
215+
.vuepress/dist
216+
217+
# Serverless directories
218+
.serverless/
219+
220+
# FuseBox cache
221+
.fusebox/
222+
223+
# DynamoDB Local files
224+
.dynamodb/
225+
226+
# TernJS port file
227+
.tern-port
228+
229+
# Stores VSCode versions used for testing VSCode extensions
230+
.vscode-test
231+
232+
# yarn v2
233+
.yarn/cache
234+
.yarn/unplugged
235+
.yarn/build-state.yml
236+
.yarn/install-state.gz
237+
.pnp.*

README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Advanced Web Applications Sprint Challenge
2+
3+
**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.**
4+
5+
This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **advanced web applications**. During this sprint, you studied **React testing, client-side auth, HTTP methods, and Vercel**.
6+
7+
In your challenge this week, you will demonstrate your mastery of these skills by creating **a login page** and **basic CRUD application.**
8+
9+
This is an individual assessment. All work must be your own. All projects will be submitted to codegrade for automated review. You will also be given feedback by code reviewers the Monday (Wednesday for PT) after challenge submissions. For more information on the review process [click here.](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a)
10+
11+
You are not allowed to collaborate during the sprint challenge. However, you are encouraged to follow the twenty-minute rule and seek support by dropping a :wave: in your help channel when needed.
12+
13+
## Introduction
14+
15+
In this project you will create a login page and request a token from the server that you'll use to send all other requests to the server. You will then be able to fetch the article data array, update data, and delete data, and watch the fun happen!
16+
17+
## Instructions
18+
19+
### Task 1: Project Setup
20+
21+
* [ ] Fork and clone this repository.
22+
* [ ] Implement the project with the `<firstName-lastName>` branch, committing changes regularly.
23+
* [ ] Push commits: git push origin `<firstName-lastName>`.
24+
* [ ] **RUN** `npm install` to install your dependencies.
25+
* [ ] **RUN** `npm start` to start your application backend and frontend.
26+
* [ ] **RUN** `npm test` to start your application's test runner.
27+
28+
### Task 2: CodeGrade Setup
29+
30+
* [ ] Open the assignment in Canvas and click on the "Set up git" option.
31+
* [ ] Follow instructions to set up Codegrade's Webhook and Deploy Key, making sure your deployment is set to your `<firstName-lastName>`. **Make sure to add in `?branch=<firstname-lastname>` at the end of your webhook payload URL.**
32+
* [ ] Push your first commit: `git commit --allow-empty -m "first commit" && git push`
33+
* [ ] Check to see that Codegrade has accepted your git submission.
34+
35+
### Task 3: Project Requirements
36+
37+
Your finished project must include all of the following requirements.
38+
39+
**See reference materials at the bottom of the this document for API Reference Details.**
40+
41+
#### Login Authentication
42+
> *Build a login form to authenticate your users along with all the components and utilities needed to support authentication.*
43+
44+
* [ ] In `Login.js`, build all UI and state functionality needed to capture a username and password. On a successful login, redirect user to the `View.js` component.
45+
* [ ] **Make sure that the input for your username and password includes the id="username" and id="password" attributes. Codegrade autotests will fail without them.**
46+
* [ ] **Make sure that the submit button to your login form includes the id="submit" attribute.**
47+
* [ ] In `Login.js`, add a p tag that will hold an error state if occurs. Add in all state functionality needed to support error display.
48+
* [ ] **Make sure your error p tag has an id="error" attribute attached. Codegrade autotests will fail without them.**
49+
* [ ] Construct an http request that retrieves an auth token from the server when the username `Lambda` and the password `School` is passed into the request. Complete successful login auth flow and redirect to `View.js.`
50+
* [ ] Display an appropriate error message when login is not successful.
51+
52+
#### Route Authentication
53+
> *Build the needed utilities to restrict access to private routes.*
54+
* [ ] Build a `PrivateRoute` component within the components folder.
55+
* [ ] Use the `PrivateRoute` component to build a route rendering `View.js` to the path `/view`.
56+
* [ ] Use the `PrivateRoute` component to build a route rendering `Logout.js` to the path `/logout`.
57+
58+
#### Request Authentication
59+
> *Complete the requests needed to execute all CRUD functions.*
60+
* [ ] Build a `axiosWithAuth` module within the utils folder to create an instance of axios with the authentication header.
61+
* [ ] Complete the `services/articleService.js` module. It should make an authenticated call to retrieve and return all articles from the server.
62+
63+
* [ ] In `View.js`, when the component mounts, use `articleService` to make an http request and add all articles to state.
64+
65+
* [ ] In `View.js`, complete `handleDelete` so that a http request is made that deletes the article with the included id. After successfully deleting the article on the api, update local state to reflect these changes.
66+
67+
* [ ] In `EditForm.js`, make a http request to get the article with the id `editId`. Save the result in state.
68+
69+
* [ ] In `View.js`, complete `handleEdit` so that a http request is made that updates the passed in article. Set the editing state to false when the request is complete. After successfully deleting the article on the api, update local state to reflect these changes.
70+
71+
72+
#### Logout Authentication
73+
> *Add in the http requests needed to logout of the application.*
74+
75+
* [ ] In `Logout.js`, execute a http request to logout on mount. When the request is complete, the user's security token should be removed and the browser should redirect to the login page.
76+
77+
#### Advanced Testing
78+
> *Add the following tests within Article.test.js.*
79+
* [ ] Build a test that shows the `Article` component, given the correct props, can render without errors.
80+
* [ ] Build a test that shows that when a correctly formatted article is passed into the `Article` component, the correct headline, author, summary and body are displayed.
81+
* [ ] The `Article` component should display "Associated Press" when an author attribute is not avalible. Build a test that verifies that that is true.
82+
* [ ] Build a test that show that when the deleteButton is pressed on an Article, the handleDelete functional property is executed.
83+
84+
> *Add the following tests within View.test.js.*
85+
* [ ] Build a test that shows the `View` component can render zero articles without errors. Make sure the mock service called made when View mounts.
86+
* [ ] Build a test that shows the `View` component can render three articles without errors. Make sure the mock service called made when View mounts.
87+
88+
**Notes:**
89+
* You are welcome to create additional files but **do not move or rename existing files** or folders.
90+
* Do not change your `package.json` file except to install additional libraries.
91+
* In your solution, it is essential that you follow best practices and produce clean and professional results.
92+
* Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work.
93+
* It is better to submit a challenge that meets MVP than one that attempts too much and does not.
94+
95+
### Reference Materials
96+
97+
#### API Documentation
98+
* **[POST]** * to `http://localhost:5000/api/login`: returns a the current authenication information of the user. Pass in the following credentials as the `body` of the request: `{ username: 'Lambda', password: 'School' }` for a successful login.
99+
100+
* **[POST]** * to `http://localhost:5000/api/logout`: returns the expired authentication information of the user.
101+
102+
* **[GET]** to `http://localhost:5000/api/articles`: returns the all posts currently available. **This endpoint can only be accessed by an authenticated user.**
103+
104+
* **[POST]** to `http://localhost:5000/api/articles`: creates a article object. Returns all available articles. Pass the article as the `body` of the request. **This endpoint can only be accessed by an authenticated user.**
105+
106+
* **[PUT]** to `http://localhost:5000/api/articles/:id`: updates the article using the `id` passed as part of the URL. Returns all available articles. Send the updated article object as the `body` of the request. **This endpoint can only be accessed by an authenticated user.**
107+
108+
* **[DELETE]** to `http://localhost:5000/api/articles/:id`: removes the article with the `id` referenced. Returns all available articles. **This endpoint can only be accessed by an authenticated user.**
109+
110+
#### Article Data Structure
111+
```
112+
{
113+
id: 'aMqwd', //unique article id
114+
headline: "headline", //title of article
115+
createdOn: '2021-08-09T18:02:38-04:00
116+
', //timestamp of when article was added
117+
summary: "summary", //short summary statement of article
118+
body: "" //paragraph of article text
119+
}
120+
```
121+
122+
## Submission format
123+
* [ ] Submit via Codegrade by commiting and pushing any new changes.
124+
* [ ] Check codegrade for automated feedback.
125+
* [ ] Check codegrade on Monday following the Sprint Challenge for reviewer feedback. For more information on how to access and read your feedback, check [here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a)
126+
* [ ] Any changes pushed to your <firstName-lastName> branch will resubmited to codegrade if pushed before the sprint challenge deadline. Changes after the deadline will not be reviewed.
127+
128+
## Interview Questions
129+
130+
Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. Add your answers to the questions within `interview_answers.md` file. These will not be counted as a part of your sprint score but will be helpful for preparing you for your endorsement interview, and enhancing overall understanding.
131+
132+
1. Explain what a token is used for.
133+
2. What steps can you take in your web apps to keep your data secure?
134+
3. Describe how web servers work.
135+
4. Which HTTP methods can be mapped to the CRUD acronym that we use when interfacing with APIs/Servers.

0 commit comments

Comments
 (0)