Skip to content
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

merge(develop): refactored folder structure, mobx logic #13

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ module.exports = configure({
"import/extensions": "off",
"react-hooks/exhaustive-deps": "warn",
"react/no-array-index-key": "warn",
"@typescript-eslint/no-explicit-any": "warn"
"@typescript-eslint/no-explicit-any": "warn",
"dot-notation": "off"
}
}
})
8 changes: 8 additions & 0 deletions _templates/fsd-module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This generator creates a module using the
[Feature-Sliced-Design](https://feature-sliced.design/ru/docs/get-started/overview) methodology.

### Methods

---

- new (General case)
3 changes: 3 additions & 0 deletions _templates/fsd-module/new/hooks/index.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
to: <%= module_name %>/hooks/index.ts
---
4 changes: 4 additions & 0 deletions _templates/fsd-module/new/index.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
to: <%= module_name %>/index.ts
---
export { <%= module_name.charAt(0).toUpperCase() + module_name.slice(1) %> } from './ui/<%= module_name %>'
3 changes: 3 additions & 0 deletions _templates/fsd-module/new/lib/index.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
to: <%= module_name %>/lib/index.ts
---
7 changes: 7 additions & 0 deletions _templates/fsd-module/new/prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = [
{
type: 'input',
name: 'module_name',
message: "Module name:"
}
]
4 changes: 4 additions & 0 deletions _templates/fsd-module/new/store/gitkeep.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
to: <%= module_name %>/store/.gitkeep
---

12 changes: 12 additions & 0 deletions _templates/fsd-module/new/ui/component.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
to: <%= module_name %>/ui/<%= module_name %>.tsx
---

interface <%= module_name.charAt(0).toUpperCase() + module_name.slice(1) %>Props {

}

export const <%= module_name.charAt(0).toUpperCase() + module_name.slice(1) %> = () => {
return null
}

8 changes: 8 additions & 0 deletions _templates/fsd-module/new/ui/component.styles.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
to: <%= module_name %>/ui/<%= module_name %>.styles.ts
---
import styled from 'styled-components'

export const <%= module_name.charAt(0).toUpperCase() + module_name.slice(1) %>Styles = styled.div`

`
4 changes: 2 additions & 2 deletions apps/client/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" type="image/ico" href="/favicon.svg" />
<link rel="manifest" href="/manifest.json">
<link rel="manifest" href="/manifest.json" />
<title>CodeGear</title>
</head>
<body>
Expand Down
7 changes: 6 additions & 1 deletion apps/client/src/app/providers/router/config/router.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Suspense } from 'react'
import { createBrowserRouter } from 'react-router-dom'

import { About } from '@/pages/about'
Expand All @@ -14,7 +15,11 @@ const router = createBrowserRouter([
},
{
path: RoutePaths.EDITOR,
element: <Editor />
element: (
<Suspense fallback={null}>
<Editor />
</Suspense>
)
},
{
path: RoutePaths.ABOUT,
Expand Down
2 changes: 1 addition & 1 deletion apps/client/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"$/styles": ["../../libs/client-shared/src/styles/index.ts"],
"$/editor": ["../../libs/editor/src/app/index.ts"],
"react": ["../../node_modules/preact/compat"],
"react-dom": ["../../node_modules/preact/compat"],
"react-dom": ["../../node_modules/preact/compat"]
}
},
"exclude": [
Expand Down
13 changes: 13 additions & 0 deletions apps/server/src/config/swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DocumentBuilder, OpenAPIObject, SwaggerModule } from '@nestjs/swagger'

import { serverAppName } from '$/config'

export const createSwaggerDocs = (app): OpenAPIObject => {
const swagger = new DocumentBuilder()
.setTitle(serverAppName)
.setDescription('REST API documentation')
.setVersion('1.0.0')
.build()

return SwaggerModule.createDocument(app, swagger)
}
6 changes: 5 additions & 1 deletion apps/server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { corsConfig } from '@/config/cors'
import { createSwaggerDocs } from '@/config/swagger'
import { HttpExceptionFilter } from '@/exception-filters'
import { ValidationPipe } from '@/pipes/validation.pipe'
import { Logger } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { SwaggerModule } from '@nestjs/swagger'

import { AppModule } from './app.module'

import { serverPort, serverPrefix } from '$/config'
import { serverDocsPrefix, serverPort, serverPrefix } from '$/config'

async function bootstrap() {
const app = await NestFactory.create(AppModule)
Expand All @@ -16,6 +18,8 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe())
app.enableCors(corsConfig)

SwaggerModule.setup(serverDocsPrefix, app, createSwaggerDocs(app))

Logger.log(`🚀 Server is running on port ${serverPort}`)
await app.listen(serverPort)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BadRequestException, Body, Controller, Post } from '@nestjs/common'
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'

import { EndPoints } from '$/config'
import {
Expand All @@ -9,9 +10,12 @@ import {
isExecutorApiResponse
} from '$/services'

@ApiTags('Code executor API')
@Controller(EndPoints.CODE_EXECUTOR_API)
export class CodeExecutorController {
constructor(private executorService: ExecutorApiService) {}
@ApiOperation({ summary: 'Execute your code' })
@ApiResponse({ status: 200 })
@Post()
async executeCode(
@Body() args: ExecuteCodeApiDTO
Expand Down
4 changes: 2 additions & 2 deletions apps/server/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"baseUrl": ".",
"paths": {
"$/config": ["../../libs/config/src/index.ts"],
"$/services": ["../../libs/services/src/index.ts"],
"@/*": ["src/*"],
"$/services": ["../../libs/nest-services/src/index.ts"],
"@/*": ["src/*"]
}
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
Expand Down
4 changes: 2 additions & 2 deletions libs/client-shared/src/hooks/use-alt-key-down.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { EventHandler, KeyboardEvent, useState } from 'react'

import { Nullable } from '../types'
import { Nullable } from '@/types'

type Handlers = Record<string, Nullable<() => void>>

export const useAltKeyDown = () => {
const [subscribers, setSubscribers] = useState<EventHandler<any>[]>([])

Check warning on line 8 in libs/client-shared/src/hooks/use-alt-key-down.ts

View workflow job for this annotation

GitHub Actions / Linting project

Unexpected any. Specify a different type

Check warning on line 8 in libs/client-shared/src/hooks/use-alt-key-down.ts

View workflow job for this annotation

GitHub Actions / Linting project

Unexpected any. Specify a different type
return {
on: (handlers: Handlers) => {
Object.entries(handlers).forEach(([key, handler]) => {
const subscriber = (e: KeyboardEvent) => {
if (e.altKey && e.key === key.toLowerCase()) {
e.preventDefault()
handler()
handler?.()
return false
}
}
setSubscribers([...subscribers, subscriber])
document.addEventListener('keydown', subscriber as EventHandler<any>)

Check warning on line 20 in libs/client-shared/src/hooks/use-alt-key-down.ts

View workflow job for this annotation

GitHub Actions / Linting project

Unexpected any. Specify a different type

Check warning on line 20 in libs/client-shared/src/hooks/use-alt-key-down.ts

View workflow job for this annotation

GitHub Actions / Linting project

Unexpected any. Specify a different type
})
},
clear: () => {
Expand Down
2 changes: 1 addition & 1 deletion libs/client-shared/src/hooks/use-notifications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from 'react'

import { NotificationsContext } from '../providers'
import { NotificationsContext } from '@/providers'

export const useNotifications = () => {
return useContext(NotificationsContext)
Expand Down
1 change: 1 addition & 0 deletions libs/client-shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './config'
export * from './hooks'
export * from './lib/components'
export * from './lib/helpers'
export * from './lib/icons'
export * from './providers'
export * from './types'
export * from './ui'
7 changes: 7 additions & 0 deletions libs/client-shared/src/lib/components/Display.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { WithChildren } from '@/types'

type DisplayProps<T> = WithChildren<{ when: T }>

export const Display = <T>({ when, children }: DisplayProps<T>) => {
return when ? children : null
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorBoundary } from '../../../providers'
import { WithChildren } from '../../../types'
import { ErrorBoundary } from '@/providers'
import { WithChildren } from '@/types'

const Page = ({ children }: WithChildren) => {
return <ErrorBoundary>{children}</ErrorBoundary>
Expand Down
7 changes: 0 additions & 7 deletions libs/client-shared/src/lib/components/common.ts

This file was deleted.

6 changes: 3 additions & 3 deletions libs/client-shared/src/lib/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export {
default as AnimationProvider,
useAnimations
} from '../../providers/with-animations/animation-provider'
export { Display } from './common'
export { default as Page } from './page/page'
} from '../../providers/animation-provider'
export { Display } from './Display'
export { default as Page } from './Page'
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext, useContext, useEffect, useMemo, useRef } from 'react'

import { useBooleanState } from '../../hooks'
import { Display } from '../../lib/components'
import { GestureType, SpringType, WithChildren } from '../../types'
import { useBooleanState } from '@/hooks'
import { Display } from '@/lib/components'
import { GestureType, SpringType, WithChildren } from '@/types'

type AnimationContextPayload = Partial<{
Gesture: GestureType
Expand Down Expand Up @@ -33,7 +33,7 @@

useEffect(() => {
loadLibraries()
}, [])

Check warning on line 36 in libs/client-shared/src/providers/animation-provider.tsx

View workflow job for this annotation

GitHub Actions / Linting project

React Hook useEffect has a missing dependency: 'loadLibraries'. Either include it or remove the dependency array

Check warning on line 36 in libs/client-shared/src/providers/animation-provider.tsx

View workflow job for this annotation

GitHub Actions / Linting project

React Hook useEffect has a missing dependency: 'loadLibraries'. Either include it or remove the dependency array

const animationPayload: AnimationContextPayload = useMemo(
() => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useErrorBoundary } from 'preact/hooks'

import { WithPreactChildren } from '../../types'
import { WithPreactChildren } from '@/types'

import ErrorTemplate from './ui/error-template'

Expand All @@ -13,7 +13,7 @@
return <ErrorTemplate errorInfo={error} />
}

return <>{children}</>

Check warning on line 16 in libs/client-shared/src/providers/error-boundary/error-boundary.tsx

View workflow job for this annotation

GitHub Actions / Linting project

Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all

Check warning on line 16 in libs/client-shared/src/providers/error-boundary/error-boundary.tsx

View workflow job for this annotation

GitHub Actions / Linting project

Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all
}

export default ErrorBoundary
4 changes: 2 additions & 2 deletions libs/client-shared/src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { default as AnimationProvider } from './animation-provider'
export { default as ErrorBoundary } from './error-boundary/error-boundary'
export {
NotificationsContext,
default as NotificationsProvider
} from './notifications/ui/notifications-provider'
export { default as AnimationProvider } from './with-animations/animation-provider'
} from './notifications-provider'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext } from 'react'
import { message } from 'antd'

import { WithChildren } from '../../../types'
import { WithChildren } from '@/types'

interface UserMessage {
type?: 'success' | 'info' | 'error'
Expand Down
1 change: 1 addition & 0 deletions libs/client-shared/src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as ColorButton } from './color-button/color-button'
export { Modal } from './modal'
export { Popover } from './popover'
export { Select } from './select/select'
9 changes: 1 addition & 8 deletions libs/client-shared/src/ui/modal/ui/modal.styles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import styled from 'styled-components'

import {
absolute,
color,
customScrollbar,
flex,
shadow,
wh
} from '../../../styles'
import { absolute, color, customScrollbar, flex, shadow, wh } from '@/styles'

export const ModalBackground = styled.div`
${flex('center', 'center')};
Expand Down
8 changes: 2 additions & 6 deletions libs/client-shared/src/ui/modal/ui/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { MouseEvent } from 'react'
import Scrollbar from 'react-smooth-scrollbar'

import { AnimationProvider, Display, useAnimations } from '@/lib/components'
import { WithChildren } from '@/types'
import { Portal } from '@reach/portal'

import {
AnimationProvider,
Display,
useAnimations
} from '../../../lib/components'
import { WithChildren } from '../../../types'
import { useModalTransitions } from '../hooks/use-modal-transitions'

import { ModalBackground, ModalContainer, ModalStyles } from './modal.styles'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAnimations } from '../../../providers/with-animations/animation-provider'
import { VoidFunction } from '../../../types'
import { useAnimations } from '@/providers/animation-provider'
import { VoidFunction } from '@/types'

export const usePopoverAnimation = (
closeCallback: VoidFunction,
Expand Down
2 changes: 1 addition & 1 deletion libs/client-shared/src/ui/popover/ui/popover.styles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components'

import { color, customScrollbar } from '../../../styles'
import { color, customScrollbar } from '@/styles'

interface PopoverStylesProps {
readonly $bottom: number
Expand Down
5 changes: 3 additions & 2 deletions libs/client-shared/src/ui/popover/ui/popover.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect } from 'react'

import { AnimationProvider } from '../../../providers'
import { VoidFunction, WithChildren } from '../../../types'
import { AnimationProvider } from '@/providers'
import { VoidFunction, WithChildren } from '@/types'

import { usePopoverAnimation } from '../hooks'

import { PopoverStyles } from './popover.styles'
Expand All @@ -17,7 +18,7 @@

useEffect(() => {
motion.toggle(isOpen)
}, [isOpen])

Check warning on line 21 in libs/client-shared/src/ui/popover/ui/popover.tsx

View workflow job for this annotation

GitHub Actions / Linting project

React Hook useEffect has a missing dependency: 'motion'. Either include it or remove the dependency array

Check warning on line 21 in libs/client-shared/src/ui/popover/ui/popover.tsx

View workflow job for this annotation

GitHub Actions / Linting project

React Hook useEffect has a missing dependency: 'motion'. Either include it or remove the dependency array

return (
<PopoverStyles
Expand Down
29 changes: 29 additions & 0 deletions libs/client-shared/src/ui/select/select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Select as AntdSelect } from 'antd'

interface SelectProps<T> {
onChange: (val: T) => void
value: T
options: {
value: T
label: string | number
}[]
defaultValue?: T
}

export const Select = <T,>({
onChange,
value,
options,
defaultValue
}: SelectProps<T>) => {
return (
<AntdSelect
size="middle"
onChange={onChange}
value={value}
style={{ width: 200 }}
options={options}
defaultValue={defaultValue}
/>
)
}
3 changes: 2 additions & 1 deletion libs/client-shared/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"types": ["node", "vite/client"],
"baseUrl": ".",
"paths": {
"$/config": ["../config/src/index.ts"]
"$/config": ["../config/src/index.ts"],
"@/*": ["src/*"]
}
},
"files": [
Expand Down
12 changes: 0 additions & 12 deletions libs/config/src/env/server.ts

This file was deleted.

Loading
Loading