-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
pr05 Typescript Migration #11: Migrate server/routes folder #3643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clairep94
wants to merge
29
commits into
processing:develop
Choose a base branch
from
clairep94:pr05/migrate_routes_folder
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
3720988
routes/user: update to ts, no-verify
clairep94 eb76d06
routes/user: remove new from Router init
clairep94 326935b
routes/api: update to ts, no-verify
clairep94 267f0de
routes/api: remove new, add passport types
clairep94 13ff418
routes/asset: update to ts, no-verify
clairep94 17ca551
routes/asset: remove new for router init, disable eslint no-default-e…
clairep94 eddbb76
routes/aws: update to ts, no-verify
clairep94 df2cee5
routes/aws: remove new for router init, disable eslint no-default-exp…
clairep94 7b6a8dc
routes/collection: update to ts, no-verify
clairep94 c1ab80a
routes/collection: remove new for router init, disable eslint no-defa…
clairep94 52bcbad
routes/embed: update to ts, no-verify
clairep94 3504485
routes/embed: remove new for router init, disable eslint no-default-e…
clairep94 d375062
routes/files: update to ts, no-verify
clairep94 f62e973
routes/files: remove new for router init, disable eslint no-default-e…
clairep94 fed552d
routes/session: migrate to ts, no-verify
clairep94 c737eac
routes/session: remove new for router init, disable eslint no-default…
clairep94 31710a2
routes/project: migrate to ts, no-verify
clairep94 b7658de
routes/project: remove new for router init, disable eslint no-default…
clairep94 da9ddd0
routes/redirectEmbed: migrate to ts, no-verify
clairep94 e036db0
routes/redirectEmbed: remove new for router init, disable eslint no-d…
clairep94 4fc47e4
routes/server: migrate to ts, no-verify
clairep94 41134a2
routes/server: remove new for router init, disable eslint no-default-…
clairep94 2b247f7
routes/passport: migrate to ts, no-verify
clairep94 2a189ee
routes/passport: remove new for router init, disable eslint no-defaul…
clairep94 a18524c
routes/passport: add types from express and passport
clairep94 e1f59df
routes/server: revert back to js for separate pr migration
clairep94 793e95c
patch fix to remove type errors for routes/passport
clairep94 d7ecaa6
Merge branch 'develop' into pr05/migrate_routes_folder
khanniie 0847612
address extraneous export
clairep94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Router, Request, Response, NextFunction } from 'express'; | ||
import passport from 'passport'; | ||
|
||
const router = Router(); | ||
|
||
const authenticateOAuth = (service: string) => ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction | ||
) => { | ||
passport.authenticate( | ||
service, | ||
{ failureRedirect: '/login' }, | ||
(err: any, user: any) => { | ||
if (err) { | ||
// use query string param to show error; | ||
res.redirect(`/account?error=${service}`); | ||
return; | ||
} | ||
|
||
if (!user) { | ||
res.redirect(`/account?error=${service}NoUser`); | ||
return; | ||
} | ||
|
||
req.logIn(user, (loginErr) => { | ||
if (loginErr) { | ||
next(loginErr); | ||
return; | ||
} | ||
res.redirect('/'); | ||
}); | ||
} | ||
)(req, res, next); | ||
}; | ||
|
||
router.get('/auth/github', passport.authenticate('github')); | ||
router.get('/auth/github/callback', authenticateOAuth('github')); | ||
|
||
router.get('/auth/google', passport.authenticate('google')); | ||
router.get('/auth/google/callback', authenticateOAuth('google')); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
server/routes/session.routes.js → server/routes/session.routes.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { Router } from 'express'; | ||
import * as SessionController from '../controllers/session.controller'; | ||
|
||
const router = new Router(); | ||
const router = Router(); | ||
|
||
router.post('/login', SessionController.createSession); | ||
|
||
router.get('/session', SessionController.getSession); | ||
|
||
router.get('/logout', SessionController.destroySession); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit but are there better types for these other than any? something from passport's types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find an
error
anduser
type from the passport @types, but I think they declareUser
as{}
, and useerr: any
I think when I migrate the
User
model, I can import it and use it, but error might just stay asany