-
Notifications
You must be signed in to change notification settings - Fork 0
Typescript Migration - Backend #26
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
Draft
mikephu
wants to merge
21
commits into
main
Choose a base branch
from
backend-typescript-migration
base: main
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.
Draft
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b970fc2
feat: initial backend typescript setup
lxkedinh 6ca7170
chore: Merge branch 'main' into backend-typescript-migration
lxkedinh d0ecca0
chore: update yarn.lock
lxkedinh 94802d7
feat: created Request and Response types
lxkedinh 7ec9043
chore: changed backend eslint rules
lxkedinh 16bde57
fix: typed express response type
lxkedinh 355e9ba
migrated events/guilds controllers to typescript
mikephu ed8da1b
fixed imports and function typing
mikephu 81ef3a7
feat: migrated users controller
lxkedinh c2f653d
chore: Merge branch 'main' into backend-typescript-migration
lxkedinh 612fb2e
fix: fail response body type
lxkedinh 15c001f
fix: adjusted export
lxkedinh 93b5dd2
fix: adjust exports in events/guild controllers
mikephu 9302270
feat: migrate events/guilds routes
mikephu c6c4677
feat: migrated auth controller and jwt utility functions
lxkedinh c6b351a
chore: Merge branch 'main' into backend-typescript-migration
lxkedinh a95783c
feat: migrated index.js and users api router
lxkedinh 7a88302
fix: fixed ESlint errors
mikephu d499196
fix: migrated local auth api route
lxkedinh e867ea8
feat: migrated auth api routes
lxkedinh 77eed3e
chore: updated with main
lxkedinh 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
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 |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ | |
| .vscode | ||
| node_modules/ | ||
| yarn-error.log | ||
| **.env | ||
| **.env | ||
| **/build/ | ||
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,22 @@ | ||
| { | ||
| "root": true, | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { | ||
| "sourceType": "script", | ||
| "ecmaVersion": 2023 | ||
| }, | ||
| "plugins": ["@typescript-eslint"], | ||
| "env": { | ||
| "node": true, | ||
| "amd": true | ||
| }, | ||
| "rules": { | ||
| "@typescript-eslint/no-explicit-any": "off" | ||
| }, | ||
| "ignorePatterns": ["/__tests__/**/*"], | ||
| "extends": [ | ||
| "prettier", | ||
| "eslint:recommended", | ||
| "plugin:@typescript-eslint/recommended" | ||
| ] | ||
| } |
This file was deleted.
Oops, something went wrong.
Empty file.
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,21 @@ | ||
| import prisma from "../utils/prisma"; | ||
| import { Guild } from ".prisma/client/index"; | ||
|
|
||
| async function getAllGuilds() { | ||
| const query = await prisma.guild.findMany(); | ||
| return query; | ||
| } | ||
mikephu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| async function getGuild(guildId: string): Promise<Guild | null> { | ||
| const query = await prisma.guild.findFirst({ | ||
| where: { | ||
| guildId: guildId, | ||
| }, | ||
| }); | ||
| return query; | ||
| } | ||
|
|
||
| module.exports = { | ||
| getGuild, | ||
| getAllGuilds, | ||
| }; | ||
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
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,21 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "lib": ["ES2023"], | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "outDir": "./build", | ||
| "allowJs": true, | ||
| "module": "Node16", | ||
| "moduleResolution": "Node16", | ||
| "target": "ES2022" | ||
| }, | ||
| "exclude": ["./__tests__/**/*"], | ||
| "include": [ | ||
| "./controllers/**/*", | ||
| "./routes/**/*", | ||
| "./utils/**/*", | ||
| "./index.js" | ||
| ] | ||
| } |
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,37 @@ | ||
| import * as Express from "express"; | ||
| import { Send } from "express-serve-static-core"; | ||
|
|
||
| /** | ||
| * @template T, V | ||
| * @param T - (optional) structure of request route parameters | ||
| * @param V - (optional) structure of request body | ||
| * | ||
| * void = optional generic parameters | ||
| */ | ||
| export type APIRequest<T = void, V = void> = Express.Request<T, any, V>; | ||
|
|
||
| /** | ||
| * @template T | ||
| * @param T - structure of response body | ||
| */ | ||
| export interface APIResponse<T = Record<string, any>> extends Express.Response { | ||
| json: Send< | ||
| SuccessResponseBody<T> | FailResponseBody<T> | ErrorResponseBody, | ||
| this | ||
| >; | ||
| } | ||
|
|
||
| type SuccessResponseBody<T = Record<string, any>> = { | ||
| status: "success"; | ||
| data: T; | ||
| }; | ||
|
|
||
| type FailResponseBody<T = Record<string, any>> = { | ||
| status: "fail"; | ||
| data: Record<keyof T, string>; | ||
| }; | ||
|
|
||
| type ErrorResponseBody = { | ||
| status: "error"; | ||
| message: string; | ||
| }; |
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,3 @@ | ||
| import { PrismaClient } from "@prisma/client"; | ||
| const prisma = new PrismaClient(); | ||
| export default prisma; |
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.