Skip to content

Commit 1dead0c

Browse files
author
Duy Nguyen
committed
Add mongo
1 parent 0eb53c3 commit 1dead0c

File tree

9 files changed

+66
-27
lines changed

9 files changed

+66
-27
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ dist/
158158
# Temporary folders
159159
tmp/
160160
temp/
161-
161+
build
162162
### Windows ###
163163
# Windows thumbnail cache files
164164
Thumbs.db

infra/mongo/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3.8"
2+
services:
3+
mongodb:
4+
image : mongo
5+
container_name: mongodb
6+
environment:
7+
- PUID=1000
8+
- PGID=1000
9+
volumes:
10+
- D:\OngDev\mongoData:/data/db
11+
ports:
12+
- 27017:27017
13+
restart: unless-stopped

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "server",
33
"version": "1.0.0",
4-
"main": "server.ts",
4+
"main": "src/server.ts",
55
"license": "MIT",
66
"scripts": {
7-
"start": "nodemon src/server.ts",
8-
"build": "tsc --project src/",
7+
"start": "nodemon -r tsconfig-paths/register src/server.ts ",
8+
"build": "tsc --project .",
99
"lint": "eslint src/**/*.ts",
1010
"format": "eslint src/**/*.ts --fix"
1111
},
@@ -14,6 +14,10 @@
1414
"pre-commit": "yarn lint"
1515
}
1616
},
17+
"_moduleAliases": {
18+
"@": "build",
19+
"@modules": "build/modules*"
20+
},
1721
"dependencies": {
1822
"axios": "^0.21.1",
1923
"cors": "^2.8.5",
@@ -38,6 +42,7 @@
3842
"nodemon": "^2.0.7",
3943
"prettier": "^2.3.0",
4044
"ts-node": "^9.1.1",
45+
"tsconfig-paths": "^3.9.0",
4146
"typescript": "^4.2.4"
4247
}
4348
}

src/middlewares/query.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { TMiddleware } from "monk"
22
import log from "@/logger"
33

44
export const logger: TMiddleware = context => next => (args, method) => {
5-
log.info(method, args)
65
return next(args, method).then((res) => {
76
log.info(method + ' result', res)
87
return res

src/modules/youtube-chat/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { messageModel, authorModel } from "./model"
44
import { YoutubeConfig } from '@/env';
55
import io from '@/server';
66
import { AuthorDetails, MessageDetails, MessageType, MessageTypeEnum, YoutubeLiveMessageListResponse, YoutubeLiveMessageType, YoutubeMessageFetchPagination } from './types';
7-
import { getCurrentLivechatId } from './helpers.js';
7+
import { getCurrentLivechatId } from './helpers';
88

99
const { API_KEY, MESSAGE_API_URL } = YoutubeConfig;
1010
let isFetchingMessages = false;

src/routers/v1ApiRouters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Router } from "express";
2-
import YoutubeChatRouter from "@modules/youtube-chat/routers"
2+
import YoutubeChatRouter from "../modules/youtube-chat/routers"
33

44
const v1ApiRouter = Router();
55

6-
v1ApiRouter.get("/", (_req: any, res: any) => {
7-
res.setStatus(200).json({
6+
v1ApiRouter.get("/", (req: any, res: any) => {
7+
res.status(200).json({
88
success: "true",
99
data: "Api v1",
1010
});

src/server.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import cors from 'cors';
55
import { createServer } from "http";
66
import { Server } from "socket.io";
77
import v1ApiRouter from "./routers/v1ApiRouters"
8-
//import 'module-alias/register';
9-
// "_moduleAliases": {
10-
// "@": "build",
11-
// "@modules": "build/modules*"
12-
// },
13-
14-
8+
import 'module-alias/register';
159

1610
import { PORT } from './env';
1711

tsconfig.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "commonjs",
5-
"rootDir": "./",
63
"outDir": "./build",
74
"esModuleInterop": true,
8-
"strict": true,
9-
"sourceMap": true,
105
"baseUrl": ".",
116
"paths": {
12-
"@/*": ["./src/*"],
13-
"@modules/*": ["./src/modules/*"],
14-
"@routers/*": ["./src/routers/*"],
15-
"@middlewares/*": ["./src/middlewares/*"]
16-
}
17-
}
7+
"@/*": ["src/*"],
8+
"@modules/*": ["src/modules/*"],
9+
"@routers/*": ["src/routers/*"],
10+
"@middlewares/*": ["src/middlewares/*"]
11+
},
12+
},
13+
"exclude": [
14+
"node_modules"
15+
],
16+
"include": [
17+
"src/**/*.ts"
18+
],
1819
}

yarn.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@
132132
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
133133
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
134134

135+
"@types/json5@^0.0.29":
136+
version "0.0.29"
137+
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
138+
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
139+
135140
"@types/mime@^1":
136141
version "1.3.2"
137142
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
@@ -1400,6 +1405,13 @@ json-stable-stringify-without-jsonify@^1.0.1:
14001405
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
14011406
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
14021407

1408+
json5@^1.0.1:
1409+
version "1.0.1"
1410+
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
1411+
integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==
1412+
dependencies:
1413+
minimist "^1.2.0"
1414+
14031415
keyv@^3.0.0:
14041416
version "3.1.0"
14051417
resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9"
@@ -2146,6 +2158,11 @@ strip-ansi@^6.0.0:
21462158
dependencies:
21472159
ansi-regex "^5.0.0"
21482160

2161+
strip-bom@^3.0.0:
2162+
version "3.0.0"
2163+
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
2164+
integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=
2165+
21492166
strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
21502167
version "3.1.1"
21512168
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
@@ -2228,6 +2245,16 @@ ts-node@^9.1.1:
22282245
source-map-support "^0.5.17"
22292246
yn "3.1.1"
22302247

2248+
tsconfig-paths@^3.9.0:
2249+
version "3.9.0"
2250+
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b"
2251+
integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==
2252+
dependencies:
2253+
"@types/json5" "^0.0.29"
2254+
json5 "^1.0.1"
2255+
minimist "^1.2.0"
2256+
strip-bom "^3.0.0"
2257+
22312258
tslib@^1.8.1:
22322259
version "1.14.1"
22332260
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

0 commit comments

Comments
 (0)