forked from async-labs/saas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.note
67 lines (42 loc) · 1.76 KB
/
.note
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
helmet and compression for Express servers
SEO (robots and sitemap) for APP and API
Logs for API with winston
Google Analytics in Chapter 12
deleteFiles after introducing Post
---
makeQueryString when it is needed
Since `href` has to be URI-encoded, we convert `redirectUrlAfterLogin` string into URI-encoded string using `makeQueryString` method. We define this method in a new file `book/5-begin/app/lib/api/makeQueryString.ts`:
```
function makeQueryString(params) {
const query = Object.keys(params)
.filter((k) => !!params[k])
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
.join('&');
return query;
}
export { makeQueryString };
```
`makeQueryString` method relies on native (part of official API) JavaScript method `encodeURIComponent` that URI-encodes string:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
So if `redirectUrlAfterLogin` has value `?x=test1&y=test2` then `qs` will be `%3Fx%3Dtest1%26y%3Dtest2` and the last string is a valid format for URL:
```
console.log(makeQueryString('?x=test1&y=test2'));
// expected output: "%3Fx%3Dtest1%26y%3Dtest2"
```
We URI encode `qs` part of our API endpoint because entire string for `href` must be in valid, URI-encoded, format. You can read more on URL syntax here:
https://www.w3.org/Addressing/URL/url-spec.html
---
cookie:
domain: process.env.COOKIE_DOMAIN
if (process.env.NODE_ENV === 'production') {
server.set('trust proxy', 1); // sets req.hostname, req.ip
sessionOptions.cookie.secure = true; // sets cookie over HTTPS only
}
---
app//.eslintrc.js
api/.eslintrc.js
'@typescript-eslint/no-explicit-any': 'off',
---
Autocomplete component should be a custom feature
---
discuss having Signup page in addition to Login