Skip to content

Commit

Permalink
Merge branch 'dev-WEB'
Browse files Browse the repository at this point in the history
  • Loading branch information
dogyeong committed Dec 21, 2020
2 parents af103aa + 8848199 commit a8541a4
Show file tree
Hide file tree
Showing 191 changed files with 32,151 additions and 29 deletions.
8 changes: 0 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
---
name: iOS PR
about: iOS PR 템플릿
title: '[iOS] '
labels: iOS
assignees: 'jjm159, eojine'
---

## :white_check_mark: 작업 내용

- Todo1
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/BE.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: BE Deployment

on:
push:
branches:
- release-BE

jobs:
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.16.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Npm Install
working-directory: ./WEB/BE
run: npm install

- name: Make envfile
working-directory: ./WEB/BE
run: |
touch .env
echo NODE_ENV = production >> .env
echo DBUSER = ${{ secrets.ENV_DBUSER }} >> .env
echo DBPASS = ${{ secrets.ENV_DBPASS }} >> .env
echo DBHOST = localhost >> .env
echo DBDATABASEWEB = ${{ secrets.ENV_DBDATABASEWEB }} >> .env
echo DBDATABASEiOS = ${{ secrets.ENV_DBDATABASEiOS }} >> .env
echo SALTROUNDS = ${{ secrets.ENV_SALTROUNDS }} >> .env
echo ENCRYPTIONKEY = ${{ secrets.ENV_ENCRYPTIONKEY }} >> .env
echo SECRETKEYNAME = ${{ secrets.ENV_SECRETKEYNAME }} >> .env
echo SECRETKEYALGORITHM = ${{ secrets.ENV_SECRETKEYALGORITHM }} >> .env
echo SECRETKEYLABEL = ${{ secrets.ENV_SECRETKEYLABEL }} >> .env
echo RECAPTCHAKEY = ${{ secrets.ENV_RECAPTCHAKEY }} >> .env
echo EMAILURL = ${{ secrets.ENV_EMAILURL }} >> .env
echo EMAILACCESSKEY = ${{ secrets.ENV_EMAILACCESSKEY }} >> .env
echo EMAILSECRETKEY = ${{ secrets.ENV_EMAILSECRETKEY }} >> .env
echo SESSIONKEY = ${{ secrets.ENV_SESSIONKEY }} >> .env
cat .env
- name: Deploy to Express Server
uses: burnett01/[email protected]
with:
switches: -avzr --delete-after
path: WEB/BE/
remote_path: ~/TOTP/
remote_host: ${{ secrets.BE_HOST }}
remote_user: ${{ secrets.BE_USERNAME }}
remote_key: ${{ secrets.BE_KEY }}
remote_port: ${{ secrets.BE_PORT }}

- name: Restart Forever
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BE_HOST }}
username: ${{ secrets.BE_USERNAME }}
key: ${{ secrets.BE_KEY }}
port: ${{ secrets.BE_PORT }}
script: forever restartall

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: 'DDIS Bot'
47 changes: 47 additions & 0 deletions .github/workflows/FE.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: FE Deployment

on:
push:
branches:
- release-FE

jobs:
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.16.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Npm Install
working-directory: ./WEB/FE
run: npm install

- name: Build
working-directory: ./WEB/FE
run: npm run build

- name: Deploy to Nginx Server
uses: burnett01/[email protected]
with:
switches: -avzr --delete-after
path: WEB/FE/dist/
remote_path: ~/dist/
remote_host: ${{ secrets.FE_HOST }}
remote_user: ${{ secrets.FE_USERNAME }}
remote_key: ${{ secrets.FE_KEY }}
remote_port: ${{ secrets.FE_PORT }}

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: 'DDIS Bot'
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions WEB/BE/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
NODE_ENV =

# DB
DBUSER =
DBPASS =
DBHOST =
DBDATABASEWEB =
DBDATABASEiOS =


# secret Key
SALTROUNDS =
ENCRYPTIONKEY =
SECRETKEYNAME =
SECRETKEYALGORITHM =
SECRETKEYLABEL =
RECAPTCHAKEY =

# email
EMAILURL =
EMAIALACCESSKEY =
EMAILSECRETKEY =

# session
SESSIONKEY =
42 changes: 42 additions & 0 deletions WEB/BE/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"parser": "babel-eslint",
"plugins": ["prettier"],
"env": {
"browser": true,
"node": true
},
"ignorePatterns": ["node_modules/"],

"rules": {
"linebreak-style": 0,
"import/no-dynamic-require": 0,
"import/no-unresolved": 0,
"global-require": 0,
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"no-use-before-define": 0,
"no-console": 0,
"camelcase": "error",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"implicit-arrow-linebreak": "off",
"no-underscore-dangle": "off",
"no-unused-vars": "warn",
"consistent-return": "off",
"no-alert": "off",
"no-return-assign": "off",
"no-param-reassign": "off",
"no-shadow": "off",
"no-continue": "off",
"no-plusplus": "off",
"no-new": "off",
"no-useless-escape": 0,
"no-restricted-syntax": 0,
"no-bitwise": 0
}
}
18 changes: 18 additions & 0 deletions WEB/BE/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"singleQuote": true,
"printWidth": 110,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "es5",
"arrowParens": "always",
"endOfLine": "lf",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"vueIndentScriptAndStyle": false
}
97 changes: 97 additions & 0 deletions WEB/BE/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require('module-alias/register');
const createError = require('http-errors');
const express = require('express');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const logger = require('morgan');
const cors = require('cors');
const debug = require('debug')('server:server');
const authRouter = require('@/routes/web/auth');
const userRouter = require('@/routes/web/user');
const logRouter = require('@/routes/web/log');
const iOSRouter = require('@routes/iOS');
const csrf = require('@middlewares/csrf');
const redis = require('@models/redis');
const sequelizeWEB = require('@models/sequelizeIOS').sequelize;
const sequelizeIOS = require('@models/sequelizeWEB').sequelize;
const swaggerUi = require('swagger-ui-express');
const swaggerJSDoc = require('swagger-jsdoc');
const swaggerDefinition = require('@config/swagger');
const helmet = require('helmet');

require('dotenv').config();

const dev = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 3000;
const app = express();
redis.notifyEvent();
const corsOptions = {
origin: 'http://dadaikseon.com/',
optionsSuccessStatus: 200,
};
const sessionOptions = {
store: new RedisStore({
client: redis.client(),
prefix: 'session:',
}),
saveUninitialized: false,
resave: true,
rolling: true,
secret: process.env.SESSIONKEY,
cookie: {
maxAge: 7200000,
},
};
const swaggerOptions = {
swaggerDefinition,
apis: ['./routes/**/*.js'],
};

sequelizeWEB.sync();
sequelizeIOS.sync();
app.use(logger(dev ? 'dev' : 'combined'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(dev ? cors() : cors(corsOptions));
app.use(helmet());

app.use('/api/app', iOSRouter);

if (!dev) {
app.set('trust proxy', 1);
sessionOptions.cookie.httpOnly = true;
sessionOptions.cookie.sameSite = true;
app.use(csrf.checkHeader);
}

app.use(session(sessionOptions));

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerJSDoc(swaggerOptions)));
app.use('/api/auth', authRouter);
app.use('/api/user', userRouter);
app.use('/api/log', logRouter);

// handle 404
app.use((req, res, next) => {
next(createError(404));
});

// error handler
app.use((err, req, res, next) => {
const { status, message } = err;
res.locals.message = message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
console.error(message);
res.status(status || 500).json({
message,
});
});

app.listen(port, (err) => {
if (err) throw err;
debug(`Listening on ${port}`);
});

module.exports = app;
Loading

0 comments on commit a8541a4

Please sign in to comment.