Skip to content

Commit

Permalink
Merge branch 'main' into 626-chore-move-authentication-route-to-speci…
Browse files Browse the repository at this point in the history
…fic-endpoints
  • Loading branch information
garrettladley authored Apr 25, 2024
2 parents 0c76214 + a28089a commit effb765
Show file tree
Hide file tree
Showing 273 changed files with 16,739 additions and 101 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Dashboard

permissions: read-all

on:
push:
paths:
- frontend/dashboard/**
- .github/workflows/dashboard.yml
pull_request:
types: opened
paths:
- frontend/dashboard/**
- .github/workflows/dashboard.yml

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/dashboard/yarn.lock
- name: Install dependencies
run: |
cd frontend/dashboard
yarn install
- name: Format
run: |
cd frontend/dashboard
yarn format
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/dashboard/yarn.lock
- name: Install dependencies
run: |
cd frontend/dashboard
yarn install
- name: Lint
run: |
cd frontend/dashboard
yarn lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/dashboard/yarn.lock
- name: Install dependencies
run: |
cd frontend/dashboard
yarn install
- name: Test
run: |
cd frontend/dashboard
yarn test
41 changes: 41 additions & 0 deletions .github/workflows/dashboard_codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Dashboard CodeQL

on:
push:
paths:
- "frontend/dashboard/**"
- ".github/workflows/dashboard_codeql.yml"
pull_request:
types: [opened]
paths:
- "frontend/dashboard/**"
- ".github/workflows/dashboard_codeql.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
security-events: write
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
queries: security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
with:
working-directory: frontend/dashboard
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: dashboard
2 changes: 1 addition & 1 deletion .github/workflows/web_codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
paths:
- "frontend/sac-web/**"
- ".github/workflows/mweb_codeql.yml"
- ".github/workflows/web_codeql.yml"
pull_request:
types: [opened]
paths:
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
<img src="https://github.com/GenerateNU/sac/actions/workflows/web_codeql.yml/badge.svg"
alt="Web CodeQL Workflow Status" />
</a>

<br />

<a href="https://github.com/GenerateNU/sac/actions/workflows/dashboard.yml">
<img src="https://github.com/GenerateNU/sac/actions/workflows/dashboard.yml/badge.svg"
alt="Dashboard Workflow Status" />
</a>

<a href="https://github.com/GenerateNU/sac/actions/workflows/dashboard_codeql.yml">
<img src="https://github.com/GenerateNU/sac/actions/workflows/dashboard_codeql.yml/badge.svg"
alt="Dashboard CodeQL Workflow Status" />
</a>
</div>

## Repo Activity
Expand Down
2 changes: 1 addition & 1 deletion backend/entities/users/tag/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (ut *UserTagController) CreateUserTags(c *fiber.Ctx) error {
// @Accept json
// @Produce json
// @Param userID path string true "User ID"
// @Success 201 {object} []models.Tag
// @Success 201 {object} fiber.StatusNoContent
// @Failure 400 {object} errors.Error
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
Expand Down
4 changes: 4 additions & 0 deletions frontend/dashboard/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "next/core-web-vitals",
"plugins": ["prettier"]
}
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions frontend/dashboard/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
36 changes: 36 additions & 0 deletions frontend/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "sac-dashboard",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --write .",
"test": "echo \"Woah there, we have no frontend tests as of right now. Let's just say we're passing.\" && exit 0"

},
"dependencies": {
"@reduxjs/toolkit": "^2.2.3",
"next": "14.2.2",
"react": "^18",
"react-dom": "^18",
"react-redux": "^9.1.1",
"zod": "^3.23.3"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.19",
"eslint": "^8",
"eslint-config-next": "14.2.2",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.4"
}
}
9 changes: 9 additions & 0 deletions frontend/dashboard/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

export default config;
File renamed without changes
File renamed without changes
35 changes: 35 additions & 0 deletions frontend/dashboard/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

export const API_BASE_URL = 'http://127.0.0.1:8080/api/v1';

// BaseAPI for the entire application:
export const baseApi = createApi({
baseQuery: fetchBaseQuery({
baseUrl: API_BASE_URL,
credentials: 'include',
}),
tagTypes: [
"User",
"Tag",
"Category",
"Club",
"Contact",
"Event",
"PointOfContact",
"File",
"Follower",
"Member",
],
endpoints: () => ({}),
});

// Add query params to a request:
export function handleQueryParams(baseUrl: string, queryParams?: Record<string, string | number | boolean>): string {
const url = new URL(baseUrl);
if (queryParams) {
Object.entries(queryParams).forEach(([key, value]) => {
url.searchParams.append(key, value.toString());
});
}
return url.toString();
}
72 changes: 72 additions & 0 deletions frontend/dashboard/src/api/authApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { baseApi } from "./api";
import { LoginRequestBody, RefreshTokenRequestBody } from "../types/auth";
import { User, userSchema } from "../types/user";
import { EmailRequestBody, VerifyEmailRequestBody, VerifyPasswordResetTokenRequestBody } from "../types/verification";

const AUTH_API_BASE_URL = '/auth';

const authApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
login: builder.mutation<User, LoginRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/login`,
method: 'POST',
body,
}),
transformResponse: (response: User) => {
return userSchema.parse(response);
},
}),
logout: builder.mutation<void, void>({
query: () => ({
url: `${AUTH_API_BASE_URL}/logout`,
method: 'POST',
}),
}),
refresh: builder.mutation<void, RefreshTokenRequestBody>({
query: (body) => ({
url: 'refresh',
method: 'POST',
body,
}),
}),
forgotPassword: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/forgot-password`,
method: 'POST',
body,
}),
}),
verifyPasswordResetToken: builder.mutation<void, VerifyPasswordResetTokenRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-reset`,
method: 'POST',
body,
}),
}),
sendCode: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/send-code`,
method: 'POST',
body,
}),
}),
verifyEmail: builder.mutation<void, VerifyEmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-email`,
method: 'POST',
body,
}),
}),
}),
});

export const {
useLoginMutation,
useLogoutMutation,
useRefreshMutation,
useForgotPasswordMutation,
useVerifyPasswordResetTokenMutation,
useSendCodeMutation,
useVerifyEmailMutation,
} = authApi;
Loading

0 comments on commit effb765

Please sign in to comment.