Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

[seomoon, gilee, hannkim, jolim] - 수고하셨습니다~ #5

Open
wants to merge 206 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
070e1d1
front setting
Aug 30, 2021
ae41ca4
directory
Aug 30, 2021
df64be9
directory
Aug 30, 2021
9edde35
Routing, JoinPage
Aug 30, 2021
b1a4ee2
gilee
weg901127 Aug 30, 2021
c158241
JoinPage 작성, App 스타일 수정
Aug 30, 2021
d9d03b1
hannkim login
Kimhan-nah Aug 30, 2021
be75c7f
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 30, 2021
b1d8733
가운데 정렬
Aug 30, 2021
384ee59
modify
Kimhan-nah Aug 30, 2021
8f6c6d8
Merge branch 'hannkim' of https://github.com/indianpoker/piscine-rush…
Kimhan-nah Aug 30, 2021
085a8e9
modify
Kimhan-nah Aug 30, 2021
0c0c045
modify
Kimhan-nah Aug 30, 2021
8d3e755
JoinPage 완성
Aug 30, 2021
8abc4d9
merge
Aug 30, 2021
45a0bbb
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 30, 2021
1b6235a
make model
weg901127 Aug 30, 2021
638b3ee
add click event : go to join page
Kimhan-nah Aug 30, 2021
a33e1f4
add axios package
Kimhan-nah Aug 30, 2021
a13ad36
yarn add axios
Aug 30, 2021
ebaa787
test
weg901127 Aug 30, 2021
e7669e9
Merge pull request #1 from indianpoker/gilee
weg901127 Aug 30, 2021
fee6ef4
프로필 이미지 필드 수정
Aug 30, 2021
fccabf4
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Aug 30, 2021
6fcc8fa
prod
Aug 30, 2021
81d948c
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 30, 2021
8d4f30b
default img 색상 변경
Aug 30, 2021
a1f79e5
fix docker-compose.yml
Aug 30, 2021
fa2a873
modify background img
Kimhan-nah Aug 30, 2021
e9a4210
Merge branch 'hannkim'
Aug 30, 2021
b935d68
디자인
Aug 30, 2021
a2c0357
Merge branch 'seomoon'
Aug 30, 2021
cbe885b
add MainPage
Kimhan-nah Aug 30, 2021
342b1ea
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 30, 2021
3c8827d
fix reverse proxy
Aug 30, 2021
13f1ea9
Merge pull request #2 from indianpoker/gilee2
weg901127 Aug 30, 2021
014ae1b
Create main.yml
weg901127 Aug 30, 2021
1f76b52
favicon 추가, title 변경
Aug 30, 2021
dd53406
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 30, 2021
5ad2082
action test
weg901127 Aug 30, 2021
7700fee
Merge pull request #3 from indianpoker/gilee2
weg901127 Aug 30, 2021
7c86bf3
action test
weg901127 Aug 30, 2021
4e09c0e
modify main page and app.js
Kimhan-nah Aug 30, 2021
191043f
Merge pull request #4 from indianpoker/gilee2
weg901127 Aug 30, 2021
619a942
Update main.yml
weg901127 Aug 30, 2021
5eb79e4
Update main.yml
weg901127 Aug 30, 2021
276cf4f
Update main.yml
weg901127 Aug 30, 2021
73ef65c
Update main.yml
weg901127 Aug 30, 2021
ae5913e
Update main.yml
weg901127 Aug 30, 2021
24a40dc
Update main.yml
weg901127 Aug 30, 2021
3ea6fb8
Update main.yml
weg901127 Aug 30, 2021
190734e
Update main.yml
weg901127 Aug 30, 2021
7a2f7e6
test
weg901127 Aug 30, 2021
458290d
Update main.yml
weg901127 Aug 30, 2021
6dad6c6
add join
weg901127 Aug 31, 2021
ab7e407
Merge pull request #5 from indianpoker/gilee
weg901127 Aug 31, 2021
558d3be
Update main.yml
weg901127 Aug 31, 2021
1e6ec10
Update up.sh
weg901127 Aug 31, 2021
4066e01
/login route
Aug 31, 2021
d4725dd
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
3259cc3
Update main.yml
weg901127 Aug 31, 2021
f353730
pull test
weg901127 Aug 31, 2021
ec35477
Create a
weg901127 Aug 31, 2021
e88dec5
add background color
Aug 31, 2021
52dcb7f
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
2340d93
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 31, 2021
d330edc
.
Aug 31, 2021
315299c
Update main.yml
weg901127 Aug 31, 2021
bec6b8e
pull test
weg901127 Aug 31, 2021
eb8b48b
Merge pull request #6 from indianpoker/gilee
weg901127 Aug 31, 2021
a22b93e
Update main.yml
weg901127 Aug 31, 2021
e1bcf79
Merge pull request #7 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
ae91cf5
Update main.yml
weg901127 Aug 31, 2021
bfb3117
Merge pull request #8 from indianpoker/weg901127-patch-2
weg901127 Aug 31, 2021
2a2ed30
pull test
weg901127 Aug 31, 2021
cd1ec7e
pull test
weg901127 Aug 31, 2021
341c4e8
Merge pull request #10 from indianpoker/gilee
weg901127 Aug 31, 2021
719e6ed
modify main page
Kimhan-nah Aug 31, 2021
a954dc2
Update main.yml
weg901127 Aug 31, 2021
17edf52
Merge pull request #11 from indianpoker/weg901127-patch-3
weg901127 Aug 31, 2021
261fd78
Update main.yml
weg901127 Aug 31, 2021
92fb869
Merge pull request #12 from indianpoker/weg901127-patch-4
weg901127 Aug 31, 2021
b71aca4
pull test
weg901127 Aug 31, 2021
b9b54b5
Delete a
weg901127 Aug 31, 2021
b6583d9
Merge pull request #13 from indianpoker/weg901127-patch-4
weg901127 Aug 31, 2021
64574d7
JoinPage state 로직 분리, axios post 처리
Aug 31, 2021
a39e89e
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Aug 31, 2021
c93e206
Update main.yml
weg901127 Aug 31, 2021
06589e2
Merge pull request #14 from indianpoker/weg901127-patch-4
weg901127 Aug 31, 2021
e3c1658
Update main.yml
weg901127 Aug 31, 2021
773319b
Merge pull request #15 from indianpoker/weg901127-patch-5
weg901127 Aug 31, 2021
673fa8c
modify app.js : MainPage's props
Kimhan-nah Aug 31, 2021
6121c22
Create a
weg901127 Aug 31, 2021
86a6587
Merge pull request #16 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
e3112b3
merge app.js
Kimhan-nah Aug 31, 2021
5d6bef5
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 31, 2021
955993c
merge
Kimhan-nah Aug 31, 2021
c5b228e
Update main.yml
weg901127 Aug 31, 2021
4119aa4
Merge pull request #17 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
8bc8871
Update main.yml
weg901127 Aug 31, 2021
2bbae8d
Merge pull request #18 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
f21a679
Update main.yml
weg901127 Aug 31, 2021
78f325e
Merge pull request #19 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
fcfaf56
Update main.yml
weg901127 Aug 31, 2021
9d4dd33
Merge pull request #20 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
70d7de4
Update main.yml
weg901127 Aug 31, 2021
ab121eb
Merge pull request #21 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
c9e63dd
Update main.yml
weg901127 Aug 31, 2021
8bffdb4
Merge pull request #22 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
4da1769
Update main.yml
weg901127 Aug 31, 2021
61dec00
Merge pull request #23 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
d9e8e62
Update main.yml
weg901127 Aug 31, 2021
3e9c46a
Merge pull request #24 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
6148cb9
Update main.yml
weg901127 Aug 31, 2021
2f83d27
Merge pull request #25 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
f129379
Update main.yml
weg901127 Aug 31, 2021
76b4545
Merge pull request #26 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
0673843
Delete a
weg901127 Aug 31, 2021
967f2e2
Merge pull request #27 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
205ac79
Create a
weg901127 Aug 31, 2021
5ede743
Merge pull request #28 from indianpoker/weg901127-patch-1
weg901127 Aug 31, 2021
fa2c7f3
모달창
Aug 31, 2021
7a3761b
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Aug 31, 2021
e0f728f
LoginPage api 연동
Aug 31, 2021
f4077a9
history.push(api/login)
Aug 31, 2021
fbbb7f9
join fix
weg901127 Aug 31, 2021
3d15758
join fix
weg901127 Aug 31, 2021
85ba49d
Merge pull request #30 from indianpoker/gilee
weg901127 Aug 31, 2021
38e5cc9
Dialog 디자인
Aug 31, 2021
b76656f
loginpage, joinpage 요청
Aug 31, 2021
046b0c2
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
0ce41ba
App.js 리팩토링
Aug 31, 2021
fbb154a
cors fix
weg901127 Aug 31, 2021
60cf9e4
Merge pull request #31 from indianpoker/gilee
weg901127 Aug 31, 2021
449ab54
cors fix
weg901127 Aug 31, 2021
2bc9bb9
Merge pull request #32 from indianpoker/gilee
weg901127 Aug 31, 2021
cbd17f9
cors fix
weg901127 Aug 31, 2021
e3af0e8
Merge pull request #33 from indianpoker/gilee
weg901127 Aug 31, 2021
25154e4
styles
Aug 31, 2021
05788ad
.
Aug 31, 2021
b91d421
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
33a84f6
.
Aug 31, 2021
6915a1d
.
Aug 31, 2021
79bde3a
fix App.js conflict
Aug 31, 2021
eb71ef3
img
weg901127 Aug 31, 2021
f799b94
Merge pull request #34 from indianpoker/gilee
weg901127 Aug 31, 2021
70d16a8
NewRoomForm 완성
Aug 31, 2021
f65a00f
img object -> formData로 전송
Aug 31, 2021
cc09f9f
NewRoomForm 디자인 개선
Aug 31, 2021
49ec53a
NewRoomForm 디자인 개선2
Aug 31, 2021
4ebcda3
JoinRoomForm 완성
Aug 31, 2021
076ae1e
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Aug 31, 2021
6a03d43
img
weg901127 Aug 31, 2021
f9b4a50
Merge pull request #35 from indianpoker/gilee
weg901127 Aug 31, 2021
4b23492
modify GamePage
Kimhan-nah Aug 31, 2021
025c5d7
img
weg901127 Aug 31, 2021
c0a8be3
Merge pull request #36 from indianpoker/gilee
weg901127 Aug 31, 2021
4727327
merge
Kimhan-nah Aug 31, 2021
f7705dc
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 31, 2021
2f9418a
img
weg901127 Aug 31, 2021
65713b6
Merge pull request #37 from indianpoker/gilee
weg901127 Aug 31, 2021
561fb5a
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Kimhan-nah Aug 31, 2021
212e98e
img
weg901127 Aug 31, 2021
c1d1332
Merge pull request #38 from indianpoker/gilee
weg901127 Aug 31, 2021
2a77b75
img
weg901127 Aug 31, 2021
7dcfc5a
Merge pull request #39 from indianpoker/gilee
weg901127 Aug 31, 2021
ca62eb7
img
weg901127 Aug 31, 2021
ec000f1
Merge pull request #40 from indianpoker/gilee
weg901127 Aug 31, 2021
098efaa
formData
Aug 31, 2021
53d6c88
img
weg901127 Aug 31, 2021
0766546
modify card margin
Kimhan-nah Aug 31, 2021
48757f5
Merge pull request #41 from indianpoker/gilee
weg901127 Aug 31, 2021
b50ebd7
img
weg901127 Aug 31, 2021
169784c
Merge pull request #42 from indianpoker/gilee
weg901127 Aug 31, 2021
0f2b226
img
weg901127 Aug 31, 2021
ec3f502
Merge pull request #43 from indianpoker/gilee
weg901127 Aug 31, 2021
6053ac7
img
weg901127 Aug 31, 2021
de50c36
Merge pull request #44 from indianpoker/gilee
weg901127 Aug 31, 2021
cb4d3f6
modify game page style
Kimhan-nah Aug 31, 2021
ec3a39d
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Kimhan-nah Aug 31, 2021
a8c1046
add contenttype header
Aug 31, 2021
3f276c4
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
14cae33
img
weg901127 Aug 31, 2021
6172a7c
Merge pull request #45 from indianpoker/gilee
weg901127 Aug 31, 2021
d6a519d
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
a4a0e76
GamePage Dealing section 추가
Aug 31, 2021
b931266
Merge branch 'master' of https://github.com/indianpoker/piscine-rush0…
Aug 31, 2021
dc6b54d
App.js 안 쓰는 함수 삭제
Aug 31, 2021
d65806d
img
weg901127 Aug 31, 2021
9eac5a5
Merge pull request #46 from indianpoker/gilee
weg901127 Aug 31, 2021
af9121b
join post only nickname
Aug 31, 2021
3005e77
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
f1d45df
img
weg901127 Aug 31, 2021
008cde7
Merge pull request #47 from indianpoker/gilee
weg901127 Aug 31, 2021
b181881
.
Aug 31, 2021
ce26c6f
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
01471d4
.
Aug 31, 2021
4c2d5ec
.
Aug 31, 2021
3556553
cookie check and redirect to login
Aug 31, 2021
cba74ef
cookie
Aug 31, 2021
5d3c889
merge
Aug 31, 2021
23efceb
react-cookie
Aug 31, 2021
e0ffee1
a
weg901127 Aug 31, 2021
63c0d45
a
weg901127 Aug 31, 2021
339880f
.
Aug 31, 2021
3ac8d47
Merge branch 'master' of https://github.com/indianpoker/piscine-rush01
Aug 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
push:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git pull
build2:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
cd rush01-front
yarn
cd ..
cd rush01-back
npm i
cd ..
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:latest AS builder
WORKDIR /app

#FROM node:latest-alpine
#WORKDIR /app
RUN npm install -g nodemon
#COPY --from=builder /app ./
CMD ["npm", "run", "start"]
7 changes: 7 additions & 0 deletions Dockerfile_front
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:latest AS builder
WORKDIR /app

#FROM node:latest-alpine
#WORKDIR /app
#COPY --from=builder /app ./
CMD ["yarn", "start"]
1 change: 1 addition & 0 deletions a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"
services:
frontend:
build:
dockerfile: Dockerfile_front
context: ./
volumes:
- ./rush01-front:/app
depends_on:
- backend
network_mode: "host"
backend:
build:
dockerfile: Dockerfile
context: ./
volumes:
- ./rush01-back:/app
network_mode: "host"
25 changes: 25 additions & 0 deletions docker-compose_copy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3"
services:
backend:
build:
dockerfile: Dockerfile
context: ./
volumes:
- ./rush01-back:/app
depends_on:
- db
ports:
- "4200:4200"
db: # 서비스 명
image: mysql:latest # 사용할 이미지
container_name: mysql_database # 컨테이너 이름 설정
environment: # -e 옵션
MYSQL_DATABASE: 42overflow
MYSQL_ROOT_PASSWORD: 1234 # MYSQL 패스워드 설정 옵션
command: # 명령어 실행
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
volumes:
- ./rush01-back/mariadb:/var/lib/mysql # -v 옵션 (다렉토리 마운트 설정)
ports:
- "3306:3306"
6 changes: 6 additions & 0 deletions rush01-back/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
.env
sessions/
migrations
mariadb
package-lock.json
93 changes: 93 additions & 0 deletions rush01-back/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
require('dotenv').config()
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var session = require('express-session');
var fileStore = require('session-file-store')(session);
var passport = require('./passportset');
const cors = require('cors');
//var ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn;

const {sequelize, Users} = require('./models/');

const loginRouter = require('./routes/login');
const joinRouter = require('./routes/join');

var app = express();
app.use(cors({
origin: true,
credentials: true
}));
//sequelize.authenticate().then((results) => {
sequelize.sync().then((results) => {
console.log("done");
}).catch((err) => {
console.log(err);
});
app.use(express.json());
app.use(express.urlencoded( {extended : false } ));
// view engine setup
// console.log(Users);
// Users.findOne({ where: { username: "gilee" } }).then((results) => {
// console.log('🤬', results);
// }).catch((err) => { console.log('' + err); });

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(session({ resave: false, saveUninitialized: false, secret: process.env.SESSION_SECRET , store: new fileStore()}));
app.use(express.static(path.join(__dirname, 'public')));

//app.use(passport.initialize());
//app.use(passport.session());
app.get('/api', (req, res) => {
res.json('hello');
});
app.use('/api/login', loginRouter);
app.use('/api/join', joinRouter);
/*
app.get('/login',
ensureLoggedIn('/login/42'),
function (req, res) {
console.log(req.user,'loggedin');
res.render('index', {name : req.user});
});

app.get('/login/42',
passport.authenticate('42'));

app.get('/login/42/return',
passport.authenticate('42', { failureRedirect: '/login/42' }),
function (req, res) {
res.redirect('/')
});
*/
app.get('/api/logout', function (req, res) {
req.logOut();
req.session.save(function(){
res.redirect('/api/login');
})
});
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.json(err.stack);
});

module.exports = app;
90 changes: 90 additions & 0 deletions rush01-back/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('oauth-42:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort('4200');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
24 changes: 24 additions & 0 deletions rush01-back/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require('dotenv').config();
const development = {
"username": process.env.NAME,
"password": process.env.PW,
"database": process.env.DB,
"host": process.env.DBHOST,
"dialect": process.env.DIALECT
}

const test = {
"username": process.env.NAME,
"password": process.env.PW,
"database": process.env.DB,
"host": process.env.DBHOST,
"dialect": process.env.DIALECT
}
const production = {
"username": process.env.NAME,
"password": process.env.PW,
"database": process.env.DB,
"host": process.env.DBHOST,
"dialect": process.env.DIALECT
}
module.exports = { development, production, test };
35 changes: 35 additions & 0 deletions rush01-back/models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.js')[env];
const db = {};

let sequelize;
if (config) {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});

Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
Loading