Skip to content

Commit

Permalink
Merge pull request #404 from sparcs-kaist/feat/fix-monorepo-struct
Browse files Browse the repository at this point in the history
Fix monorepo structure
  • Loading branch information
SnowSuno authored Oct 3, 2023
2 parents b89f9b6 + c7b080a commit 741c833
Show file tree
Hide file tree
Showing 241 changed files with 527 additions and 519 deletions.
32 changes: 32 additions & 0 deletions .docker/api.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:18-alpine as builder

WORKDIR /app

RUN npm install -g [email protected]

COPY pnpm-lock.yaml .
RUN pnpm fetch


COPY . .
RUN pnpm --filter @biseo/api... install --offline

RUN pnpm --filter @biseo/api... build
#RUN pnpm --filter @biseo/api --prod deploy pruned
#
#FROM node:18-alpine
#
#WORKDIR /app
#
#COPY --from=builder /app/pruned .
#
#EXPOSE 8000
#
#CMD ["npm", "run", "prod"]

EXPOSE 8000

CMD ["pnpm", "--filter", "@biseo/api", "prod"]



27 changes: 0 additions & 27 deletions .docker/client.Dockerfile

This file was deleted.

29 changes: 0 additions & 29 deletions .docker/server.Dockerfile

This file was deleted.

20 changes: 20 additions & 0 deletions .docker/web.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-alpine as builder

WORKDIR /app

RUN npm install -g [email protected]

COPY pnpm-lock.yaml .
RUN pnpm fetch

COPY . .
RUN pnpm --filter @biseo/web... install --offline
RUN pnpm --filter @biseo/web... build

FROM nginx:1.22-alpine

COPY nginx.conf /etc/nginx/templates/default.conf.template

COPY --from=builder /app/packages/web/dist /usr/share/nginx/html

EXPOSE 80
17 changes: 15 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ecmaFeatures": {
"jsx": true
},
"project": ["./*/tsconfig.json"]
"project": ["./packages/*/tsconfig.json", "./tsconfig.json"]
},
"plugins": ["import", "@typescript-eslint", "react"],
"ignorePatterns": ["node_modules/", "dist/"],
Expand All @@ -46,7 +46,12 @@
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": ["./server/", "./client/", "./interface/"]
"packageDir": [
"./packages/web",
"./packages/api",
"./packages/interface",
"."
]
}
],
"import/prefer-default-export": "off",
Expand Down Expand Up @@ -110,6 +115,14 @@
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"project": ["./tsconfig.json"]
}
},
"react": {
"version": "18.2.0"
}
}
}
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pnpm-lock.yaml
pnpm-lock.yaml
**/dist
12 changes: 0 additions & 12 deletions client/.eslintrc

This file was deleted.

16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ version: "3.4"
name: "biseo"

services:
client:
container_name: biseo-client
web:
container_name: biseo-web
restart: always
build:
context: .
dockerfile: .docker/client.Dockerfile
dockerfile: .docker/web.Dockerfile
ports:
- "${EXPOSE_PORT:?}:80"
environment:
- SERVER_URI="http://server:8000"
- SERVER_URI="http://api:8000"
depends_on:
- server
- api
networks:
- frontend
server:
container_name: biseo-server
api:
container_name: biseo-api
restart: always
environment:
- NODE_ENV=production
Expand All @@ -26,7 +26,7 @@ services:
- SECRET_KEY=${SECRET_KEY:?}
build:
context: .
dockerfile: .docker/server.Dockerfile
dockerfile: .docker/api.Dockerfile
depends_on:
- db
networks:
Expand Down
12 changes: 0 additions & 12 deletions interface/.eslintrc

This file was deleted.

18 changes: 0 additions & 18 deletions interface/package.json

This file was deleted.

16 changes: 0 additions & 16 deletions interface/tsconfig.json

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"scripts": {
"prepare": "husky install",
"postinstall": "pnpm typegen",
"web": "pnpm -F @biseo/client",
"api": "dotenv -- pnpm -F @biseo/server",
"web": "pnpm -F @biseo/web",
"api": "dotenv -- pnpm -F @biseo/api",
"interface": "pnpm -F @biseo/interface",
"dev": "dotenv -- pnpm -r --stream dev",
"db": "dotenv -- pnpm -F @biseo/server db",
"migrate": "dotenv -- pnpm -F @biseo/server migrate",
"typegen": "dotenv -- pnpm -F @biseo/server typegen",
"studio": "dotenv -- pnpm -F @biseo/server studio",
"db": "dotenv -- pnpm -F @biseo/api db",
"migrate": "dotenv -- pnpm -F @biseo/api migrate",
"typegen": "pnpm -F @biseo/api typegen",
"studio": "dotenv -- pnpm -F @biseo/api studio",
"typecheck": "pnpm -r typecheck",
"lint": "pnpm eslint . && pnpm prettier --config ./.prettierrc --check -u .",
"build": "pnpm -r build"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 9 additions & 4 deletions server/package.json → packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
{
"name": "@biseo/server",
"name": "@biseo/api",
"version": "2.0.0",
"main": "src/index.ts",
"license": "MIT",
"scripts": {
"dev": "pnpm migrate && nodemon",
"prod": "prisma migrate deploy && node dist/server/src/index.js",
"prod": "prisma migrate deploy && node dist/index.js",
"db": "docker compose -f docker-compose.dev.yml",
"typecheck": "prisma generate && tsc --noEmit",
"typegen": "prisma generate",
"migrate": "pnpm db up -d && prisma migrate dev",
"studio": "pnpm db up -d && prisma studio",
"build": "prisma generate && tsc && tsc-alias",
"build": "prisma generate && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"env": "echo $NODE_ENV"
},
"files": [
"dist",
"prisma"
],
"dependencies": {
"@biseo/interface": "workspace:*",
"@prisma/client": "^4.9.0",
"@socket.io/component-emitter": "^3.1.0",
"cors": "^2.8.5",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.0",
"ldapts": "^4.2.6",
"prisma": "^4.16.2",
"socket.io": "^4.5.4",
"winston": "^3.10.0",
"winston-daily-rotate-file": "^4.7.1",
Expand All @@ -32,7 +38,6 @@
"@types/jsonwebtoken": "^9.0.2",
"@types/node": "^18.11.18",
"nodemon": "^2.0.20",
"prisma": "^4.9.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"tsconfig-paths": "^4.1.2"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import type { Request, Response } from "express";

import { prisma } from "@/db/prisma";
import { prisma } from "@biseo/api/db/prisma";

import { authenticate } from "./ldap";
import { getToken } from "./token";
Expand Down
File renamed without changes.
10 changes: 3 additions & 7 deletions server/src/auth/socket.ts → packages/api/src/auth/socket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ExtendedError } from "socket.io/dist/namespace";
import type { BiseoSocket } from "@/types/socket";
import { getUserFromToken } from "@/auth/token";
import type { BiseoSocket } from "@biseo/api/types/socket";
import { getUserFromToken } from "@biseo/api/auth/token";

const handler = async (socket: BiseoSocket) => {
const user = await getUserFromToken(socket.handshake.auth.token);
Expand All @@ -13,10 +12,7 @@ const handler = async (socket: BiseoSocket) => {
return socket.emit("init", user);
};

export const auth = (
socket: BiseoSocket,
next: (err?: ExtendedError) => void,
) => {
export const auth = (socket: BiseoSocket, next: (err?: Error) => void) => {
handler(socket)
.then(() => next())
.catch(e => {
Expand Down
4 changes: 2 additions & 2 deletions server/src/auth/token.ts → packages/api/src/auth/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import jwt from "jsonwebtoken";
import { z } from "zod";
import type { User } from "@prisma/client";

import { prisma } from "@/db/prisma";
import { env } from "@/env";
import { prisma } from "@biseo/api/db/prisma";
import { env } from "@biseo/api/env";

const MAX_AGE = 60 * 60 * 24 * 7; // 1 week
export const getToken = (username: string) =>
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions server/src/index.ts → packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import express from "express";
import { Server } from "socket.io";
import cors from "cors";

import type { BiseoServer } from "@/types/socket";
import { authRouter } from "@/auth/router";
import { env } from "@/env";
import logger from "@/utils/logger";

import { auth } from "@/auth/socket";

import { adminAgendaRouter } from "@/listener/admin.agenda";
import { adminUserRouter } from "@/listener/admin.user";
import { chatRouter } from "@/listener/chat";
import { agendaRouter } from "@/listener/agenda";
import { agendaTemplateRouter } from "@/listener/agenda.template";
import { userTagRouter } from "@/listener/user.tag";
import type { BiseoServer } from "@biseo/api/types/socket";
import { authRouter } from "@biseo/api/auth/router";
import { env } from "@biseo/api/env";
import logger from "@biseo/api/utils/logger";

import { auth } from "@biseo/api/auth/socket";

import { adminAgendaRouter } from "@biseo/api/listener/admin.agenda";
import { adminUserRouter } from "@biseo/api/listener/admin.user";
import { chatRouter } from "@biseo/api/listener/chat";
import { agendaRouter } from "@biseo/api/listener/agenda";
import { agendaTemplateRouter } from "@biseo/api/listener/agenda.template";
import { userTagRouter } from "@biseo/api/listener/user.tag";

const app = express();
const httpServer = createServer(app);
Expand Down
Loading

0 comments on commit 741c833

Please sign in to comment.