Skip to content
Open
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
20,147 changes: 0 additions & 20,147 deletions .pnp.cjs

This file was deleted.

2,076 changes: 0 additions & 2,076 deletions .pnp.loader.mjs

This file was deleted.

11 changes: 8 additions & 3 deletions app/daehwahap-app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
printWidth: 100,
tabWidth: 2,
singleQuote: true,
trailingComma: 'all',
semi: false,
useTabs: false,
arrowParens: 'always',
endOfLine: 'auto',
bracketSpacing: true,
bracketLine: true,
};
118 changes: 0 additions & 118 deletions app/daehwahap-app/App.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/daehwahap-app/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'react-native';
import React from 'react';
import App from '../App';
import App from '../src/screens/App';

// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals';
Expand Down
8 changes: 4 additions & 4 deletions app/daehwahap-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @format
*/

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import { AppRegistry } from 'react-native'
import { name as appName } from './app.json'
import App from './src/screens/App'

AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent(appName, () => App)
2 changes: 1 addition & 1 deletion app/daehwahap-app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ SPEC CHECKSUMS:
React-utils: d16c1d2251c088ad817996621947d0ac8167b46c
ReactCommon: 2aa35648354bd4c4665b9a5084a7d37097b89c10
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: d17d2cc8105eed528474683b42e2ea310e1daf61
Yoga: 805bf71192903b20fc14babe48080582fee65a80

PODFILE CHECKSUM: 44bdfeef7d9d62a62fdb49baead142801fc2eef7

Expand Down
2 changes: 2 additions & 0 deletions app/daehwahap-app/ios/daehwahapapp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2A2Q849C26;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = daehwahapapp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -493,6 +494,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2A2Q849C26;
INFOPLIST_FILE = daehwahapapp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
3 changes: 3 additions & 0 deletions app/daehwahap-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"test": "jest"
},
"dependencies": {
"@daehwahap/daehwahap-server": "workspace:^",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"react": "18.2.0",
"react-native": "0.73.6"
},
Expand Down
22 changes: 22 additions & 0 deletions app/daehwahap-app/src/screens/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { Button, Text, View } from 'react-native'
import { trpc } from '../trpc'

function App(): React.JSX.Element {
const handle회원가입Press = async () => {
await trpc.createUser.mutate({ email: 'aa', password: 'aa', name: '최봉수' })
}

return (
<View style={{ flex: 1, paddingVertical: 40 }}>
<View style={{ backgroundColor: 'white' }}>
<Button title="회원가입" color="blue" onPress={handle회원가입Press} />
</View>
<View>
<Text>aaaaaaaaaaaaa </Text>
</View>
</View>
)
}

export default App
10 changes: 10 additions & 0 deletions app/daehwahap-app/src/trpc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AppRouter } from '@daehwahap/daehwahap-server/src/trpc/trpc.router'
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client'

export const trpc = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:8080/trpc', // you should update this to use env variables
}),
],
})
10 changes: 10 additions & 0 deletions app/daehwahap-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ __metadata:
"@react-native/eslint-config": "npm:0.73.2"
"@react-native/metro-config": "npm:0.73.5"
"@react-native/typescript-config": "npm:0.73.1"
"@trpc/client": "npm:^10.45.2"
"@types/react": "npm:^18.2.6"
"@types/react-test-renderer": "npm:^18.0.0"
babel-jest: "npm:^29.6.3"
Expand Down Expand Up @@ -2619,6 +2620,15 @@ __metadata:
languageName: node
linkType: hard

"@trpc/client@npm:^10.45.2":
version: 10.45.2
resolution: "@trpc/client@npm:10.45.2"
peerDependencies:
"@trpc/server": 10.45.2
checksum: 10c0/15c277a35f15108346902507c7f04fdcdf008d7fd8232f28806518af555ce72273a06d024b727494684c9d8752949b3e334437f321a7f3228be6411511b553f0
languageName: node
linkType: hard

"@types/babel__core@npm:^7.1.14":
version: 7.20.5
resolution: "@types/babel__core@npm:7.20.5"
Expand Down
6 changes: 3 additions & 3 deletions server/daehwahap-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:dev": "prisma generate && nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"start:prod": "prisma generate && node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand All @@ -25,6 +25,7 @@
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@prisma/client": "^5.12.1",
"@trpc/server": "^10.45.2",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
Expand All @@ -36,7 +37,6 @@
"@nestjs/mapped-types": "*",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@prisma/client": "^5.12.1",
"@types/eslint": "^8",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
Expand Down
3 changes: 1 addition & 2 deletions server/daehwahap-server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

generator client {
provider = "prisma-client-js"
previewFeactures = ["relationMode"]
}

datasource db {
Expand All @@ -17,7 +16,7 @@ datasource db {

generator zod {
provider = "zod-prisma-types"
output = "./dto/zod"
output = "../src/prisma/dto"
}

model User {
Expand Down
17 changes: 11 additions & 6 deletions server/daehwahap-server/src/trpc/trpc.router.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import { UserController } from './user/user.controller'
import { INestApplication, Injectable } from '@nestjs/common'
import { TrpcService } from './trpc.service'
import * as trpcExpress from '@trpc/server/adapters/express'
import { NodeHTTPHandlerOptions } from '@trpc/server/dist/adapters/node-http'
import express from 'express'
import { AnyRouter } from '@trpc/server'
import { TrpcService } from './trpc.service'

@Injectable()
export class TrpcRouter {
constructor(
private readonly trpcService: TrpcService,
private readonly userController: UserController,
) {}
private readonly trpcService: TrpcService,
) {
this.mergeRouter = this.trpcService.mergeRouters(this.userController.router)
}

mergeRouter = this.trpcService.mergeRouters(this.userController.router)
mergeRouter

async applyMiddleware(app: INestApplication) {
app.use(
`/trpc`,
trpcExpress.createExpressMiddleware({
router: this.mergeRouter,
}),
} as NodeHTTPHandlerOptions<AnyRouter, express.Request, express.Response>),
)
}
}

export type AppRouter = TrpcRouter[`mergeRouter`]
export type AppRouter = TrpcRouter['mergeRouter']
18 changes: 0 additions & 18 deletions server/daehwahap-server/src/trpc/trpc.service.spec.ts

This file was deleted.

30 changes: 28 additions & 2 deletions server/daehwahap-server/src/trpc/trpc.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
import { Injectable } from '@nestjs/common'
import { initTRPC } from '@trpc/server'
import { TRPCError, initTRPC } from '@trpc/server'
import * as trpcNext from '@trpc/server/adapters/next'
import { FetchCreateContextFnOptions } from '@trpc/server/adapters/fetch'

// Create your context based on the request object
// Will be available as `ctx` in all your resolvers
// This is just an example of something you might want to do in your ctx fn

@Injectable()
export class TrpcService {
trpc = initTRPC.create()
private createContext = async ({ req }: FetchCreateContextFnOptions) => {
if (!req.headers.get('authenticate')) {
throw new TRPCError({ code: 'UNAUTHORIZED' })
}
// 여기서 디코딩하고 유저 받아주는 로직
console.log(req)
const user = { userId: 'aa' }
return user
}

trpc = initTRPC.context<typeof this.createContext>().create()
auth = this.trpc.middleware(async ({ next, ctx }) => {
console.log(ctx)
// if (!ctx.userId) {
// throw new TRPCError({ code: 'UNAUTHORIZED' })
// }
return next({ ctx })
})

procedure = this.trpc.procedure
authProcedure = this.procedure.use(this.auth)

router = this.trpc.router
mergeRouters = this.trpc.mergeRouters
}
Loading