You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migration.md
+24-5Lines changed: 24 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# Migration Guide
2
2
3
+
## What version do you have?
4
+
> Choose the version you have before upgrading, and follow the guide to the bottom from there.
5
+
- [Version 0.x.x](#version-0.x.x-->-1.x.x)
6
+
- [Version 1.x.x](#version-1.x.x-->-2.x.x)
7
+
- [Version 2.x.x](#version-2.x.x-->-3.x.x)
8
+
3
9
## Version 0.x.x -> 1.x.x
4
10
5
11
1. Remove `response` parameter from responders and handlers
@@ -31,7 +37,7 @@
31
37
```typescript
32
38
// Set model
33
39
router.use((request, response, next) => {
34
-
if (await setModel(request, response, BaseUser)) {
40
+
if (await setModel(request, response, ExampleUser)) {
35
41
// Note that this next() call is now in an if-statement around the setModel()
36
42
next();
37
43
}
@@ -51,7 +57,7 @@
51
57
// Set model
52
58
router.use((request, response, next) => {
53
59
// vvv add this for auth routes
54
-
if (await setModel(request, response, BaseUser, true)) {
60
+
if (await setModel(request, response, ExampleUser, true)) {
55
61
// Note that this next() call is now in an if-statement around the setModel()
56
62
next();
57
63
}
@@ -110,11 +116,24 @@
110
116
1. Auth tokens are now completely stateless. Remove the `token` field from your User entity.
111
117
2. Login now issues a refresh token.
112
118
1. Make a POST endpoint in your auth router:
113
-
`router.post('/refresh', refreshTokenEndpoint);`
114
-
2. Update your front-end auth service to save the `refreshToken` and `refreshExpiration` from the `loginEndpoint`
115
-
3. Set a timeout to call the `refreshTokenEndpoint` route when the access token expires. `refreshTokenEndpoint` will return an updated user object, including a new access token & expiration time.
2. Update your front-end auth refreshTokenservice to save the `refreshToken` and `refreshExpiration` from the `loginEndpoint`
121
+
3. Set a timeout to call the `refreshTokenEndpoint` route when the access token expires. Setup the body like this: `{ __refreshToken: myRefreshToken }`. This will return an updated user object, including a new access token & expiration time.
116
122
3.**(Optional)** PointyAPI now supports `UUID`. Follow the steps in the Readme to enable UUID (strongly recommended for production).
117
123
118
124
**NOTE** If you are already in production and decide to migrate to UUID, you must make sure to update relations etc
119
125
120
126
4.**(Optional)** Guards will now issue a `401` only if a token is not present/valid, otherwise will issue a `403`. This may help determine if the user is authenticated/authorized on the front-end.
127
+
128
+
## Version 2.x.x -> 3.x.x
129
+
130
+
1. If you use the PointyAPI HTTP Client, the functions have swapped the `bearer` and `expect` parameters. You must swap these in your code.
131
+
2. If your code uses a custom database error handler, this should be removed and the pointyapi error handler used instead.
132
+
3.`CLIENT_URL` is no longer used for CORS policy. Now you should use `ALLOW_ORIGINS`. **However, `CLIENT_URL` is still used for links, etc - so don't remove it**.
0 commit comments