Skip to content

Commit 0653c4e

Browse files
Tolerblancsummersummerwhyezcolin2
committed
chore: websocket nest app 추가
Co-authored-by: Summer Min <[email protected]> Co-authored-by: ez <[email protected]>
1 parent a1b000b commit 0653c4e

File tree

7 files changed

+144
-0
lines changed

7 files changed

+144
-0
lines changed

apps/websocket/.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

apps/websocket/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"tabWidth": 2
5+
}

apps/websocket/nest-cli.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src",
5+
"compilerOptions": {
6+
"deleteOutDir": true
7+
}
8+
}

apps/websocket/package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "websocket",
3+
"version": "0.0.1",
4+
"description": "WebSocket server for OctoDocs",
5+
"private": true,
6+
"license": "UNLICENSED",
7+
"scripts": {
8+
"build": "nest build",
9+
"format": "prettier --write \"src/**/*.ts\"",
10+
"start": "nest start",
11+
"dev": "nest start --tsc --watch --preserveWatchOutput --watchAssets",
12+
"start:debug": "nest start --debug --watch",
13+
"start:prod": "node dist/main",
14+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
15+
},
16+
"dependencies": {
17+
"@nestjs/common": "^10.0.0",
18+
"@nestjs/config": "^3.3.0",
19+
"@nestjs/core": "^10.0.0",
20+
"@nestjs/platform-socket.io": "^10.4.8",
21+
"@nestjs/typeorm": "^10.0.2",
22+
"@nestjs/websockets": "^10.4.8",
23+
"axios": "^1.7.8",
24+
"class-transformer": "^0.5.1",
25+
"class-validator": "^0.14.1",
26+
"ioredis": "^5.4.1",
27+
"lib0": "^0.2.98",
28+
"pg": "^8.13.1",
29+
"reflect-metadata": "^0.1.13",
30+
"rxjs": "^7.8.1",
31+
"socket.io": "^4.8.1",
32+
"typeorm": "^0.3.20",
33+
"y-prosemirror": "^1.2.12",
34+
"y-protocols": "^1.0.6",
35+
"y-socket.io": "^1.1.3",
36+
"yjs": "^13.6.8"
37+
},
38+
"devDependencies": {
39+
"@nestjs/cli": "^10.0.0",
40+
"@nestjs/schematics": "^10.0.0",
41+
"@types/node": "^20.3.1",
42+
"@typescript-eslint/eslint-plugin": "^6.0.0",
43+
"@typescript-eslint/parser": "^6.0.0",
44+
"eslint": "^8.42.0",
45+
"eslint-config-prettier": "^9.0.0",
46+
"eslint-plugin-prettier": "^5.0.0",
47+
"prettier": "^3.0.0",
48+
"ts-loader": "^9.4.3",
49+
"ts-node": "^10.9.1",
50+
"tsconfig-paths": "^4.2.0",
51+
"typescript": "^5.1.3"
52+
}
53+
}

apps/websocket/src/app.module.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Module } from '@nestjs/common';
2+
import { ConfigModule } from '@nestjs/config';
3+
import * as path from 'path';
4+
import { YjsModule } from './yjs/yjs.module';
5+
6+
@Module({
7+
imports: [
8+
ConfigModule.forRoot({
9+
isGlobal: true,
10+
envFilePath: path.join(__dirname, '..', '.env'), // * nest 디렉터리 기준
11+
}),
12+
YjsModule,
13+
],
14+
})
15+
export class AppModule {}

apps/websocket/src/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NestFactory } from '@nestjs/core';
2+
import { AppModule } from './app.module';
3+
import { IoAdapter } from '@nestjs/platform-socket.io';
4+
5+
async function bootstrap() {
6+
const app = await NestFactory.create(AppModule);
7+
app.useWebSocketAdapter(new IoAdapter(app));
8+
app.enableCors({
9+
origin:
10+
process.env.NODE_ENV === 'production'
11+
? ['https://octodocs.com', 'https://www.octodocs.com']
12+
: process.env.origin,
13+
credentials: true,
14+
});
15+
await app.listen(4242);
16+
}
17+
bootstrap();

apps/websocket/tsconfig.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"declaration": true,
5+
"removeComments": true,
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"allowSyntheticDefaultImports": true,
9+
"target": "ES2021",
10+
"sourceMap": true,
11+
"outDir": "./dist",
12+
"baseUrl": "./",
13+
"incremental": true,
14+
"skipLibCheck": true,
15+
"strictNullChecks": false,
16+
"noImplicitAny": false,
17+
"strictBindCallApply": false,
18+
"forceConsistentCasingInFileNames": false,
19+
"noFallthroughCasesInSwitch": false
20+
}
21+
}

0 commit comments

Comments
 (0)