Skip to content

Commit

Permalink
Merge pull request #210 from boostcampwm-2021/sprint-5
Browse files Browse the repository at this point in the history
merge to main
  • Loading branch information
ChanHoHan authored Dec 6, 2021
2 parents 4786331 + 37365d8 commit 3663877
Show file tree
Hide file tree
Showing 45 changed files with 24,134 additions and 466 deletions.
20 changes: 0 additions & 20 deletions back-end/api-server/app.js

This file was deleted.

2 changes: 2 additions & 0 deletions back-end/api-server/database/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ export const innerJoinTable = async (
tableB,
on = null,
condition = null,
orderBy = null,
limit = null
) => {
let queryLine = `SELECT ${column} FROM ${tableA} INNER JOIN ${tableB} ON ${on}`;
queryLine += condition ? ` WHERE ${condition}` : ``;
queryLine += orderBy ? ` ORDER BY ${orderBy}` : ``;
queryLine += limit ? ` LIMIT ${limit}` : ``;
return connectionQuery(queryLine);
};
Expand Down
15 changes: 0 additions & 15 deletions back-end/api-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as express from 'express';
import axios from 'axios';
import * as jwt from 'jsonwebtoken';
import { selectTable } from '../database/query';
import { selectTable } from '../../database/query';
import 'dotenv/config';

import { getGithubUser, getUserInfoFromNaver, setJWT } from '../services/auth';
import { getGithubUser, getUserInfoFromNaver, setJWT } from '../../services/auth';

const AuthRouter = express.Router();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
requestFriend,
requestFriendList,
requestFriendUpdate,
} from '../services/friend';
} from '../../services/friend';

const FriendRouter = express.Router();
interface friendReturnFormInterface {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as express from 'express';
import { insertGameInfo, insertPlayerInfo } from '../services/gameRecord';
import { insertGameInfo, insertPlayerInfo } from '../../services/gameRecord';

const GameRecordRouter = express.Router();

Expand Down
19 changes: 19 additions & 0 deletions back-end/api-server/routes/api-routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as express from 'express';
import AuthRouter from './auth';
import InsertDbRegister from './registerDBInsert';
import ProfileRouter from './profile';
import RankingRouter from './rankingSearch';
import FriendRouter from './friend';
import GameRecordRouter from './gameRecord';
import { registerDupCheck } from '../../middlewares/jwt';

const ApiRouter = express.Router();

ApiRouter.use('/auth', AuthRouter);
ApiRouter.use('/rank', RankingRouter);
ApiRouter.use('/register', registerDupCheck, InsertDbRegister);
ApiRouter.use('/profile', ProfileRouter);
ApiRouter.use('/friend', FriendRouter);
ApiRouter.use('/game/record', GameRecordRouter);

export default ApiRouter;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as express from 'express';
import { selectTable, innerJoinTable, updateTable } from '../database/query';
import { setJWT } from './../services/auth';
import { selectTable, innerJoinTable, updateTable } from '../../database/query';
import { setJWT } from '../../services/auth';

const ProfileRouter = express.Router();

Expand All @@ -27,7 +27,6 @@ ProfileRouter.post('/total', async (req, res, next) => {
const data = { ...total[0], ...win[0] };
res.status(200).json(data);
} catch (error) {
console.log(error);
res.status(401).json({ error: '잘못된 인증입니다.' });
}
});
Expand All @@ -39,7 +38,6 @@ ProfileRouter.post('/recent', async (req, res, next) => {
const data = await getRecentInDB(oauth_id, offset, limit);
res.status(200).json(data);
} catch (error) {
console.log(error);
res.status(401).json({ error: '잘못된 인증입니다.' });
}
});
Expand Down Expand Up @@ -100,6 +98,7 @@ const getRecentInDB = (id, offset, limit) => {
'GAME_INFO',
'PLAY.game_id = GAME_INFO.game_id',
`oauth_id='${id}'`,
`game_date DESC`,
`${offset}, ${limit}`
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as express from 'express';
import { selectTable } from '../database/query';
import { selectTable } from '../../database/query';

const RankingRouter = express.Router();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setJWT } from './../services/auth';
import { setJWT } from '../../services/auth';
import * as express from 'express';
import { insertIntoTable } from '../database/query';
import { insertIntoTable } from '../../database/query';

const RegisterRouter = express.Router();

Expand Down
7 changes: 0 additions & 7 deletions back-end/api-server/routes/registerDupCheck.ts

This file was deleted.

21 changes: 2 additions & 19 deletions back-end/api-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ const cors = require('cors');
const cookieParser = require('cookie-parser');
const path = require('path');
const logger = require('morgan');
const axios = require('axios');

import 'dotenv/config';
import AuthRouter from '../routes/auth';
import InsertDbRegister from '../routes/registerDBInsert';
import ProfileRouter from '../routes/profile';
import RankingRouter from '../routes/rankingSearch';
import FriendRouter from '../routes/friend';
import GameRecordRouter from '../routes/gameRecord';
import * as swaggerUi from 'swagger-ui-express';
import * as YAML from 'yamljs';

import { registerDupCheck } from '../middlewares/jwt';
import ApiRouter from '../routes/api-routes/index';

class App {
public application: express.Application;
Expand All @@ -37,16 +29,7 @@ app.use(
app.use(logger('dev'));
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/api/auth', AuthRouter);
app.use('/api/rank', RankingRouter);
app.use('/api/register', registerDupCheck, InsertDbRegister);
app.use('/api/profile', ProfileRouter);
app.use('/api/friend', FriendRouter);
app.use('/api/game/record', GameRecordRouter);
app.use('/api', ApiRouter);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));

app.get('/api', (req: express.Request, res: express.Response) => {
res.send('start');
});

app.listen(4000, () => console.log('start'));
114 changes: 114 additions & 0 deletions back-end/socket-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions back-end/socket-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"start": "npx nodemon --exec ts-node ./src/index.ts"
},
"dependencies": {
"@socket.io/redis-adapter": "^7.0.1",
"@socket.io/redis-emitter": "^4.1.0",
"@types/express": "^4.17.13",
"axios": "^0.24.0",
"cookie-parser": "~1.4.4",
Expand All @@ -14,10 +16,13 @@
"express": "~4.16.1",
"jsonwebtoken": "^8.5.1",
"morgan": "~1.9.1",
"redis": "^3.1.2",
"redis-lock": "^0.1.4",
"socket.io": "^4.3.2",
"typescript": "^4.4.4"
},
"devDependencies": {
"@types/redis": "^2.8.32",
"nodemon": "^2.0.14",
"ts-node": "^10.4.0"
}
Expand Down
Loading

0 comments on commit 3663877

Please sign in to comment.