Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Merge branch 'feat/lectures' (#7)
Browse files Browse the repository at this point in the history
- downgrate vite version (postcss bug vitejs/vite#7717)
  • Loading branch information
DiD3n committed Apr 13, 2022
2 parents 88f1fb4 + 4816067 commit 8702a44
Show file tree
Hide file tree
Showing 100 changed files with 10,709 additions and 15,201 deletions.
24,195 changes: 9,353 additions & 14,842 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Expand Up @@ -67,8 +67,9 @@
"^.+\\.tsx?$": "ts-jest"
},
"globals": {
"__API_URL__": "http://localhost/",
"__DEV__": true
"__RESTAPI_URI__": "'http://localhost:8080'",
"__GRAPHQL_URI__": "'http://localhost:8080'",
"__DEV__": false
},
"moduleNameMapper": {
"\\.s?[ca]ss$": "<rootDir>/src/__mocks__/css.ts",
Expand Down Expand Up @@ -102,10 +103,12 @@
"typescript": "^4.4.3"
},
"dependencies": {
"@vitejs/plugin-react": "^1.2.0",
"@apollo/client": "^3.5.10",
"@vitejs/plugin-react": "^1.3.1",
"express": "^4.17.1",
"express-history-api-fallback": "^2.2.1",
"vite": "^2.8.4",
"graphql": "^16.3.0",
"vite": "^2.9.1",
"vite-plugin-svgr-component": "^1.0.0"
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions src/components/App.tsx → src/App.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { AuthContextProvider } from '../common/auth/AuthContext';
import { AppRouter } from '../views/AppRouter';
import { AuthContextProvider } from './contexts/auth/AuthContext';
import { AppRouter } from './views/AppRouter';

export const App: React.FC = () => {

Expand Down
38 changes: 38 additions & 0 deletions src/api/graphql/events/EventDataQuery.ts
@@ -0,0 +1,38 @@
import {gql} from "@apollo/client";

export const GET_EVENT_QUERY = gql`
query getEvent($id: String!) {
event(id: $id) {
id
title
subtitle
author {
nickname
}
timeFrame {
startDate
}
theme {
primaryColor
image
}
}
}
`;

export interface EventData {
id: string
title: string
subtitle: string
author: {
id: string
nickname: string
}
timeFrame: {
startDate: string
}
theme: {
primaryColor: string
image: string
}
}
31 changes: 31 additions & 0 deletions src/api/graphql/events/EventListQuery.ts
@@ -0,0 +1,31 @@
import {gql} from "@apollo/client";
import {EventData} from "./EventDataQuery";

export const GET_EVENTS_LIST_QUERY = gql`
query getEventsList($page: Int, $size: Int) {
events(page: $page, size: $size) {
id
title
subtitle
author {
nickname
}
timeFrame {
startDate
}
theme {
primaryColor
image
}
}
}
`;

export interface EventListQueryVars {
page: number,
size: number,
}

export interface EventListQueryData {
events: EventData[]
}
172 changes: 172 additions & 0 deletions src/api/graphql/schema.graphql
@@ -0,0 +1,172 @@
input AddressRequestInput {
city: String!
coordinates: CoordinatesRequestInput
place: String!
}

type AddressResponse {
city: String!
coordinates: CoordinatesResponse
place: String!
}

input ContactRequestInput {
github: String
linkedin: String
mail: String
twitter: String
}

type ContactResponse {
github: String
linkedin: String
mail: String
twitter: String
}

input CoordinatesRequestInput {
latitude: Float!
longitude: Float!
}

type CoordinatesResponse {
latitude: Float!
longitude: Float!
}

input EventRequestInput {
address: AddressRequestInput
subtitle: String
tags: [TagRequestInput!]!
timeFrame: TimeFrameRequestInput!
title: String!
}

type EventResponse {
address: AddressResponse
authorId: String!
createDate: Instant!
id: String!
subtitle: String
tags: [TagResponse!]!
theme: ThemeResponse!
timeFrame: TimeFrameResponse!
title: String!
updateDate: Instant!

# Event creator
author: UserResponse!

# Is event followed by current user
isFollowed: Boolean!
}

input EventThemeRequestInput {
primaryColor: String
secondaryColor: String
}

# ISO date-time
scalar Instant

type Mutation {
# Creates tag
createTag(request: TagCreateRequestInput!): TagResponse!

# Appends new tags to followed list
followTags(request: [TagRequestInput!]!): [TagResponse!]!

# Removes tags from followed list
unfollowTags(request: [TagRequestInput!]!): Boolean!

# Create event with request
createEvent(request: EventRequestInput!): EventResponse!

# Delete event by id
deleteEvent(id: String!): Boolean!

# Follow event by id
followEvent(id: String!): Boolean!

# Replace event data with new data (PUT equivalent)
replaceEvent(id: String!, request: EventRequestInput!): EventResponse!

# Replace event theme with new one (PUT equivalent)
replaceEventTheme(
id: String!
request: EventThemeRequestInput!
): EventResponse!

# Unfollow event by id
unfollowEvent(id: String!): Boolean!

# Replace user data with new data (PUT equivalent)
replaceMyUser(request: UserRequestInput!): UserResponse!
}

type Query {
# Get tags followed by user (paged)
followedTags(page: Int, size: Int): [TagResponse!]!

# Get tag by id
tag(id: String!): TagResponse

# Get all tags paged
tags(page: Int, size: Int): [TagResponse!]!

# Get single event by its id
event(id: String!): EventResponse

# Get all events paged
events(page: Int, size: Int): [EventResponse!]!

# Get user by id
user(id: String!): UserResponse

# Get all users paged
users(page: Int, size: Int): [UserResponse!]!
}

input TagCreateRequestInput {
name: String!
}

input TagRequestInput {
id: String!
}

type TagResponse {
id: String!
name: String!
}

type ThemeResponse {
image: String
primaryColor: String
secondaryColor: String
}

input TimeFrameRequestInput {
finishDate: Instant
startDate: Instant!
}

type TimeFrameResponse {
finishDate: Instant
startDate: Instant!
}

input UserRequestInput {
contact: ContactRequestInput!
description: String
nickname: String!
}

type UserResponse {
contact: ContactResponse!
createDate: Instant!
description: String
id: String!
nickname: String!
updateDate: Instant!
}
@@ -1,5 +1,5 @@
import { AxiosInstance } from 'axios';
import { AuthResponse } from './authResponse.interface';
import { AuthResponse } from './AuthResponse.interface';

export const authByProvidersToken = async (axios: AxiosInstance, provider: string, token: string, state?: string): Promise<AuthResponse> =>
axios.get<AuthResponse>(`/oauth/callback/${provider}`, {
Expand Down
18 changes: 18 additions & 0 deletions src/api/rest/auth/AuthResponse.interface.ts
@@ -0,0 +1,18 @@
import {UserResponse} from "../user/UserResponse.interface";

export interface AuthResponse {
username: string

roles: string[]

accessToken: string
refreshToken: string
tokenType: string
expiresIn: number

user: UserResponse

properties: {
isInitialized: boolean
}
}
@@ -1,11 +1,11 @@

export interface JwtData {
export interface DecodedJwt {
id: string;
nickname: string;

exp: number; // expire
iat: number;
iss: string; // service name
iss: string; // api name
roles: string[],
sub: string;
}
@@ -1,7 +1,7 @@

enum ProvidersList {
enum Provider {
github = 'github',
githubDev = 'devgithub'
}

export default ProvidersList;
export default Provider;
10 changes: 10 additions & 0 deletions src/api/rest/user/User.ts
@@ -0,0 +1,10 @@
import {AxiosInstance} from "axios";
import {UserResponse} from "./UserResponse.interface";

export const getMe = (axios: AxiosInstance): Promise<UserResponse> =>
axios.get<UserResponse>('/api/v1/users/@me')
.then(res => res.data);

export const getById = (axios: AxiosInstance, id: string): Promise<UserResponse> =>
axios.get<UserResponse>(`/api/v1/users/${id}`)
.then(res => res.data);
14 changes: 14 additions & 0 deletions src/api/rest/user/UserResponse.interface.ts
@@ -0,0 +1,14 @@

export interface UserResponse {
id: string
nickname: string
description?: string
contact: {
github?: string
linkedin?: string
mail?: string
twitter?: string
}
createDate: string
updateDate: string
}
14 changes: 14 additions & 0 deletions src/assets/brand/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8702a44

Please sign in to comment.