-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
232 lines (152 loc) · 5.98 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
-- install JSON server --
npx json-server --port 3001 --watch db.json
npm install axios
-- Install json-server as a development dependency (only used during development) --
npm install json-server --save-dev
to package.json -> "server": "json-server -p3001 --watch db.json"
npm run server
-- create a new template for application --
npm init
node index.js //run app
-- express --
npm install express
-- nodemon --
npm install --save-dev nodemon
node_modules/.bin/nodemon index.js //start app with nodemon
npm run dev //after adding "dev": "nodemon index.js", script to package.json
-- postman --
https://www.postman.com/downloads/
-- rest client --
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
overriding default NOT FOUND message for http status (404)
https://stackoverflow.com/questions/14154337/how-to-send-a-custom-http-status-message-in-node-express/36507614#36507614
-- cors --
npm install cors
https://fullstackopen-notes-fglsn.herokuapp.com/
== heroku subtree ==
https://dev.to/crrojas88/deploying-a-git-subdirectory-to-heroku-23ld
git subtree push --prefix part03/phonebook-back heroku main
npm install mongoose
== phonebook: ==
heroku git:remote -a fullstackopen-phonebook-fglsn
heroku config:set MONGODB_URI="mongodb+srv://<username>:<password>@cluster0.rxxdbit.mongodb.net/phonebookApp?retryWrites=true&w=majority"
git subtree push --prefix part03/phonebook-back heroku main
== notes ==
heroku git:remote -a fullstackopen-notes-fglsn
heroku config:set MONGODB_URI="mongodb+srv://<username>:<password>@cluster0.yitvnyc.mongodb.net/noteApp?retryWrites=true&w=majority"
git subtree push --prefix theory/part3 heroku main
== ESlint ==
back:
npm install eslint --save-dev
npx eslint --init
to package.json scripts section:
"lint": "eslint .",
"lint:fix": "npx eslint . --fix"
front:
npm install --save-dev eslint-plugin-jest
testing lib
== jest ==
__Back__
npm install --save-dev jest
into to scripts of package.json :
"test": "jest --verbose"
to the end of package.json :
"jest": {
"testEnvironment": "node"
}
to "env" section of eslintrc.js :
'jest': true,
(** to run one test, use for.ex :
npm test -- tests/blog_api.test.js
or
npm test -- -t 'test desc/name' )
__Front__
==test-lib==
npm install --save-dev @testing-library/react @testing-library/jest-dom
run tests in 'normal mode'
CI=true npm test
==user-event lib==
npm install --save-dev @testing-library/user-event
// If there is a mismatch between the version of a dependency
jest-watch-typeahead that create-react-app and user-event are using:
npm install -D --exact jest-watch-typeahead@0.6.5
( at least starting from macOS Sierra, running tests in watch mode issues some warnings to the console, that can be removed by installing Watchman.
https://facebook.github.io/watchman/
)
__End to end__
==cypress==
npm install --save-dev cypress
to package-json scripts: "cypress:open": "cypress open"
to backend package.json scripts: "start:test": "cross-env NODE_ENV=test node index.js"
npm install eslint-plugin-cypress --save-dev
to .eslintrc.js 'env': "cypress/globals": true
to .eslintrc.js 'plugins: "cypress"
list of the most common assertions which can be used with should
https://docs.cypress.io/guides/references/assertions.html#BDD-Assertions
https://github.com/cypress-io/cypress/issues/9349
_____
== supertest ==
npm install --save-dev supertest
== express-async-errors library ==
npm install express-async-errors
into app.js add : require('express-async-errors')
Creating users:
== bcrypt ==
npm install bcrypt
== jsonwebtoken ==
npm install jsonwebtoken
(If the application has multiple interfaces requiring identification, JWT's validation should be separated into its own middleware. Some existing library like express-jwt could also be used. )
==logout==
window.localStorage.removeItem('loggedNoteappUser')
or with the command which empties localstorage completely:
window.localStorage.clear()
== prop-types ==
npm install prop-types
__Redux__
npm install redux
npm install --save-dev deep-freeze
npm install react-redux
npm install @reduxjs/toolkit
https://chrome.google.com/webstore/detail/redux-devtools/lmThkpmbekcpmknklioeibfkpmmfibljd/related
npm install redux-thunk
__Router__
npm install react-router-dom
__HOOKS__
https://fullstackopen.com/en/part7/custom_hooks
__Bootstrap__
npm install react-bootstrap
to head tag of pubic/index.html:
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossOrigin="anonymous"
/>
__MUI__
npm install @mui/material @emotion/react @emotion/styled
to head:
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
other ui frameworks:
https://react.semantic-ui.com/
https://bulma.io/
https://ant.design/
https://get.foundation/
https://chakra-ui.com/
https://tailwindcss.com/
https://semantic-ui.com/
https://mantine.dev/
https://react.fluentui.dev/
npm install styled-components
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
__Check dependencies && Security__
npm outdated --depth 0
"The dependencies can be brought up to date by updating the file package.json. The best way to do that is by using a tool called npm-check-updates. It can be installed globally by running the command"
npm install -g npm-check-updates
The file package.json is brought up to date by running the command ncu -u.
ncu -u
npm audit
npm audit fix
The documentation for Express includes a section on security: Production Best Practices: Security, which is worth a read through. It is also recommended to add a library called Helmet to the backend. It includes a set of middlewares that eliminate some security vulnerabilities in Express applications.
Using the ESlint security-plugin is also worth doing.
https://fullstackopen.com/en/part7/class_components_miscellaneous
npm install --save-dev --save-exact prettier