송용우

Merge commit 'c0bc6fd4' into feature/rest_api

Showing 53 changed files with 2645 additions and 52 deletions
This diff could not be displayed because it is too large.
...@@ -3,13 +3,25 @@ ...@@ -3,13 +3,25 @@
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 + "@material-ui/core": "^4.10.2",
6 "@testing-library/jest-dom": "^4.2.4", 7 "@testing-library/jest-dom": "^4.2.4",
7 "@testing-library/react": "^9.3.2", 8 "@testing-library/react": "^9.3.2",
8 "@testing-library/user-event": "^7.1.2", 9 "@testing-library/user-event": "^7.1.2",
10 + "axios": "^0.19.2",
11 + "immer": "^7.0.5",
12 + "include-media": "^1.4.9",
13 + "moment": "^2.27.0",
14 + "open-color": "^1.7.0",
9 "react": "^16.13.1", 15 "react": "^16.13.1",
10 "react-dom": "^16.13.1", 16 "react-dom": "^16.13.1",
17 + "react-redux": "^7.2.0",
11 "react-router-dom": "^5.2.0", 18 "react-router-dom": "^5.2.0",
12 - "react-scripts": "3.4.1" 19 + "react-scripts": "3.4.1",
20 + "redux": "^4.0.5",
21 + "redux-actions": "^2.6.5",
22 + "redux-devtools-extension": "^2.13.8",
23 + "redux-saga": "^1.1.3",
24 + "styled-components": "^5.1.1"
13 }, 25 },
14 "scripts": { 26 "scripts": {
15 "start": "react-scripts start", 27 "start": "react-scripts start",
...@@ -31,5 +43,6 @@ ...@@ -31,5 +43,6 @@
31 "last 1 firefox version", 43 "last 1 firefox version",
32 "last 1 safari version" 44 "last 1 safari version"
33 ] 45 ]
34 - } 46 + },
47 + "proxy": "http://localhost:4000"
35 } 48 }
......
1 import React from 'react'; 1 import React from 'react';
2 -import logo from './logo.svg'; 2 +import { Route } from 'react-router-dom';
3 import './App.css'; 3 import './App.css';
4 +import LoginPage from './pages/LoginPage';
5 +import RegisterPage from './pages/RegisterPage';
6 +import HomePage from './pages/HomePage';
7 +import SettingPage from './pages/SettingPage';
4 8
5 function App() { 9 function App() {
6 return ( 10 return (
7 - <div className="App"> 11 + <>
8 - <header className="App-header"> 12 + <Route component={HomePage} path={['/@:username', '/']} exact />
9 - <img src={logo} className="App-logo" alt="logo" /> 13 + <Route component={LoginPage} path="/login" />
10 - <p> 14 + <Route component={RegisterPage} path="/register" />
11 - Edit <code>src/App.js</code> and save to reload. 15 + <Route component={SettingPage} path="/setting" />
12 - </p> 16 + </>
13 - <a
14 - className="App-link"
15 - href="https://reactjs.org"
16 - target="_blank"
17 - rel="noopener noreferrer"
18 - >
19 - Learn React
20 - </a>
21 - </header>
22 - </div>
23 ); 17 );
24 } 18 }
25 19
......
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import { Link } from 'react-router-dom';
4 +import palette from '../../lib/styles/palette';
5 +import Button from '../common/Button';
6 +
7 +const AuthFormBlock = styled.div`
8 + h3 {
9 + margin: 0;
10 + color: ${palette.gray[8]};
11 + margin-bottom: 1rem;
12 + }
13 +`;
14 +
15 +const StyledInput = styled.input`
16 + font-size: 1rem;
17 + border: none;
18 + border-bottom: 1px solid ${palette.gray[5]};
19 + padding-bottom: 0.5rem;
20 + outline: none;
21 + width: 100%;
22 + &:focus {
23 + color: $oc-teal-7;
24 + border-bottom: 1px solid ${palette.gray[7]};
25 + }
26 + & + & {
27 + margin-top: 1rem;
28 + }
29 +`;
30 +
31 +const Footer = styled.div`
32 + margin-top: 2rem;
33 + text-align: right;
34 + a {
35 + color: ${palette.gray[6]};
36 + text-decoration: underline;
37 + &:hover {
38 + color: ${palette.gray[9]};
39 + }
40 + }
41 +`;
42 +
43 +const ButtonWithMarginTop = styled(Button)`
44 + margin-top: 1rem;
45 +`;
46 +
47 +const ErrorMessage = styled.div`
48 + color: red;
49 + text-align: center;
50 + font-size: 0.875rem;
51 + margin-top: 1rem;
52 +`;
53 +
54 +const textMap = {
55 + login: '로그인',
56 + register: '회원가입',
57 +};
58 +
59 +const AuthForm = ({ type, form, onChange, onSubmit, error }) => {
60 + const text = textMap[type];
61 + return (
62 + <AuthFormBlock>
63 + <h3>{text}</h3>
64 + <form onSubmit={onSubmit}>
65 + <StyledInput
66 + autoComplete="username"
67 + name="username"
68 + placeholder="아이디"
69 + onChange={onChange}
70 + value={form.username}
71 + />
72 + <StyledInput
73 + autoComplete="new-password"
74 + name="password"
75 + placeholder="비밀번호"
76 + type="password"
77 + onChange={onChange}
78 + value={form.password}
79 + />
80 + {type === 'register' && (
81 + <StyledInput
82 + autoComplete="new-password"
83 + name="passwordConfirm"
84 + placeholder="비밀번호 확인"
85 + type="password"
86 + onChange={onChange}
87 + value={form.passwordConfirm}
88 + />
89 + )}
90 + {error && <ErrorMessage>{error}</ErrorMessage>}
91 + <ButtonWithMarginTop cyan fullWidth>
92 + {text}
93 + </ButtonWithMarginTop>
94 + </form>
95 + <Footer>
96 + {type === 'login' ? (
97 + <Link to="/register">회원가입</Link>
98 + ) : (
99 + <Link to="/login">로그인</Link>
100 + )}
101 + </Footer>
102 + </AuthFormBlock>
103 + );
104 +};
105 +
106 +export default AuthForm;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import palette from '../../lib/styles/palette';
4 +import { Link } from 'react-router-dom';
5 +/*
6 +register/login Layout
7 +*/
8 +const AuthTemplateBlock = styled.div`
9 + position: absolute;
10 + left: 0;
11 + top: 0;
12 + bottom: 0;
13 + right: 0;
14 + background: ${palette.gray[2]};
15 + display: flex;
16 + flex-direction: column;
17 + justify-content: center;
18 + align-items: center;
19 +`;
20 +
21 +const WhiteBox = styled.div`
22 + .logo-area {
23 + display: block;
24 + padding-bottom: 2rem;
25 + text-align: center;
26 + font-weight: bold;
27 + letter-spacing: 2px;
28 + }
29 + box-shadow: 0 0 8px rgba(0, 0, 0, 0.025);
30 + padding: 2rem;
31 + width: 360px;
32 + background: white;
33 + border-radius: 2px;
34 +`;
35 +
36 +const AuthTemplate = ({ children }) => {
37 + return (
38 + <AuthTemplateBlock>
39 + <WhiteBox>
40 + <div className="logo-area">
41 + <Link to="/">작심삼일</Link>
42 + </div>
43 + {children}
44 + </WhiteBox>
45 + </AuthTemplateBlock>
46 + );
47 +};
48 +
49 +export default AuthTemplate;
1 +import React from 'react';
2 +import styled, { css } from 'styled-components';
3 +import palette from '../../lib/styles/palette';
4 +import { withRouter } from 'react-router-dom';
5 +
6 +const StyledButton = styled.button`
7 + border: none;
8 + border-radius: 4px;
9 + font-size: 1rem;
10 + font-weight: bold;
11 + padding: 0.25rem 1rem;
12 + color: white;
13 + outline: none;
14 + cursor: pointer;
15 +
16 + background: ${palette.gray[8]};
17 + &:hover {
18 + background: ${palette.gray[6]};
19 + }
20 + ${props =>
21 + props.fullWidth &&
22 + css`
23 + padding-top: 0.75rem;
24 + padding-bottom: 0.75rem;
25 + width: 100%;
26 + font-size: 1.125rem;
27 + `}
28 +
29 + ${props =>
30 + props.cyan &&
31 + css`
32 + background: ${palette.cyan[5]};
33 + &:hover {
34 + background: ${palette.cyan[4]};
35 + }
36 + `}
37 +`;
38 +
39 +const Button = ({ to, history, ...rest }) => {
40 + const onClick = e => {
41 + if (to) {
42 + history.push(to);
43 + }
44 + if (rest.onClick) {
45 + rest.onClick(e);
46 + }
47 + };
48 + return <StyledButton {...rest} onClick={onClick} />;
49 +};
50 +export default withRouter(Button);
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import { NavLink } from 'react-router-dom';
4 +
5 +const categories = [
6 + {
7 + name: 'home',
8 + text: '홈',
9 + },
10 + {
11 + name: 'setting',
12 + text: '설정',
13 + },
14 +];
15 +
16 +const CategoriesBlock = styled.div`
17 + display: flex;
18 + padding: 1rem;
19 + margin: 0 auto;
20 + @media screen and (max-width: 768px) {
21 + width: 100%;
22 + overflow-x: auto;
23 + }
24 +`;
25 +
26 +const Category = styled(NavLink)`
27 + font-size: 1.2rem;
28 + cursor: pointer;
29 + white-space: pre;
30 + text-decoration: none;
31 + color: inherit;
32 + padding-bottom: 0.25rem;
33 + &:hover {
34 + color: #495057;
35 + }
36 + & + & {
37 + margin-left: 2rem;
38 + }
39 + &.active {
40 + font-weight: 600;
41 + border-bottom: 2px solid #22b8cf;
42 + color: #22b8cf;
43 + &:hover {
44 + color: #3bc9db;
45 + }
46 + }
47 +`;
48 +
49 +const Categories = () => {
50 + return (
51 + <CategoriesBlock>
52 + {categories.map((c) => (
53 + <Category
54 + activeClassName="active"
55 + key={c.name}
56 + exact={c.name === 'home'}
57 + to={c.name === 'home' ? '/' : `/${c.name}`}
58 + >
59 + {c.text}
60 + </Category>
61 + ))}
62 + </CategoriesBlock>
63 + );
64 +};
65 +
66 +export default Categories;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import Responsive from './Responsive';
4 +import Button from './Button';
5 +import { Link } from 'react-router-dom';
6 +import Categories from './Categories';
7 +
8 +const HeaderBlock = styled.div`
9 + position: fixed;
10 + width: 100%;
11 + background: white;
12 + box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.08);
13 +`;
14 +
15 +const Wrapper = styled(Responsive)`
16 + height: 4rem;
17 + display: flex;
18 + align-items: center;
19 + justify-content: space-between;
20 + .logo {
21 + font-size: 1.125rem;
22 + font-weight: 800;
23 + letter-spacing: 2px;
24 + }
25 + .right {
26 + display: flex;
27 + align-items: center;
28 + }
29 +`;
30 +
31 +const Spacer = styled.div`
32 + height: 4rem;
33 +`;
34 +const UserInfo = styled.div`
35 + font-weight: 800;
36 + margin-right: 1rem;
37 +`;
38 +
39 +const Header = ({ user, onLogout, category, onSelect }) => {
40 + return (
41 + <>
42 + <HeaderBlock>
43 + <Wrapper>
44 + <Link to="/" className="logo">
45 + 작심삼일
46 + </Link>
47 + <Categories
48 + category={category}
49 + onSelect={onSelect}
50 + className="right"
51 + />
52 + {user ? (
53 + <div className="right">
54 + <UserInfo>{user.username}</UserInfo>
55 + <Button onClick={onLogout}>로그아웃</Button>
56 + </div>
57 + ) : (
58 + <div className="right">
59 + <Button to="/login">로그인</Button>
60 + </div>
61 + )}
62 + </Wrapper>
63 + </HeaderBlock>
64 + <Spacer />
65 + </>
66 + );
67 +};
68 +
69 +export default Header;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +
4 +const ResponsiveBlock = styled.div`
5 + padding-left: 1rem;
6 + padding-right: 1rem;
7 + width: 1024px;
8 + margin: 0 auto;
9 +
10 + @media (max-width: 1024px) {
11 + width: 768px;
12 + }
13 + @media (max-width: 768px) {
14 + width: 100%;
15 + }
16 +`;
17 +
18 +const Responsive = ({ children, ...rest }) => {
19 + return <ResponsiveBlock {...rest}>{children}</ResponsiveBlock>;
20 +};
21 +
22 +export default Responsive;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Paper from '@material-ui/core/Paper';
4 +import Grid from '@material-ui/core/Grid';
5 +import palette from '../../lib/styles/palette';
6 +const useStyles = makeStyles((theme) => ({
7 + root: {
8 + flexGrow: 1,
9 + background: palette.gray[2],
10 + },
11 + paper: {
12 + padding: theme.spacing(2),
13 + textAlign: 'center',
14 + color: theme.palette.text.secondary,
15 + },
16 +}));
17 +const HomeForm = () => {
18 + const classes = useStyles();
19 + return (
20 + <div className={classes.root}>
21 + <Grid container spacing={3}>
22 + <Grid item xs={12}>
23 + <Paper className={classes.paper}>xs=12</Paper>
24 + </Grid>
25 + <Grid item xs={6}>
26 + <Paper className={classes.paper}>xs=6</Paper>
27 + </Grid>
28 + <Grid item xs={6}>
29 + <Paper className={classes.paper}>xs=6</Paper>
30 + </Grid>
31 + <Grid item xs={3}>
32 + <Paper className={classes.paper}>xs=3</Paper>
33 + </Grid>
34 + <Grid item xs={3}>
35 + <Paper className={classes.paper}>xs=3</Paper>
36 + </Grid>
37 + <Grid item xs={3}>
38 + <Paper className={classes.paper}>xs=3</Paper>
39 + </Grid>
40 + <Grid item xs={3}>
41 + <Paper className={classes.paper}>xs=3</Paper>
42 + </Grid>
43 + </Grid>
44 + </div>
45 + );
46 +};
47 +
48 +export default HomeForm;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Button from '@material-ui/core/Button';
4 +import TextField from '@material-ui/core/TextField';
5 +
6 +const useStyles = makeStyles((theme) => ({
7 + root: {
8 + '& > *': {
9 + margin: theme.spacing(1),
10 + },
11 + },
12 +}));
13 +
14 +const BJIDForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => {
15 + const classes = useStyles();
16 + return (
17 + <div>
18 + <form onSubmit={onBJIDSubmit}>
19 + <TextField
20 + name="userBJID"
21 + onChange={onChange}
22 + value={profile.userBJID}
23 + placeholder="백준 아이디"
24 + label="백준 아이디"
25 + />
26 + <Button variant="outlined" type="submit">
27 + 등록
28 + </Button>
29 + </form>
30 + <Button variant="outlined" onClick={onSyncBJIDSubmit}>
31 + 동기화
32 + </Button>
33 + </div>
34 + );
35 +};
36 +export default BJIDForm;
1 +import React from 'react';
2 +import palette from '../../lib/styles/palette';
3 +import BJIDForm from './BJIDForm';
4 +import SlackForm from './SlackForm';
5 +import { makeStyles } from '@material-ui/core/styles';
6 +import Paper from '@material-ui/core/Paper';
7 +import Grid from '@material-ui/core/Grid';
8 +
9 +const useStyles = makeStyles((theme) => ({
10 + root: {
11 + flexGrow: 1,
12 + background: palette.gray[2],
13 + },
14 + paper: {
15 + margin: 'auto',
16 + textAlign: 'center',
17 + padding: 30,
18 + },
19 +}));
20 +
21 +const SettingForm = ({
22 + onChange,
23 + onBJIDSubmit,
24 + onSlackURLSubmit,
25 + profile,
26 + onSyncBJIDSubmit,
27 +}) => {
28 + const classes = useStyles();
29 + return (
30 + <div className={classes.root}>
31 + <Grid container spacing={3}>
32 + <Grid item xs={12}>
33 + <Paper className={classes.paper}>
34 + <h3>{profile.username}</h3>
35 + </Paper>
36 + </Grid>
37 + <Grid container item xs={12}>
38 + <Paper className={classes.paper} elevation={3}>
39 + <BJIDForm
40 + profile={profile}
41 + onChange={onChange}
42 + onBJIDSubmit={onBJIDSubmit}
43 + onSyncBJIDSubmit={onSyncBJIDSubmit}
44 + />
45 + </Paper>
46 + </Grid>
47 +
48 + <Grid container item xs={12}>
49 + <Paper className={classes.paper} elevation={3}>
50 + <SlackForm
51 + profile={profile}
52 + onChange={onChange}
53 + onSlackURLSubmit={onSlackURLSubmit}
54 + />
55 + </Paper>
56 + </Grid>
57 + </Grid>
58 + </div>
59 + );
60 +};
61 +
62 +export default SettingForm;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +
4 +import Button from '@material-ui/core/Button';
5 +import TextField from '@material-ui/core/TextField';
6 +
7 +const useStyles = makeStyles((theme) => ({
8 + root: {
9 + '& > *': {
10 + margin: theme.spacing(1),
11 + },
12 + },
13 +}));
14 +
15 +const SlackForm = ({ onChange, profile, onSlackURLSubmit }) => {
16 + const classes = useStyles();
17 + return (
18 + <div>
19 + <form onSubmit={onSlackURLSubmit}>
20 + <TextField
21 + name="slackWebHookURL"
22 + onChange={onChange}
23 + value={profile.slackWebHookURL}
24 + placeholder="슬랙 Webhook URL"
25 + label="슬랙 Webhook URL"
26 + />
27 + <Button variant="outlined" type="submit">
28 + 등록
29 + </Button>
30 + </form>
31 + </div>
32 + );
33 +};
34 +
35 +export default SlackForm;
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import { changeField, initializeForm, login } from '../../modules/auth';
5 +import AuthForm from '../../components/auth/AuthForm';
6 +import { check } from '../../modules/user';
7 +
8 +const LoginForm = ({ history }) => {
9 + const dispatch = useDispatch();
10 + const [error, setError] = useState(null);
11 + const { form, auth, authError, user } = useSelector(({ auth, user }) => ({
12 + form: auth.login,
13 + auth: auth.auth,
14 + authError: auth.authError,
15 + user: user.user,
16 + }));
17 +
18 + const onChange = (e) => {
19 + const { value, name } = e.target;
20 + dispatch(
21 + changeField({
22 + form: 'login',
23 + key: name,
24 + value,
25 + }),
26 + );
27 + };
28 +
29 + const onSubmit = (e) => {
30 + e.preventDefault();
31 + const { username, password } = form;
32 + dispatch(login({ username, password }));
33 + };
34 +
35 + useEffect(() => {
36 + dispatch(initializeForm('login'));
37 + }, [dispatch]);
38 +
39 + useEffect(() => {
40 + if (authError) {
41 + console.log('Error Occured');
42 + console.log(authError);
43 + setError('로그인 실패');
44 + return;
45 + }
46 + if (auth) {
47 + console.log('Login Success');
48 + dispatch(check());
49 + }
50 + }, [auth, authError, dispatch]);
51 +
52 + useEffect(() => {
53 + if (user) {
54 + history.push('/');
55 + try {
56 + localStorage.setItem('user', JSON.stringify(user));
57 + } catch (e) {
58 + console.log('localStorage is not working');
59 + }
60 + console.log(user);
61 + }
62 + }, [history, user]);
63 + return (
64 + <AuthForm
65 + type="login"
66 + form={form}
67 + onChange={onChange}
68 + onSubmit={onSubmit}
69 + error={error}
70 + ></AuthForm>
71 + );
72 +};
73 +
74 +export default withRouter(LoginForm);
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { changeField, initializeForm, register } from '../../modules/auth';
4 +import AuthForm from '../../components/auth/AuthForm';
5 +import { check } from '../../modules/user';
6 +import { withRouter } from 'react-router-dom';
7 +
8 +const RegisterForm = ({ history }) => {
9 + const [error, setError] = useState(null);
10 + const dispatch = useDispatch();
11 + const { form, auth, authError, user } = useSelector(({ auth, user }) => ({
12 + form: auth.register,
13 + auth: auth.auth,
14 + authError: auth.authError,
15 + user: user.user,
16 + }));
17 +
18 + const onChange = (e) => {
19 + const { value, name } = e.target;
20 + dispatch(
21 + changeField({
22 + form: 'register',
23 + key: name,
24 + value,
25 + }),
26 + );
27 + };
28 +
29 + const onSubmit = (e) => {
30 + e.preventDefault();
31 + const { username, password, passwordConfirm } = form;
32 + if ([username, password, passwordConfirm].includes('')) {
33 + setError('빈 칸을 모두 입력하세요');
34 + return;
35 + }
36 + if (password !== passwordConfirm) {
37 + setError('비밀번호가 일치하지 않습니다.');
38 + changeField({ form: 'register', key: 'password', value: '' });
39 + changeField({ form: 'register', key: 'passwordConfirm', value: '' });
40 + return;
41 + }
42 + dispatch(register({ username, password }));
43 + };
44 +
45 + useEffect(() => {
46 + dispatch(initializeForm('register'));
47 + }, [dispatch]);
48 + useEffect(() => {
49 + if (authError) {
50 + if (authError.response.status === 409) {
51 + setError('이미 존재하는 계정명입니다.');
52 + return;
53 + }
54 + setError('회원가입 실패');
55 + return;
56 + }
57 +
58 + if (auth) {
59 + console.log('Register Success!');
60 + console.log(auth);
61 + dispatch(check());
62 + }
63 + }, [auth, authError, dispatch]);
64 +
65 + useEffect(() => {
66 + if (user) {
67 + console.log('SUCCESS check API');
68 + history.push('/');
69 + try {
70 + localStorage.setItem('user', JSON.stringify(user));
71 + } catch (e) {
72 + console.log('localStorage is not working');
73 + }
74 + }
75 + }, [history, user]);
76 + return (
77 + <AuthForm
78 + type="register"
79 + form={form}
80 + onChange={onChange}
81 + onSubmit={onSubmit}
82 + error={error}
83 + ></AuthForm>
84 + );
85 +};
86 +
87 +export default withRouter(RegisterForm);
1 +import React from 'react';
2 +import { useSelector, useDispatch } from 'react-redux';
3 +import Header from '../../components/common/Header';
4 +import { logout } from '../../modules/user';
5 +const HeaderContainer = () => {
6 + const { user } = useSelector(({ user }) => ({ user: user.user }));
7 +
8 + const dispatch = useDispatch();
9 + const onLogout = () => {
10 + dispatch(logout());
11 + };
12 + return <Header user={user} onLogout={onLogout} />;
13 +};
14 +export default HeaderContainer;
1 +import React, { useEffect } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import HomeForm from '../../components/home/HomeForm';
5 +import { getPROFILE } from '../../modules/profile';
6 +import { analyzeBJ } from '../../lib/util/analyzeBJ';
7 +const HomeContainer = ({ history }) => {
8 + const dispatch = useDispatch();
9 + const { user, profile } = useSelector(({ user, profile }) => ({
10 + user: user.user,
11 + profile: profile,
12 + }));
13 + useEffect(() => {}, [profile.solvedBJ]);
14 + useEffect(() => {
15 + if (user) {
16 + let username = user.username;
17 + dispatch(getPROFILE({ username }));
18 + }
19 + }, [dispatch, user]);
20 + return <HomeForm />;
21 +};
22 +export default withRouter(HomeContainer);
1 +import React, { useEffect } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import {
5 + changeField,
6 + setBJID,
7 + getPROFILE,
8 + syncBJID,
9 + initializeProfile,
10 + setSLACK,
11 +} from '../../modules/profile';
12 +import SettingForm from '../../components/setting/SettingForm';
13 +
14 +const SettingContainer = ({ history }) => {
15 + const dispatch = useDispatch();
16 + const { user, profile } = useSelector(({ user, profile }) => ({
17 + user: user.user,
18 + profile: profile,
19 + }));
20 +
21 + const onChange = (e) => {
22 + const { value, name } = e.target;
23 + dispatch(
24 + changeField({
25 + key: name,
26 + value: value,
27 + }),
28 + );
29 + };
30 +
31 + const onSyncBJIDSubmit = (e) => {
32 + e.preventDefault();
33 + let username = profile.username;
34 + dispatch(syncBJID({ username }));
35 + };
36 + const onSlackURLSubmit = (e) => {
37 + e.preventDefault();
38 + let username = profile.username;
39 + let slackWebHookURL = profile.slackWebHookURL;
40 + dispatch(setSLACK({ username, slackWebHookURL }));
41 + };
42 +
43 + const onBJIDSubmit = (e) => {
44 + e.preventDefault();
45 + let username = profile.username;
46 + let userBJID = profile.userBJID;
47 +
48 + dispatch(setBJID({ username, userBJID }));
49 + };
50 +
51 + useEffect(() => {
52 + if (!user) {
53 + alert('로그인이 필요합니다 ');
54 + history.push('/');
55 + } else {
56 + let username = user.username;
57 + dispatch(getPROFILE({ username }));
58 + return () => {
59 + dispatch(initializeProfile());
60 + };
61 + }
62 + }, [dispatch, user, history]);
63 +
64 + return (
65 + <SettingForm
66 + type="setting"
67 + onChange={onChange}
68 + onBJIDSubmit={onBJIDSubmit}
69 + onSyncBJIDSubmit={onSyncBJIDSubmit}
70 + onSlackURLSubmit={onSlackURLSubmit}
71 + profile={profile}
72 + ></SettingForm>
73 + );
74 +};
75 +
76 +export default withRouter(SettingContainer);
...@@ -5,6 +5,24 @@ body { ...@@ -5,6 +5,24 @@ body {
5 sans-serif; 5 sans-serif;
6 -webkit-font-smoothing: antialiased; 6 -webkit-font-smoothing: antialiased;
7 -moz-osx-font-smoothing: grayscale; 7 -moz-osx-font-smoothing: grayscale;
8 + box-sizing: border-box;
9 + min-height: 100%;
10 +}
11 +
12 +#root {
13 + min-height: 100%;
14 +}
15 +
16 +html {
17 + height: 100%;
18 +}
19 +
20 +a {
21 + color: inherit;
22 + text-decoration: none;
23 +}
24 +* {
25 + box-sizing: inherit;
8 } 26 }
9 27
10 code { 28 code {
......
...@@ -3,12 +3,41 @@ import ReactDOM from 'react-dom'; ...@@ -3,12 +3,41 @@ import ReactDOM from 'react-dom';
3 import './index.css'; 3 import './index.css';
4 import App from './App'; 4 import App from './App';
5 import * as serviceWorker from './serviceWorker'; 5 import * as serviceWorker from './serviceWorker';
6 +import { BrowserRouter } from 'react-router-dom';
7 +import { Provider } from 'react-redux';
8 +import { createStore, applyMiddleware } from 'redux';
9 +import { composeWithDevTools } from 'redux-devtools-extension';
10 +import createSagaMiddleware from 'redux-saga';
11 +import rootReducer, { rootSaga } from './modules';
12 +import { tempSetUser, check } from './modules/user';
13 +
14 +const sagaMiddleware = createSagaMiddleware();
15 +const store = createStore(
16 + rootReducer,
17 + composeWithDevTools(applyMiddleware(sagaMiddleware)),
18 +);
19 +
20 +function loadUser() {
21 + try {
22 + const user = localStorage.getItem('user');
23 + if (!user) return;
24 +
25 + store.dispatch(tempSetUser(user));
26 + store.dispatch(check());
27 + } catch (e) {
28 + console.log('localStorage is not working');
29 + }
30 +}
31 +sagaMiddleware.run(rootSaga);
32 +loadUser();
6 33
7 ReactDOM.render( 34 ReactDOM.render(
8 - <React.StrictMode> 35 + <Provider store={store}>
36 + <BrowserRouter>
9 <App /> 37 <App />
10 - </React.StrictMode>, 38 + </BrowserRouter>
11 - document.getElementById('root') 39 + </Provider>,
40 + document.getElementById('root'),
12 ); 41 );
13 42
14 // If you want your app to work offline and load faster, you can change 43 // If you want your app to work offline and load faster, you can change
......
1 +import client from './client';
2 +
3 +export const login = ({ username, password }) =>
4 + client.post('api/auth/login', { username, password });
5 +
6 +export const register = ({ username, password }) =>
7 + client.post('api/auth/register', { username, password });
8 +
9 +export const check = () => client.get('api/auth/check');
10 +
11 +export const logout = () => client.post('/api/auth/logout');
1 +import axios from 'axios';
2 +const client = axios.create();
3 +export default client;
1 +import client from './client';
2 +
3 +export const setBJID = ({ username, userBJID }) =>
4 + client.post('api/profile/setprofile', {
5 + username: username,
6 + userBJID: userBJID,
7 + });
8 +export const setPROFILE = (postdata) =>
9 + client.post('api/profile/setprofile', postdata);
10 +export const getPROFILE = ({ username }) =>
11 + client.post('api/profile/getprofile', { username });
12 +
13 +export const syncBJ = ({ username }) =>
14 + client.patch('api/profile/syncBJ', { username });
1 +import { call, put } from 'redux-saga/effects';
2 +import { startLoading, finishLoading } from '../modules/loading';
3 +
4 +export const createRequestActionTypes = (type) => {
5 + const SUCCESS = `${type}_SUCCESS`;
6 + const FAILURE = `${type}_FAILURE`;
7 + return [type, SUCCESS, FAILURE];
8 +};
9 +
10 +export default function createRequestSaga(type, request) {
11 + const SUCCESS = `${type}_SUCCESS`;
12 + const FAILURE = `${type}_FAILURE`;
13 +
14 + return function* (action) {
15 + yield put(startLoading(type));
16 + try {
17 + const response = yield call(request, action.payload);
18 + yield put({
19 + type: SUCCESS,
20 + payload: response.data,
21 + });
22 + } catch (e) {
23 + yield put({
24 + type: FAILURE,
25 + payload: e,
26 + error: true,
27 + });
28 + }
29 + yield put(finishLoading(type));
30 + };
31 +}
1 +// source: https://yeun.github.io/open-color/
2 +
3 +const palette = {
4 + gray: [
5 + '#f8f9fa',
6 + '#f1f3f5',
7 + '#e9ecef',
8 + '#dee2e6',
9 + '#ced4da',
10 + '#adb5bd',
11 + '#868e96',
12 + '#495057',
13 + '#343a40',
14 + '#212529',
15 + ],
16 + cyan: [
17 + '#e3fafc',
18 + '#c5f6fa',
19 + '#99e9f2',
20 + '#66d9e8',
21 + '#3bc9db',
22 + '#22b8cf',
23 + '#15aabf',
24 + '#1098ad',
25 + '#0c8599',
26 + '#0b7285',
27 + ],
28 +};
29 +
30 +export default palette;
1 -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
2 - <g fill="#61DAFB">
3 - <path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
4 - <circle cx="420.9" cy="296.5" r="45.7"/>
5 - <path d="M520.5 78.1z"/>
6 - </g>
7 -</svg>
1 +import { createAction, handleActions } from 'redux-actions';
2 +import produce from 'immer';
3 +import { takeLatest } from 'redux-saga/effects';
4 +import createRequestSaga, {
5 + createRequestActionTypes,
6 +} from '../lib/createRequestSaga';
7 +import * as authAPI from '../lib/api/auth';
8 +const CHANGE_FIELD = 'auth/CHANGE_FIELD';
9 +const INITIALIZE_FORM = 'auth/INITIALIZE_FORM';
10 +
11 +const [REGISTER, REGISTER_SUCCESS, REGISTER_FAILURE] = createRequestActionTypes(
12 + 'auth/REGISTER',
13 +);
14 +
15 +const [LOGIN, LOGIN_SUCCESS, LOGIN_FAILURE] = createRequestActionTypes(
16 + 'auth/REGISTER',
17 +);
18 +
19 +export const changeField = createAction(
20 + CHANGE_FIELD,
21 + ({ form, key, value }) => ({
22 + form,
23 + key,
24 + value,
25 + }),
26 +);
27 +export const initializeForm = createAction(INITIALIZE_FORM, (form) => form);
28 +
29 +const initalState = {
30 + register: {
31 + username: '',
32 + password: '',
33 + passwordConfirm: '',
34 + },
35 + login: {
36 + username: '',
37 + password: '',
38 + },
39 + auth: null,
40 + authError: null,
41 +};
42 +
43 +export const register = createAction(REGISTER, ({ username, password }) => ({
44 + username,
45 + password,
46 +}));
47 +export const login = createAction(LOGIN, ({ username, password }) => ({
48 + username,
49 + password,
50 +}));
51 +
52 +const registerSaga = createRequestSaga(REGISTER, authAPI.register);
53 +const loginSaga = createRequestSaga(LOGIN, authAPI.login);
54 +
55 +export function* authSaga() {
56 + yield takeLatest(REGISTER, registerSaga);
57 + yield takeLatest(LOGIN, loginSaga);
58 +}
59 +
60 +const auth = handleActions(
61 + {
62 + [CHANGE_FIELD]: (state, { payload: { form, key, value } }) =>
63 + produce(state, (draft) => {
64 + draft[form][key] = value;
65 + }),
66 + [INITIALIZE_FORM]: (state, { payload: form }) => ({
67 + ...state,
68 + [form]: initalState[form],
69 + authError: null,
70 + }),
71 + [REGISTER_SUCCESS]: (state, { payload: auth }) => ({
72 + ...state,
73 + authError: null,
74 + auth,
75 + }),
76 + [REGISTER_FAILURE]: (state, { payload: error }) => ({
77 + ...state,
78 + authError: error,
79 + }),
80 + [LOGIN_SUCCESS]: (state, { payload: auth }) => ({
81 + ...state,
82 + authError: null,
83 + auth,
84 + }),
85 + [LOGIN_FAILURE]: (state, { payload: error }) => ({
86 + ...state,
87 + authError: error,
88 + }),
89 + },
90 + initalState,
91 +);
92 +
93 +export default auth;
1 +import { combineReducers } from 'redux';
2 +import { all } from 'redux-saga/effects';
3 +import auth, { authSaga } from './auth';
4 +import loading from './loading';
5 +import user, { userSaga } from './user';
6 +import profile, { profileSaga } from './profile';
7 +
8 +const rootReducer = combineReducers({
9 + auth,
10 + loading,
11 + user,
12 + profile,
13 +});
14 +
15 +export function* rootSaga() {
16 + yield all([authSaga(), userSaga(), profileSaga()]);
17 +}
18 +
19 +export default rootReducer;
1 +import { createAction, handleActions } from 'redux-actions';
2 +
3 +const START_LOADING = 'loading/START_LOADING';
4 +const FINISH_LOADING = 'loading/FINISH_LOADING';
5 +
6 +export const startLoading = createAction(
7 + START_LOADING,
8 + (requestType) => requestType,
9 +);
10 +
11 +export const finishLoading = createAction(
12 + FINISH_LOADING,
13 + (requestType) => requestType,
14 +);
15 +
16 +const initialState = {};
17 +
18 +const loading = handleActions(
19 + {
20 + [START_LOADING]: (state, action) => ({
21 + ...state,
22 + [action.payload]: true,
23 + }),
24 + [FINISH_LOADING]: (state, action) => ({
25 + ...state,
26 + [action.payload]: false,
27 + }),
28 + },
29 + initialState,
30 +);
31 +
32 +export default loading;
1 +import { createAction, handleActions } from 'redux-actions';
2 +import createRequestSaga, {
3 + createRequestActionTypes,
4 +} from '../lib/createRequestSaga';
5 +import produce from 'immer';
6 +import * as profileAPI from '../lib/api/profile';
7 +import { takeLatest } from 'redux-saga/effects';
8 +
9 +const INITIALIZE = 'profile/INITIALIZE';
10 +const CHANGE_FIELD = 'profile/CHANGE_FIELD';
11 +const [SET_BJID, SET_BJID_SUCCESS, SET_BJID_FAILURE] = createRequestActionTypes(
12 + 'profile/SET_BJID',
13 +);
14 +const [
15 + SET_SLACK,
16 + SET_SLACK_SUCCESS,
17 + SET_SLACK_FAILURE,
18 +] = createRequestActionTypes('/profile/SET_SLACK');
19 +const [
20 + GET_PROFILE,
21 + GET_PROFILE_SUCCESS,
22 + GET_PROFILE_FAILURE,
23 +] = createRequestActionTypes('profile/GET_PROFILE');
24 +
25 +const [
26 + SYNC_BJID,
27 + SYNC_BJID_SUCCESS,
28 + SYNC_BJID_FAILURE,
29 +] = createRequestActionTypes('profile/SYNC_BJID');
30 +export const initializeProfile = createAction(INITIALIZE);
31 +export const syncBJID = createAction(SYNC_BJID, ({ username }) => ({
32 + username,
33 +}));
34 +export const setSLACK = createAction(
35 + SET_SLACK,
36 + ({ username, slackWebHookURL }) => ({
37 + username,
38 + slackWebHookURL,
39 + }),
40 +);
41 +export const setBJID = createAction(SET_BJID, ({ username, userBJID }) => ({
42 + username,
43 + userBJID,
44 +}));
45 +
46 +export const changeField = createAction(CHANGE_FIELD, ({ key, value }) => ({
47 + key,
48 + value,
49 +}));
50 +
51 +export const getPROFILE = createAction(GET_PROFILE, ({ username }) => ({
52 + username,
53 +}));
54 +const initialState = {
55 + username: '',
56 + userBJID: '',
57 + solvedBJ: '',
58 + friendList: [],
59 + profileError: '',
60 + slackWebHookURL: '',
61 +};
62 +const getPROFILESaga = createRequestSaga(GET_PROFILE, profileAPI.getPROFILE);
63 +const setBJIDSaga = createRequestSaga(SET_BJID, profileAPI.setBJID);
64 +const setSLACKSaga = createRequestSaga(SET_SLACK, profileAPI.setPROFILE);
65 +const syncBJIDSaga = createRequestSaga(SYNC_BJID, profileAPI.syncBJ);
66 +export function* profileSaga() {
67 + yield takeLatest(SET_BJID, setBJIDSaga);
68 + yield takeLatest(GET_PROFILE, getPROFILESaga);
69 + yield takeLatest(SYNC_BJID, syncBJIDSaga);
70 + yield takeLatest(SET_SLACK, setSLACKSaga);
71 +}
72 +
73 +export default handleActions(
74 + {
75 + [INITIALIZE]: (state) => initialState,
76 + [CHANGE_FIELD]: (state, { payload: { key, value } }) =>
77 + produce(state, (draft) => {
78 + draft[key] = value;
79 + }),
80 + [GET_PROFILE_SUCCESS]: (
81 + state,
82 + {
83 + payload: { username, userBJID, solvedBJ, friendList, slackWebHookURL },
84 + },
85 + ) => ({
86 + ...state,
87 + username: username,
88 + userBJID: userBJID,
89 + solvedBJ: solvedBJ,
90 + friendList: friendList,
91 + profileError: null,
92 + slackWebHookURL: slackWebHookURL,
93 + }),
94 + [GET_PROFILE_FAILURE]: (state, { payload: error }) => ({
95 + ...state,
96 + profileError: error,
97 + }),
98 +
99 + [SET_BJID_SUCCESS]: (state, { payload: { userBJID } }) => ({
100 + ...state,
101 + userBJID: userBJID,
102 + profileError: null,
103 + }),
104 + [SET_BJID_FAILURE]: (state, { payload: error }) => ({
105 + ...state,
106 + profileError: error,
107 + }),
108 + [SET_SLACK_SUCCESS]: (state, { payload: { slackWebHookURL } }) => ({
109 + ...state,
110 + slackWebHookURL: slackWebHookURL,
111 + profileError: null,
112 + }),
113 + [SET_SLACK_FAILURE]: (state, { payload: error }) => ({
114 + ...state,
115 + profileError: error,
116 + }),
117 + [SYNC_BJID_SUCCESS]: (state, { payload: { solvedBJ } }) => ({
118 + ...state,
119 + solvedBJ,
120 + profileError: null,
121 + }),
122 + [SYNC_BJID_FAILURE]: (state, { payload: error }) => ({
123 + ...state,
124 + profileError: error,
125 + }),
126 + },
127 + initialState,
128 +);
1 +import { createAction, handleActions } from 'redux-actions';
2 +import { takeLatest, call } from 'redux-saga/effects';
3 +import * as authAPI from '../lib/api/auth';
4 +import createRequestSaga, {
5 + createRequestActionTypes,
6 +} from '../lib/createRequestSaga';
7 +
8 +const TEMP_SET_USER = 'user/TEMP_SET_USER';
9 +const [CHECK, CHECK_SUCCESS, CHECK_FAILURE] = createRequestActionTypes(
10 + 'user/CHECK',
11 +);
12 +const LOGOUT = 'user/LOGOUT';
13 +
14 +export const tempSetUser = createAction(TEMP_SET_USER, (user) => user);
15 +export const check = createAction(CHECK);
16 +export const logout = createAction(LOGOUT);
17 +const checkSaga = createRequestSaga(CHECK, authAPI.check);
18 +function checkFailureSaga() {
19 + try {
20 + localStorage.removeItem('user');
21 + } catch (e) {
22 + console.log('localStroage is not working');
23 + }
24 +}
25 +function* logoutSaga() {
26 + try {
27 + yield call(authAPI.logout);
28 + console.log('logout');
29 + localStorage.removeItem('user');
30 + } catch (e) {
31 + console.log(e);
32 + }
33 +}
34 +export function* userSaga() {
35 + yield takeLatest(CHECK, checkSaga);
36 + yield takeLatest(CHECK_FAILURE, checkFailureSaga);
37 + yield takeLatest(LOGOUT, logoutSaga);
38 +}
39 +
40 +const initialState = {
41 + user: null,
42 + checkError: null,
43 +};
44 +
45 +export default handleActions(
46 + {
47 + [TEMP_SET_USER]: (state, { payload: user }) => ({
48 + ...state,
49 + user,
50 + }),
51 + [CHECK_SUCCESS]: (state, { payload: user }) => ({
52 + ...state,
53 + user,
54 + checkError: null,
55 + }),
56 + [CHECK_FAILURE]: (state, { payload: error }) => ({
57 + ...state,
58 + user: null,
59 + checkError: error,
60 + }),
61 + [LOGOUT]: (state) => ({
62 + ...state,
63 + user: null,
64 + }),
65 + },
66 + initialState,
67 +);
1 +import React from 'react';
2 +import HeaderContainer from '../containers/common/HeaderContainer';
3 +import HomeContainer from '../containers/home/HomeContainer';
4 +
5 +const HomePage = () => {
6 + return (
7 + <div>
8 + <HeaderContainer />
9 + <HomeContainer />
10 + </div>
11 + );
12 +};
13 +
14 +export default HomePage;
1 +import React from 'react';
2 +import AuthTemplate from '../components/auth/AuthTemplate';
3 +import LoginForm from '../containers/auth/LoginForm';
4 +
5 +const LoginPage = () => {
6 + return (
7 + <AuthTemplate>
8 + <LoginForm type="login" />
9 + </AuthTemplate>
10 + );
11 +};
12 +
13 +export default LoginPage;
1 +import React from 'react';
2 +import AuthTemplate from '../components/auth/AuthTemplate';
3 +import RegisterForm from '../containers/auth/RegisterForm';
4 +
5 +const RegisterPage = () => {
6 + return (
7 + <AuthTemplate>
8 + <RegisterForm type="register" />
9 + </AuthTemplate>
10 + );
11 +};
12 +
13 +export default RegisterPage;
1 +import React from 'react';
2 +import HeaderContainer from '../containers/common/HeaderContainer';
3 +import SettingContainer from '../containers/setting/SettingContainer';
4 +
5 +const SettingPage = () => {
6 + return (
7 + <div>
8 + <HeaderContainer />
9 + <SettingContainer></SettingContainer>
10 + </div>
11 + );
12 +};
13 +
14 +export default SettingPage;
This diff could not be displayed because it is too large.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
19 ## API Table 19 ## API Table
20 20
21 | group | description | method | URL | Detail | Auth | 21 | group | description | method | URL | Detail | Auth |
22 -| ------- | --------------------------- | ------ | ------------------------ | -------- | --------- | 22 +| ------- | --------------------------- | --------- | ------------------------ | -------- | --------- |
23 | user | 유저 등록 | POST | api/user | 바로가기 | JWT Token | 23 | user | 유저 등록 | POST | api/user | 바로가기 | JWT Token |
24 | user | 유저 삭제 | DELETE | api/user:id | 바로가기 | JWT Token | 24 | user | 유저 삭제 | DELETE | api/user:id | 바로가기 | JWT Token |
25 | user | 특정 유저 조회 | GET | api/user:id | 바로가기 | None | 25 | user | 특정 유저 조회 | GET | api/user:id | 바로가기 | None |
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
29 | profile | 유저가 푼 문제 조회(백준) | GET | api/profile/solvedBJ:id | 바로가기 | None | 29 | profile | 유저가 푼 문제 조회(백준) | GET | api/profile/solvedBJ:id | 바로가기 | None |
30 | profile | 유저가 푼 문제 동기화(백준) | PATCH | api/profile/syncBJ | 바로가기 | None | 30 | profile | 유저가 푼 문제 동기화(백준) | PATCH | api/profile/syncBJ | 바로가기 | None |
31 | profile | 유저 정보 수정 | POST | api/profile/setprofile | 바로가기 | JWT TOKEN | 31 | profile | 유저 정보 수정 | POST | api/profile/setprofile | 바로가기 | JWT TOKEN |
32 +| profile | 유저 정보 받아오기 | POST | api/profile/getprofile | 바로가기 | JWT |
32 | profile | 추천 문제 조회 | GET | api/profile/recommend:id | 바로가기 | None | 33 | profile | 추천 문제 조회 | GET | api/profile/recommend:id | 바로가기 | None |
33 -| notify | 슬랙 메시지 전송 요청 | POST | api/notify/slack | 바로가기 | Jwt Token | 34 +| notify | 슬랙 메시지 전송 요청 | POST | api/notify/ |
35 +| slack | 바로가기 | Jwt Token |
34 | auth | 로그인 | POST | api/auth/login | 바로가기 | None | 36 | auth | 로그인 | POST | api/auth/login | 바로가기 | None |
35 -| auth | 로그아웃 | GET | api/auth/logout | 바로가기 | JWT Token | 37 +| auth | 로그아웃 | POST | api/auth/logout | 바로가기 | JWT Token |
36 | auth | 회원가입 | POST | api/auth/register | 바로가기 | None | 38 | auth | 회원가입 | POST | api/auth/register | 바로가기 | None |
37 | auth | 로그인 확인 | GET | api/auth/check | 바로가기 | None | 39 | auth | 로그인 확인 | GET | api/auth/check | 바로가기 | None |
......
This diff could not be displayed because it is too large.
...@@ -5,6 +5,10 @@ const mongoose = require("mongoose"); ...@@ -5,6 +5,10 @@ const mongoose = require("mongoose");
5 const fs = require("fs"); 5 const fs = require("fs");
6 const morgan = require("koa-morgan"); 6 const morgan = require("koa-morgan");
7 const jwtMiddleware = require("./src/lib/jwtMiddleware"); 7 const jwtMiddleware = require("./src/lib/jwtMiddleware");
8 +const api = require("./src/api");
9 +
10 +require("dotenv").config();
11 +
8 const app = new Koa(); 12 const app = new Koa();
9 const router = new Router(); 13 const router = new Router();
10 const accessLogStream = fs.createWriteStream(__dirname + "/access.log", { 14 const accessLogStream = fs.createWriteStream(__dirname + "/access.log", {
...@@ -14,7 +18,6 @@ require("dotenv").config(); ...@@ -14,7 +18,6 @@ require("dotenv").config();
14 app.use(bodyParser()); 18 app.use(bodyParser());
15 app.use(jwtMiddleware); 19 app.use(jwtMiddleware);
16 app.use(morgan("combined", { stream: accessLogStream })); 20 app.use(morgan("combined", { stream: accessLogStream }));
17 -const api = require("./src/api");
18 const { SERVER_PORT, MONGO_URL } = process.env; 21 const { SERVER_PORT, MONGO_URL } = process.env;
19 22
20 router.use("/api", api.routes()); 23 router.use("/api", api.routes());
...@@ -32,6 +35,7 @@ mongoose ...@@ -32,6 +35,7 @@ mongoose
32 .catch((e) => { 35 .catch((e) => {
33 console.log(e); 36 console.log(e);
34 }); 37 });
38 +
35 app.listen(SERVER_PORT, () => { 39 app.listen(SERVER_PORT, () => {
36 console.log("Server is running on port", process.env.SERVER_PORT); 40 console.log("Server is running on port", process.env.SERVER_PORT);
37 }); 41 });
......
...@@ -198,11 +198,26 @@ ...@@ -198,11 +198,26 @@
198 "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", 198 "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
199 "dev": true 199 "dev": true
200 }, 200 },
201 + "agent-base": {
202 + "version": "2.1.1",
203 + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.1.1.tgz",
204 + "integrity": "sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc=",
205 + "requires": {
206 + "extend": "~3.0.0",
207 + "semver": "~5.0.1"
208 + },
209 + "dependencies": {
210 + "semver": {
211 + "version": "5.0.3",
212 + "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz",
213 + "integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no="
214 + }
215 + }
216 + },
201 "ajv": { 217 "ajv": {
202 "version": "6.12.2", 218 "version": "6.12.2",
203 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", 219 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz",
204 "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", 220 "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==",
205 - "dev": true,
206 "requires": { 221 "requires": {
207 "fast-deep-equal": "^3.1.1", 222 "fast-deep-equal": "^3.1.1",
208 "fast-json-stable-stringify": "^2.0.0", 223 "fast-json-stable-stringify": "^2.0.0",
...@@ -323,12 +338,45 @@ ...@@ -323,12 +338,45 @@
323 "sprintf-js": "~1.0.2" 338 "sprintf-js": "~1.0.2"
324 } 339 }
325 }, 340 },
341 + "asn1": {
342 + "version": "0.2.4",
343 + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
344 + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
345 + "requires": {
346 + "safer-buffer": "~2.1.0"
347 + }
348 + },
349 + "assert-plus": {
350 + "version": "1.0.0",
351 + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
352 + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
353 + },
326 "astral-regex": { 354 "astral-regex": {
327 "version": "1.0.0", 355 "version": "1.0.0",
328 "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", 356 "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
329 "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", 357 "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
330 "dev": true 358 "dev": true
331 }, 359 },
360 + "async": {
361 + "version": "1.5.2",
362 + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
363 + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
364 + },
365 + "asynckit": {
366 + "version": "0.4.0",
367 + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
368 + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
369 + },
370 + "aws-sign2": {
371 + "version": "0.7.0",
372 + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
373 + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
374 + },
375 + "aws4": {
376 + "version": "1.10.0",
377 + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz",
378 + "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA=="
379 + },
332 "axios": { 380 "axios": {
333 "version": "0.19.2", 381 "version": "0.19.2",
334 "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", 382 "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
...@@ -373,6 +421,14 @@ ...@@ -373,6 +421,14 @@
373 "node-pre-gyp": "0.14.0" 421 "node-pre-gyp": "0.14.0"
374 } 422 }
375 }, 423 },
424 + "bcrypt-pbkdf": {
425 + "version": "1.0.2",
426 + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
427 + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
428 + "requires": {
429 + "tweetnacl": "^0.14.3"
430 + }
431 + },
376 "binary-extensions": { 432 "binary-extensions": {
377 "version": "2.0.0", 433 "version": "2.0.0",
378 "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", 434 "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz",
...@@ -517,6 +573,11 @@ ...@@ -517,6 +573,11 @@
517 "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", 573 "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
518 "dev": true 574 "dev": true
519 }, 575 },
576 + "caseless": {
577 + "version": "0.12.0",
578 + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
579 + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
580 + },
520 "chalk": { 581 "chalk": {
521 "version": "3.0.0", 582 "version": "3.0.0",
522 "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", 583 "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
...@@ -670,6 +731,19 @@ ...@@ -670,6 +731,19 @@
670 "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 731 "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
671 "dev": true 732 "dev": true
672 }, 733 },
734 + "colors": {
735 + "version": "1.0.3",
736 + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
737 + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs="
738 + },
739 + "combined-stream": {
740 + "version": "1.0.8",
741 + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
742 + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
743 + "requires": {
744 + "delayed-stream": "~1.0.0"
745 + }
746 + },
673 "concat-map": { 747 "concat-map": {
674 "version": "0.0.1", 748 "version": "0.0.1",
675 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 749 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
...@@ -752,6 +826,15 @@ ...@@ -752,6 +826,15 @@
752 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 826 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
753 "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 827 "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
754 }, 828 },
829 + "cron-parser": {
830 + "version": "2.15.0",
831 + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.15.0.tgz",
832 + "integrity": "sha512-rMFkrQw8+oG5OuwjiXesup4KeIlEG/IU82YtG4xyAHbO5jhKmYaHPp/ZNhq9+7TjSJ65E3zV3kQPUbmXSff2/g==",
833 + "requires": {
834 + "is-nan": "^1.3.0",
835 + "moment-timezone": "^0.5.31"
836 + }
837 + },
755 "cross-spawn": { 838 "cross-spawn": {
756 "version": "7.0.3", 839 "version": "7.0.3",
757 "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", 840 "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
...@@ -785,6 +868,19 @@ ...@@ -785,6 +868,19 @@
785 "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", 868 "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz",
786 "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" 869 "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg=="
787 }, 870 },
871 + "cycle": {
872 + "version": "1.0.3",
873 + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
874 + "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI="
875 + },
876 + "dashdash": {
877 + "version": "1.14.1",
878 + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
879 + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
880 + "requires": {
881 + "assert-plus": "^1.0.0"
882 + }
883 + },
788 "debug": { 884 "debug": {
789 "version": "2.6.9", 885 "version": "2.6.9",
790 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 886 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
...@@ -831,6 +927,19 @@ ...@@ -831,6 +927,19 @@
831 "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", 927 "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==",
832 "dev": true 928 "dev": true
833 }, 929 },
930 + "define-properties": {
931 + "version": "1.1.3",
932 + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
933 + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
934 + "requires": {
935 + "object-keys": "^1.0.12"
936 + }
937 + },
938 + "delayed-stream": {
939 + "version": "1.0.0",
940 + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
941 + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
942 + },
834 "delegates": { 943 "delegates": {
835 "version": "1.0.0", 944 "version": "1.0.0",
836 "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 945 "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
...@@ -916,6 +1025,15 @@ ...@@ -916,6 +1025,15 @@
916 "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", 1025 "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=",
917 "dev": true 1026 "dev": true
918 }, 1027 },
1028 + "ecc-jsbn": {
1029 + "version": "0.1.2",
1030 + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
1031 + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
1032 + "requires": {
1033 + "jsbn": "~0.1.0",
1034 + "safer-buffer": "^2.1.0"
1035 + }
1036 + },
919 "ecdsa-sig-formatter": { 1037 "ecdsa-sig-formatter": {
920 "version": "1.0.11", 1038 "version": "1.0.11",
921 "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 1039 "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
...@@ -1170,6 +1288,16 @@ ...@@ -1170,6 +1288,16 @@
1170 "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", 1288 "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
1171 "dev": true 1289 "dev": true
1172 }, 1290 },
1291 + "eventemitter3": {
1292 + "version": "1.2.0",
1293 + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz",
1294 + "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg="
1295 + },
1296 + "extend": {
1297 + "version": "3.0.2",
1298 + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
1299 + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
1300 + },
1173 "external-editor": { 1301 "external-editor": {
1174 "version": "3.1.0", 1302 "version": "3.1.0",
1175 "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", 1303 "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
...@@ -1181,17 +1309,25 @@ ...@@ -1181,17 +1309,25 @@
1181 "tmp": "^0.0.33" 1309 "tmp": "^0.0.33"
1182 } 1310 }
1183 }, 1311 },
1312 + "extsprintf": {
1313 + "version": "1.3.0",
1314 + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
1315 + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
1316 + },
1317 + "eyes": {
1318 + "version": "0.1.8",
1319 + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
1320 + "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
1321 + },
1184 "fast-deep-equal": { 1322 "fast-deep-equal": {
1185 "version": "3.1.3", 1323 "version": "3.1.3",
1186 "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", 1324 "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
1187 - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", 1325 + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
1188 - "dev": true
1189 }, 1326 },
1190 "fast-json-stable-stringify": { 1327 "fast-json-stable-stringify": {
1191 "version": "2.1.0", 1328 "version": "2.1.0",
1192 "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 1329 "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
1193 - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", 1330 + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
1194 - "dev": true
1195 }, 1331 },
1196 "fast-levenshtein": { 1332 "fast-levenshtein": {
1197 "version": "2.0.6", 1333 "version": "2.0.6",
...@@ -1277,6 +1413,21 @@ ...@@ -1277,6 +1413,21 @@
1277 } 1413 }
1278 } 1414 }
1279 }, 1415 },
1416 + "forever-agent": {
1417 + "version": "0.6.1",
1418 + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
1419 + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
1420 + },
1421 + "form-data": {
1422 + "version": "2.3.3",
1423 + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
1424 + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
1425 + "requires": {
1426 + "asynckit": "^0.4.0",
1427 + "combined-stream": "^1.0.6",
1428 + "mime-types": "^2.1.12"
1429 + }
1430 + },
1280 "fresh": { 1431 "fresh": {
1281 "version": "0.5.2", 1432 "version": "0.5.2",
1282 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 1433 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
...@@ -1367,6 +1518,14 @@ ...@@ -1367,6 +1518,14 @@
1367 "pump": "^3.0.0" 1518 "pump": "^3.0.0"
1368 } 1519 }
1369 }, 1520 },
1521 + "getpass": {
1522 + "version": "0.1.7",
1523 + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
1524 + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
1525 + "requires": {
1526 + "assert-plus": "^1.0.0"
1527 + }
1528 + },
1370 "glob": { 1529 "glob": {
1371 "version": "7.1.6", 1530 "version": "7.1.6",
1372 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 1531 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
...@@ -1432,6 +1591,20 @@ ...@@ -1432,6 +1591,20 @@
1432 "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", 1591 "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
1433 "dev": true 1592 "dev": true
1434 }, 1593 },
1594 + "har-schema": {
1595 + "version": "2.0.0",
1596 + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
1597 + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
1598 + },
1599 + "har-validator": {
1600 + "version": "5.1.3",
1601 + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
1602 + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
1603 + "requires": {
1604 + "ajv": "^6.5.5",
1605 + "har-schema": "^2.0.0"
1606 + }
1607 + },
1435 "has-flag": { 1608 "has-flag": {
1436 "version": "3.0.0", 1609 "version": "3.0.0",
1437 "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 1610 "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
...@@ -1513,6 +1686,26 @@ ...@@ -1513,6 +1686,26 @@
1513 } 1686 }
1514 } 1687 }
1515 }, 1688 },
1689 + "http-signature": {
1690 + "version": "1.2.0",
1691 + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
1692 + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
1693 + "requires": {
1694 + "assert-plus": "^1.0.0",
1695 + "jsprim": "^1.2.2",
1696 + "sshpk": "^1.7.0"
1697 + }
1698 + },
1699 + "https-proxy-agent": {
1700 + "version": "1.0.0",
1701 + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
1702 + "integrity": "sha1-NffabEjOTdv6JkiRrFk+5f+GceY=",
1703 + "requires": {
1704 + "agent-base": "2",
1705 + "debug": "2",
1706 + "extend": "3"
1707 + }
1708 + },
1516 "iconv": { 1709 "iconv": {
1517 "version": "3.0.0", 1710 "version": "3.0.0",
1518 "resolved": "https://registry.npmjs.org/iconv/-/iconv-3.0.0.tgz", 1711 "resolved": "https://registry.npmjs.org/iconv/-/iconv-3.0.0.tgz",
...@@ -1669,6 +1862,14 @@ ...@@ -1669,6 +1862,14 @@
1669 "is-path-inside": "^3.0.1" 1862 "is-path-inside": "^3.0.1"
1670 } 1863 }
1671 }, 1864 },
1865 + "is-nan": {
1866 + "version": "1.3.0",
1867 + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.0.tgz",
1868 + "integrity": "sha512-z7bbREymOqt2CCaZVly8aC4ML3Xhfi0ekuOnjO2L8vKdl+CttdVoGZQhd4adMFAsxQ5VeRVwORs4tU8RH+HFtQ==",
1869 + "requires": {
1870 + "define-properties": "^1.1.3"
1871 + }
1872 + },
1672 "is-npm": { 1873 "is-npm": {
1673 "version": "4.0.0", 1874 "version": "4.0.0",
1674 "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-4.0.0.tgz", 1875 "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-4.0.0.tgz",
...@@ -1696,8 +1897,7 @@ ...@@ -1696,8 +1897,7 @@
1696 "is-typedarray": { 1897 "is-typedarray": {
1697 "version": "1.0.0", 1898 "version": "1.0.0",
1698 "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 1899 "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
1699 - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", 1900 + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
1700 - "dev": true
1701 }, 1901 },
1702 "is-yarn-global": { 1902 "is-yarn-global": {
1703 "version": "0.3.0", 1903 "version": "0.3.0",
...@@ -1724,6 +1924,11 @@ ...@@ -1724,6 +1924,11 @@
1724 "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", 1924 "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
1725 "dev": true 1925 "dev": true
1726 }, 1926 },
1927 + "isstream": {
1928 + "version": "0.1.2",
1929 + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
1930 + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
1931 + },
1727 "joi": { 1932 "joi": {
1728 "version": "14.3.1", 1933 "version": "14.3.1",
1729 "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.1.tgz", 1934 "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.1.tgz",
...@@ -1750,6 +1955,11 @@ ...@@ -1750,6 +1955,11 @@
1750 "esprima": "^4.0.0" 1955 "esprima": "^4.0.0"
1751 } 1956 }
1752 }, 1957 },
1958 + "jsbn": {
1959 + "version": "0.1.1",
1960 + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
1961 + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
1962 + },
1753 "jsesc": { 1963 "jsesc": {
1754 "version": "2.5.2", 1964 "version": "2.5.2",
1755 "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", 1965 "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
...@@ -1762,11 +1972,15 @@ ...@@ -1762,11 +1972,15 @@
1762 "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", 1972 "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=",
1763 "dev": true 1973 "dev": true
1764 }, 1974 },
1975 + "json-schema": {
1976 + "version": "0.2.3",
1977 + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
1978 + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
1979 + },
1765 "json-schema-traverse": { 1980 "json-schema-traverse": {
1766 "version": "0.4.1", 1981 "version": "0.4.1",
1767 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 1982 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
1768 - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", 1983 + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
1769 - "dev": true
1770 }, 1984 },
1771 "json-stable-stringify-without-jsonify": { 1985 "json-stable-stringify-without-jsonify": {
1772 "version": "1.0.1", 1986 "version": "1.0.1",
...@@ -1774,6 +1988,11 @@ ...@@ -1774,6 +1988,11 @@
1774 "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", 1988 "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
1775 "dev": true 1989 "dev": true
1776 }, 1990 },
1991 + "json-stringify-safe": {
1992 + "version": "5.0.1",
1993 + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
1994 + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
1995 + },
1777 "jsonwebtoken": { 1996 "jsonwebtoken": {
1778 "version": "8.5.1", 1997 "version": "8.5.1",
1779 "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", 1998 "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
...@@ -1791,6 +2010,17 @@ ...@@ -1791,6 +2010,17 @@
1791 "semver": "^5.6.0" 2010 "semver": "^5.6.0"
1792 } 2011 }
1793 }, 2012 },
2013 + "jsprim": {
2014 + "version": "1.4.1",
2015 + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
2016 + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
2017 + "requires": {
2018 + "assert-plus": "1.0.0",
2019 + "extsprintf": "1.3.0",
2020 + "json-schema": "0.2.3",
2021 + "verror": "1.10.0"
2022 + }
2023 + },
1794 "jwa": { 2024 "jwa": {
1795 "version": "1.4.1", 2025 "version": "1.4.1",
1796 "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 2026 "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
...@@ -2029,6 +2259,11 @@ ...@@ -2029,6 +2259,11 @@
2029 "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", 2259 "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
2030 "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" 2260 "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
2031 }, 2261 },
2262 + "long-timeout": {
2263 + "version": "0.1.1",
2264 + "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz",
2265 + "integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ="
2266 + },
2032 "lowercase-keys": { 2267 "lowercase-keys": {
2033 "version": "1.0.1", 2268 "version": "1.0.1",
2034 "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", 2269 "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
...@@ -2131,6 +2366,19 @@ ...@@ -2131,6 +2366,19 @@
2131 "minimist": "^1.2.5" 2366 "minimist": "^1.2.5"
2132 } 2367 }
2133 }, 2368 },
2369 + "moment": {
2370 + "version": "2.27.0",
2371 + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
2372 + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ=="
2373 + },
2374 + "moment-timezone": {
2375 + "version": "0.5.31",
2376 + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.31.tgz",
2377 + "integrity": "sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA==",
2378 + "requires": {
2379 + "moment": ">= 2.9.0"
2380 + }
2381 + },
2134 "mongodb": { 2382 "mongodb": {
2135 "version": "3.5.8", 2383 "version": "3.5.8",
2136 "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.5.8.tgz", 2384 "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.5.8.tgz",
...@@ -2282,6 +2530,16 @@ ...@@ -2282,6 +2530,16 @@
2282 "tar": "^4.4.2" 2530 "tar": "^4.4.2"
2283 } 2531 }
2284 }, 2532 },
2533 + "node-schedule": {
2534 + "version": "1.3.2",
2535 + "resolved": "https://registry.npmjs.org/node-schedule/-/node-schedule-1.3.2.tgz",
2536 + "integrity": "sha512-GIND2pHMHiReSZSvS6dpZcDH7pGPGFfWBIEud6S00Q8zEIzAs9ommdyRK1ZbQt8y1LyZsJYZgPnyi7gpU2lcdw==",
2537 + "requires": {
2538 + "cron-parser": "^2.7.3",
2539 + "long-timeout": "0.1.1",
2540 + "sorted-array-functions": "^1.0.0"
2541 + }
2542 + },
2285 "nodemon": { 2543 "nodemon": {
2286 "version": "2.0.4", 2544 "version": "2.0.4",
2287 "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.4.tgz", 2545 "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.4.tgz",
...@@ -2379,11 +2637,21 @@ ...@@ -2379,11 +2637,21 @@
2379 "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", 2637 "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
2380 "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" 2638 "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
2381 }, 2639 },
2640 + "oauth-sign": {
2641 + "version": "0.9.0",
2642 + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
2643 + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
2644 + },
2382 "object-assign": { 2645 "object-assign": {
2383 "version": "4.1.1", 2646 "version": "4.1.1",
2384 "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 2647 "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
2385 "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 2648 "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
2386 }, 2649 },
2650 + "object-keys": {
2651 + "version": "1.1.1",
2652 + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
2653 + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
2654 + },
2387 "on-finished": { 2655 "on-finished": {
2388 "version": "2.3.0", 2656 "version": "2.3.0",
2389 "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 2657 "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
...@@ -2433,6 +2701,11 @@ ...@@ -2433,6 +2701,11 @@
2433 "word-wrap": "^1.2.3" 2701 "word-wrap": "^1.2.3"
2434 } 2702 }
2435 }, 2703 },
2704 + "options": {
2705 + "version": "0.0.6",
2706 + "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz",
2707 + "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8="
2708 + },
2436 "os-homedir": { 2709 "os-homedir": {
2437 "version": "1.0.2", 2710 "version": "1.0.2",
2438 "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", 2711 "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
...@@ -2526,6 +2799,11 @@ ...@@ -2526,6 +2799,11 @@
2526 "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 2799 "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
2527 "dev": true 2800 "dev": true
2528 }, 2801 },
2802 + "performance-now": {
2803 + "version": "2.1.0",
2804 + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
2805 + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
2806 + },
2529 "picomatch": { 2807 "picomatch": {
2530 "version": "2.2.2", 2808 "version": "2.2.2",
2531 "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", 2809 "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
...@@ -2560,6 +2838,11 @@ ...@@ -2560,6 +2838,11 @@
2560 "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", 2838 "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
2561 "dev": true 2839 "dev": true
2562 }, 2840 },
2841 + "psl": {
2842 + "version": "1.8.0",
2843 + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
2844 + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
2845 + },
2563 "pstree.remy": { 2846 "pstree.remy": {
2564 "version": "1.1.8", 2847 "version": "1.1.8",
2565 "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", 2848 "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
...@@ -2676,6 +2959,51 @@ ...@@ -2676,6 +2959,51 @@
2676 "rc": "^1.2.8" 2959 "rc": "^1.2.8"
2677 } 2960 }
2678 }, 2961 },
2962 + "request": {
2963 + "version": "2.88.2",
2964 + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
2965 + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==",
2966 + "requires": {
2967 + "aws-sign2": "~0.7.0",
2968 + "aws4": "^1.8.0",
2969 + "caseless": "~0.12.0",
2970 + "combined-stream": "~1.0.6",
2971 + "extend": "~3.0.2",
2972 + "forever-agent": "~0.6.1",
2973 + "form-data": "~2.3.2",
2974 + "har-validator": "~5.1.3",
2975 + "http-signature": "~1.2.0",
2976 + "is-typedarray": "~1.0.0",
2977 + "isstream": "~0.1.2",
2978 + "json-stringify-safe": "~5.0.1",
2979 + "mime-types": "~2.1.19",
2980 + "oauth-sign": "~0.9.0",
2981 + "performance-now": "^2.1.0",
2982 + "qs": "~6.5.2",
2983 + "safe-buffer": "^5.1.2",
2984 + "tough-cookie": "~2.5.0",
2985 + "tunnel-agent": "^0.6.0",
2986 + "uuid": "^3.3.2"
2987 + },
2988 + "dependencies": {
2989 + "qs": {
2990 + "version": "6.5.2",
2991 + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
2992 + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
2993 + }
2994 + }
2995 + },
2996 + "requestretry": {
2997 + "version": "1.13.0",
2998 + "resolved": "https://registry.npmjs.org/requestretry/-/requestretry-1.13.0.tgz",
2999 + "integrity": "sha512-Lmh9qMvnQXADGAQxsXHP4rbgO6pffCfuR8XUBdP9aitJcLQJxhp7YZK4xAVYXnPJ5E52mwrfiKQtKonPL8xsmg==",
3000 + "requires": {
3001 + "extend": "^3.0.0",
3002 + "lodash": "^4.15.0",
3003 + "request": "^2.74.0",
3004 + "when": "^3.7.7"
3005 + }
3006 + },
2679 "require_optional": { 3007 "require_optional": {
2680 "version": "1.0.1", 3008 "version": "1.0.1",
2681 "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", 3009 "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
...@@ -2726,6 +3054,11 @@ ...@@ -2726,6 +3054,11 @@
2726 "signal-exit": "^3.0.2" 3054 "signal-exit": "^3.0.2"
2727 } 3055 }
2728 }, 3056 },
3057 + "retry": {
3058 + "version": "0.8.0",
3059 + "resolved": "https://registry.npmjs.org/retry/-/retry-0.8.0.tgz",
3060 + "integrity": "sha1-I2dijcDtskex6rZJ3FOshiisLV8="
3061 + },
2729 "rimraf": { 3062 "rimraf": {
2730 "version": "2.7.1", 3063 "version": "2.7.1",
2731 "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", 3064 "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
...@@ -2830,6 +3163,38 @@ ...@@ -2830,6 +3163,38 @@
2830 "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", 3163 "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
2831 "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" 3164 "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA=="
2832 }, 3165 },
3166 + "slack-client": {
3167 + "version": "2.0.6",
3168 + "resolved": "https://registry.npmjs.org/slack-client/-/slack-client-2.0.6.tgz",
3169 + "integrity": "sha1-eOuJ9/UnYg4UXM17HY0WvWcLs4M=",
3170 + "requires": {
3171 + "async": "^1.5.0",
3172 + "eventemitter3": "^1.1.1",
3173 + "https-proxy-agent": "^1.0.0",
3174 + "inherits": "^2.0.1",
3175 + "lodash": "^3.10.1",
3176 + "request": "^2.64.0",
3177 + "retry": "^0.8.0",
3178 + "url-join": "0.0.1",
3179 + "winston": "^2.1.1",
3180 + "ws": "^1.0.1"
3181 + },
3182 + "dependencies": {
3183 + "lodash": {
3184 + "version": "3.10.1",
3185 + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
3186 + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y="
3187 + }
3188 + }
3189 + },
3190 + "slack-node": {
3191 + "version": "0.1.8",
3192 + "resolved": "https://registry.npmjs.org/slack-node/-/slack-node-0.1.8.tgz",
3193 + "integrity": "sha1-zamN6GgUhbMB3GdC3cOJcRf600k=",
3194 + "requires": {
3195 + "requestretry": "^1.2.2"
3196 + }
3197 + },
2833 "slice-ansi": { 3198 "slice-ansi": {
2834 "version": "2.1.0", 3199 "version": "2.1.0",
2835 "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", 3200 "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
...@@ -2854,6 +3219,11 @@ ...@@ -2854,6 +3219,11 @@
2854 "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", 3219 "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
2855 "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" 3220 "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
2856 }, 3221 },
3222 + "sorted-array-functions": {
3223 + "version": "1.2.0",
3224 + "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.2.0.tgz",
3225 + "integrity": "sha512-sWpjPhIZJtqO77GN+LD8dDsDKcWZ9GCOJNqKzi1tvtjGIzwfoyuRH8S0psunmc6Z5P+qfDqztSbwYR5X/e1UTg=="
3226 + },
2857 "source-map": { 3227 "source-map": {
2858 "version": "0.5.7", 3228 "version": "0.5.7",
2859 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", 3229 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
...@@ -2875,6 +3245,27 @@ ...@@ -2875,6 +3245,27 @@
2875 "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 3245 "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
2876 "dev": true 3246 "dev": true
2877 }, 3247 },
3248 + "sshpk": {
3249 + "version": "1.16.1",
3250 + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
3251 + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
3252 + "requires": {
3253 + "asn1": "~0.2.3",
3254 + "assert-plus": "^1.0.0",
3255 + "bcrypt-pbkdf": "^1.0.0",
3256 + "dashdash": "^1.12.0",
3257 + "ecc-jsbn": "~0.1.1",
3258 + "getpass": "^0.1.1",
3259 + "jsbn": "~0.1.0",
3260 + "safer-buffer": "^2.0.2",
3261 + "tweetnacl": "~0.14.0"
3262 + }
3263 + },
3264 + "stack-trace": {
3265 + "version": "0.0.10",
3266 + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
3267 + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
3268 + },
2878 "statuses": { 3269 "statuses": {
2879 "version": "1.5.0", 3270 "version": "1.5.0",
2880 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 3271 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
...@@ -3078,6 +3469,15 @@ ...@@ -3078,6 +3469,15 @@
3078 } 3469 }
3079 } 3470 }
3080 }, 3471 },
3472 + "tough-cookie": {
3473 + "version": "2.5.0",
3474 + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
3475 + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
3476 + "requires": {
3477 + "psl": "^1.1.28",
3478 + "punycode": "^2.1.1"
3479 + }
3480 + },
3081 "tslib": { 3481 "tslib": {
3082 "version": "1.13.0", 3482 "version": "1.13.0",
3083 "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", 3483 "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
...@@ -3089,6 +3489,19 @@ ...@@ -3089,6 +3489,19 @@
3089 "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz", 3489 "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz",
3090 "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==" 3490 "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA=="
3091 }, 3491 },
3492 + "tunnel-agent": {
3493 + "version": "0.6.0",
3494 + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
3495 + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
3496 + "requires": {
3497 + "safe-buffer": "^5.0.1"
3498 + }
3499 + },
3500 + "tweetnacl": {
3501 + "version": "0.14.5",
3502 + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
3503 + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
3504 + },
3092 "type-check": { 3505 "type-check": {
3093 "version": "0.4.0", 3506 "version": "0.4.0",
3094 "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", 3507 "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
...@@ -3122,6 +3535,11 @@ ...@@ -3122,6 +3535,11 @@
3122 "is-typedarray": "^1.0.0" 3535 "is-typedarray": "^1.0.0"
3123 } 3536 }
3124 }, 3537 },
3538 + "ultron": {
3539 + "version": "1.0.2",
3540 + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz",
3541 + "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po="
3542 + },
3125 "undefsafe": { 3543 "undefsafe": {
3126 "version": "2.0.3", 3544 "version": "2.0.3",
3127 "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.3.tgz", 3545 "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.3.tgz",
...@@ -3170,11 +3588,15 @@ ...@@ -3170,11 +3588,15 @@
3170 "version": "4.2.2", 3588 "version": "4.2.2",
3171 "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", 3589 "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
3172 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 3590 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
3173 - "dev": true,
3174 "requires": { 3591 "requires": {
3175 "punycode": "^2.1.0" 3592 "punycode": "^2.1.0"
3176 } 3593 }
3177 }, 3594 },
3595 + "url-join": {
3596 + "version": "0.0.1",
3597 + "resolved": "https://registry.npmjs.org/url-join/-/url-join-0.0.1.tgz",
3598 + "integrity": "sha1-HbSK1CLTQCRpqH99l73r/k+x48g="
3599 + },
3178 "url-parse-lax": { 3600 "url-parse-lax": {
3179 "version": "3.0.0", 3601 "version": "3.0.0",
3180 "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", 3602 "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz",
...@@ -3204,6 +3626,11 @@ ...@@ -3204,6 +3626,11 @@
3204 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 3626 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
3205 "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 3627 "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
3206 }, 3628 },
3629 + "uuid": {
3630 + "version": "3.4.0",
3631 + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
3632 + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
3633 + },
3207 "v8-compile-cache": { 3634 "v8-compile-cache": {
3208 "version": "2.1.0", 3635 "version": "2.1.0",
3209 "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", 3636 "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
...@@ -3215,11 +3642,26 @@ ...@@ -3215,11 +3642,26 @@
3215 "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 3642 "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
3216 "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 3643 "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
3217 }, 3644 },
3645 + "verror": {
3646 + "version": "1.10.0",
3647 + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
3648 + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
3649 + "requires": {
3650 + "assert-plus": "^1.0.0",
3651 + "core-util-is": "1.0.2",
3652 + "extsprintf": "^1.2.0"
3653 + }
3654 + },
3218 "voca": { 3655 "voca": {
3219 "version": "1.4.0", 3656 "version": "1.4.0",
3220 "resolved": "https://registry.npmjs.org/voca/-/voca-1.4.0.tgz", 3657 "resolved": "https://registry.npmjs.org/voca/-/voca-1.4.0.tgz",
3221 "integrity": "sha512-8Xz4H3vhYRGbFupLtl6dHwMx0ojUcjt0HYkqZ9oBCfipd/5mD7Md58m2/dq7uPuZU/0T3Gb1m66KS9jn+I+14Q==" 3658 "integrity": "sha512-8Xz4H3vhYRGbFupLtl6dHwMx0ojUcjt0HYkqZ9oBCfipd/5mD7Md58m2/dq7uPuZU/0T3Gb1m66KS9jn+I+14Q=="
3222 }, 3659 },
3660 + "when": {
3661 + "version": "3.7.8",
3662 + "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz",
3663 + "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I="
3664 + },
3223 "which": { 3665 "which": {
3224 "version": "2.0.2", 3666 "version": "2.0.2",
3225 "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", 3667 "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
...@@ -3275,6 +3717,26 @@ ...@@ -3275,6 +3717,26 @@
3275 "string-width": "^4.0.0" 3717 "string-width": "^4.0.0"
3276 } 3718 }
3277 }, 3719 },
3720 + "winston": {
3721 + "version": "2.4.5",
3722 + "resolved": "https://registry.npmjs.org/winston/-/winston-2.4.5.tgz",
3723 + "integrity": "sha512-TWoamHt5yYvsMarGlGEQE59SbJHqGsZV8/lwC+iCcGeAe0vUaOh+Lv6SYM17ouzC/a/LB1/hz/7sxFBtlu1l4A==",
3724 + "requires": {
3725 + "async": "~1.0.0",
3726 + "colors": "1.0.x",
3727 + "cycle": "1.0.x",
3728 + "eyes": "0.1.x",
3729 + "isstream": "0.1.x",
3730 + "stack-trace": "0.0.x"
3731 + },
3732 + "dependencies": {
3733 + "async": {
3734 + "version": "1.0.0",
3735 + "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz",
3736 + "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k="
3737 + }
3738 + }
3739 + },
3278 "word-wrap": { 3740 "word-wrap": {
3279 "version": "1.2.3", 3741 "version": "1.2.3",
3280 "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 3742 "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
...@@ -3307,6 +3769,15 @@ ...@@ -3307,6 +3769,15 @@
3307 "typedarray-to-buffer": "^3.1.5" 3769 "typedarray-to-buffer": "^3.1.5"
3308 } 3770 }
3309 }, 3771 },
3772 + "ws": {
3773 + "version": "1.1.5",
3774 + "resolved": "https://registry.npmjs.org/ws/-/ws-1.1.5.tgz",
3775 + "integrity": "sha512-o3KqipXNUdS7wpQzBHSe180lBGO60SoK0yVo3CYJgb2MkobuWuBX6dhkYP5ORCLd55y+SaflMOV5fqAB53ux4w==",
3776 + "requires": {
3777 + "options": ">=0.0.5",
3778 + "ultron": "1.0.x"
3779 + }
3780 + },
3310 "xdg-basedir": { 3781 "xdg-basedir": {
3311 "version": "4.0.0", 3782 "version": "4.0.0",
3312 "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", 3783 "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",
......
...@@ -21,7 +21,10 @@ ...@@ -21,7 +21,10 @@
21 "koa-router": "^9.0.1", 21 "koa-router": "^9.0.1",
22 "mongoose": "^5.9.17", 22 "mongoose": "^5.9.17",
23 "morgan": "^1.10.0", 23 "morgan": "^1.10.0",
24 + "node-schedule": "^1.3.2",
24 "path": "^0.12.7", 25 "path": "^0.12.7",
26 + "slack-client": "^2.0.6",
27 + "slack-node": "^0.1.8",
25 "voca": "^1.4.0" 28 "voca": "^1.4.0"
26 }, 29 },
27 "devDependencies": { 30 "devDependencies": {
......
...@@ -40,7 +40,7 @@ exports.register = async (ctx) => { ...@@ -40,7 +40,7 @@ exports.register = async (ctx) => {
40 ctx.body = user.serialize(); 40 ctx.body = user.serialize();
41 41
42 const token = user.generateToken(); 42 const token = user.generateToken();
43 - ctx.cookies.set("acces_token", token, { 43 + ctx.cookies.set("access_token", token, {
44 //3일동안 유효 44 //3일동안 유효
45 maxAge: 1000 * 60 * 60 * 24 * 3, 45 maxAge: 1000 * 60 * 60 * 24 * 3,
46 httpOnly: true, 46 httpOnly: true,
...@@ -75,7 +75,7 @@ exports.login = async (ctx) => { ...@@ -75,7 +75,7 @@ exports.login = async (ctx) => {
75 } 75 }
76 ctx.body = user.serialize(); 76 ctx.body = user.serialize();
77 const token = user.generateToken(); 77 const token = user.generateToken();
78 - ctx.cookies.set("acces_token", token, { 78 + ctx.cookies.set("access_token", token, {
79 //7일동안 유효 79 //7일동안 유효
80 maxAge: 1000 * 60 * 60 * 24 * 7, 80 maxAge: 1000 * 60 * 60 * 24 * 7,
81 httpOnly: true, 81 httpOnly: true,
......
...@@ -2,7 +2,8 @@ const Router = require("koa-router"); ...@@ -2,7 +2,8 @@ const Router = require("koa-router");
2 const auth = new Router(); 2 const auth = new Router();
3 const authCtrl = require("./auth.ctrl"); 3 const authCtrl = require("./auth.ctrl");
4 auth.post("/login", authCtrl.login); 4 auth.post("/login", authCtrl.login);
5 -auth.get("/logout", authCtrl.logout); 5 +auth.post("/logout", authCtrl.logout);
6 auth.post("/register", authCtrl.register); 6 auth.post("/register", authCtrl.register);
7 +auth.get("/check", authCtrl.check);
7 8
8 module.exports = auth; 9 module.exports = auth;
......
...@@ -7,4 +7,5 @@ profile.get("/solvednum:id"); ...@@ -7,4 +7,5 @@ profile.get("/solvednum:id");
7 profile.get("/recommendps:id"); 7 profile.get("/recommendps:id");
8 profile.patch("/syncBJ", profileCtrl.syncBJ); 8 profile.patch("/syncBJ", profileCtrl.syncBJ);
9 profile.post("/setprofile", profileCtrl.setProfile); 9 profile.post("/setprofile", profileCtrl.setProfile);
10 +profile.post("/getprofile", profileCtrl.getProfile);
10 module.exports = profile; 11 module.exports = profile;
......
...@@ -13,6 +13,24 @@ exports.checkObjectId = (ctx, next) => { ...@@ -13,6 +13,24 @@ exports.checkObjectId = (ctx, next) => {
13 } 13 }
14 return next(); 14 return next();
15 }; 15 };
16 +/*POST /api/profile/getprofile
17 +{
18 + username: "username"
19 +}
20 +*/
21 +exports.getProfile = async (ctx) => {
22 + try {
23 + const { username } = ctx.request.body;
24 + const profile = await Profile.findByUsername(username);
25 + if (!profile) {
26 + ctx.status = 401;
27 + return;
28 + }
29 + ctx.body = profile;
30 + } catch (e) {
31 + ctx.throw(500, e);
32 + }
33 +};
16 /* 34 /*
17 POST /api/proflie/setprofile 35 POST /api/proflie/setprofile
18 { 36 {
......
1 +export const problem_set = [
2 + "1517",
3 + "2448",
4 + "1891",
5 + "1074",
6 + "2263",
7 + "1780",
8 + "11728",
9 + "10816",
10 + "10815",
11 + "2109",
12 + "1202",
13 + "1285",
14 + "2138",
15 + "1080",
16 + "11399",
17 + "1931",
18 + "11047",
19 + "15666",
20 + "15665",
21 + "15664",
22 + "15663",
23 + "15657",
24 + "15656",
25 + "15655",
26 + "15654",
27 + "15652",
28 + "15651",
29 + "15650",
30 + "15649",
31 + "6603",
32 + "10971",
33 + "10819",
34 + "10973",
35 + "10974",
36 + "10972",
37 + "7576",
38 + "1248",
39 + "2529",
40 + "15661",
41 + "14501",
42 + "1759",
43 + "14391",
44 + "14889",
45 + "1182",
46 + "11723",
47 + "1748",
48 + "6064",
49 + "1107",
50 + "3085",
51 + "2309",
52 + "1748",
53 + "14500",
54 + "1107",
55 + "1476",
56 + "3085",
57 + "2309",
58 + "1261",
59 + "13549",
60 + "14226",
61 + "13913",
62 + "1697",
63 + "1967",
64 + "1167",
65 + "11725",
66 + "2250",
67 + "1991",
68 + "7562",
69 + "2178",
70 + "4963",
71 + "2667",
72 + "1707",
73 + "11724",
74 + "1260",
75 + "13023",
76 + "11652",
77 + "1377",
78 + "11004",
79 + "10825",
80 + "2751",
81 + "9461",
82 + "1699",
83 + "9095",
84 + "2225",
85 + "2133",
86 + "11727",
87 + "11726",
88 + "1463",
89 + "2748",
90 + "2747",
91 + "11656",
92 + "10824",
93 + "2743",
94 + "10820",
95 + "10808",
96 + "11655",
97 + "11720",
98 + "1008",
99 + "10951",
100 + "2557",
101 + "1021",
102 + "1966",
103 + "2164",
104 + "10799",
105 + "17413",
106 + "10866",
107 + "1158",
108 + "10845",
109 + "1406",
110 + "1874",
111 + "9012",
112 + "9093",
113 + "10828",
114 + "11721",
115 + "11719",
116 + "11718",
117 + "10953",
118 + "2558",
119 + "10814",
120 + "1181",
121 + "11651",
122 + "11650",
123 + "1427",
124 + "2108",
125 + "10989",
126 + "2751",
127 + "2750",
128 + "1436",
129 + "1018",
130 + "7568",
131 + "2231",
132 + "2798",
133 + "1002",
134 + "3053",
135 + "4153",
136 + "3009",
137 + "1085",
138 + "9020",
139 + "4948",
140 + "1929",
141 + "2581",
142 + "1978",
143 + "2292",
144 + "6064",
145 + "2775",
146 + "10250",
147 + "2869",
148 + "1011",
149 + "1193",
150 + "2839",
151 + "1712",
152 + "1316",
153 + "2941",
154 + "5622",
155 + "2908",
156 + "1152",
157 + "1157",
158 + "2675",
159 + "10809",
160 + "11720",
161 + "11654",
162 + "11729",
163 + "2447",
164 + "3052",
165 + "10818",
166 + "10872",
167 + "10870",
168 + "1065",
169 + "4673",
170 + "15596",
171 + "4344",
172 + "2920",
173 + "8958",
174 + "1546",
175 + "2577",
176 + "2562",
177 + "1110",
178 + "10951",
179 + "10952",
180 + "10871",
181 + "2439",
182 + "2438",
183 + "11022",
184 + "11021",
185 + "2742",
186 + "2741",
187 + "15552",
188 + "8393",
189 + "10950",
190 + "2739",
191 + "10817",
192 + "2884",
193 + "2753",
194 + "9498",
195 + "1330",
196 + "2588",
197 + "10430",
198 + "10869",
199 + "1008",
200 + "10998",
201 + "7287",
202 + "10172",
203 + "10171",
204 + "10718",
205 + "1001",
206 + "1000",
207 + "2557",
208 +];
1 const jwt = require("jsonwebtoken"); 1 const jwt = require("jsonwebtoken");
2 const User = require("../models/user"); 2 const User = require("../models/user");
3 +
3 const jwtMiddleware = async (ctx, next) => { 4 const jwtMiddleware = async (ctx, next) => {
4 const token = ctx.cookies.get("access_token"); 5 const token = ctx.cookies.get("access_token");
6 +
5 if (!token) { 7 if (!token) {
6 - //토큰이 없을 때
7 return next(); 8 return next();
8 } 9 }
9 try { 10 try {
10 - const decoded = jwt.verify(token, process.env.JWT_TOKEN); 11 + const decoded = jwt.verify(token, process.env.JWT_SECRET);
11 ctx.state.user = { 12 ctx.state.user = {
12 _id: decoded._id, 13 _id: decoded._id,
13 username: decoded.username, 14 username: decoded.username,
14 }; 15 };
15 - //토큰의 남은 유효 기간이 2일 이하라면 재발급 16 + const now = Math.floor(Date.now() / 1000);
16 - if (decoded.exp - Date.now() / 1000 < 60 * 60 * 24 * 2) { 17 + if (decoded.exp - now < 60 * 60 * 24 * 3.5) {
17 const user = await User.findById(decoded._id); 18 const user = await User.findById(decoded._id);
18 const token = user.generateToken(); 19 const token = user.generateToken();
19 ctx.cookies.set("access_token", token, { 20 ctx.cookies.set("access_token", token, {
20 - maxAge: 1000 * 60 * 60 * 24 * 7, 21 + maxAge: 1000 * 60 * 60 * 24 * 7, //7days
21 httpOnly: true, 22 httpOnly: true,
22 }); 23 });
23 } 24 }
25 +
24 return next(); 26 return next();
25 } catch (e) { 27 } catch (e) {
26 return next(); 28 return next();
27 } 29 }
28 }; 30 };
29 -
30 module.exports = jwtMiddleware; 31 module.exports = jwtMiddleware;
......
...@@ -7,6 +7,7 @@ const ProfileSchema = new Schema({ ...@@ -7,6 +7,7 @@ const ProfileSchema = new Schema({
7 userBJID: String, 7 userBJID: String,
8 solvedBJ: Object, 8 solvedBJ: Object,
9 friendList: [String], 9 friendList: [String],
10 + slackWebHookURL: String,
10 }); 11 });
11 ProfileSchema.statics.findByUsername = function (username) { 12 ProfileSchema.statics.findByUsername = function (username) {
12 return this.findOne({ username }); 13 return this.findOne({ username });
......
1 +/*
2 +2. 현재 날짜와의 차이 =>
3 +3. 오늘 푼 문제 => 앞에서부터 순회하면서 데이트 같은거 찾기
4 +3. 최근 일주일간 푼 문제 수 => 앞에서부터 순회하면서 - 값이
5 +4. 추천 문제 => 정규 셋에서 없는거 찾기
6 +5. 날짜별로 묶기.
7 +데이터베이스에서 처리하자
8 +*/
9 +
10 +let moment = require('moment');
11 +
12 +exports.analyzeBJ = function (solvedBJ) {
13 + try {
14 + if (solvedBJ) {
15 + console.log(solvedBJ[0]);
16 + let presentDate = moment();
17 + let presentDate_str = presentDate.format('YYYYMMDD');
18 + let latestDate = moment(solvedBJ[0].solved_date, 'YYYYMMDD');
19 + let difflatest = presentDate.diff(latestDate, 'days');
20 +
21 + let solvedBJbyDATE = {};
22 + for (let i = 0; i < solvedBJ.length; i++) {
23 + if (!(solvedBJ[i].solved_date in solvedBJbyDATE)) {
24 + solvedBJbyDATE[solvedBJ[i].solved_date] = [];
25 + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]);
26 + } else {
27 + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]);
28 + }
29 + }
30 +
31 + let latestNum = solvedBJbyDATE[solvedBJ[0].solved_date].length;
32 + let presentNum =
33 + presentDate_str in solvedBJbyDATE
34 + ? solvedBJbyDATE[presentDate_str].length
35 + : 0;
36 + let returnOBJ = {
37 + latestDate: latestDate.format('YYYYMMDD'),
38 + difflatest: difflatest,
39 + latestNum: latestNum,
40 + presentNum: presentNum,
41 + solvedBJbyDATE: solvedBJbyDATE,
42 + };
43 + console.log(returnOBJ);
44 + return returnOBJ;
45 + }
46 + } catch (e) {
47 + console.log(e);
48 + }
49 +};
1 +/*
2 +집중을 해보자.
3 +새거와 데이터가 있다.
4 +데이터 기준으로 새거에 자료가 있으면 넘어가기
5 +없으면 새 배열에 추가
6 +키만 모아둔 리스트를 만들자.
7 +그렇게 해서
8 +반복은 새거 길이만큼
9 +데이터에 있으면 추가 X
10 +없으면 추가
11 +그렇게 반환
12 +*/
13 +
14 +exports.compareBJ = function (solvedBJ_new, problem_set) {
15 + try {
16 + let new_obj = [];
17 + for (let i = 0; i < solvedBJ.length; i++) {
18 + if (solvedBJ_new[i].problem_number in problem_set) {
19 + new_obj.push(solvedBJ_new[i]);
20 + }
21 + }
22 + console.log(new_obj);
23 + } catch (e) {
24 + console.log(e);
25 + }
26 +};
1 +const Slack = require("slack-node"); // 슬랙 모듈 사용
2 +
3 +const webhookUri =
4 + "https://hooks.slack.com/services/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"; // Webhook URL
5 +
6 +const slack = new Slack();
7 +slack.setWebhook(webhookUri);
8 +
9 +const send = async (message) => {
10 + slack.webhook(
11 + {
12 + text: message,
13 + },
14 + function (err, response) {
15 + console.log(response);
16 + }
17 + );
18 +};
19 +
20 +send("hello");
1 +var getBJ = require("./getBJ");
2 +var fs = require("fs");
3 +
4 +let dataset = [
5 + "1517",
6 + "2448",
7 + "1891",
8 + "1074",
9 + "2263",
10 + "1780",
11 + "11728",
12 + "10816",
13 + "10815",
14 + "2109",
15 + "1202",
16 + "1285",
17 + "2138",
18 + "1080",
19 + "11399",
20 + "1931",
21 + "11047",
22 + "15666",
23 + "15665",
24 + "15664",
25 + "15663",
26 + "15657",
27 + "15656",
28 + "15655",
29 + "15654",
30 + "15652",
31 + "15651",
32 + "15650",
33 + "15649",
34 + "6603",
35 + "10971",
36 + "10819",
37 + "10973",
38 + "10974",
39 + "10972",
40 + "7576",
41 + "1248",
42 + "2529",
43 + "15661",
44 + "14501",
45 + "1759",
46 + "14391",
47 + "14889",
48 + "1182",
49 + "11723",
50 + "1748",
51 + "6064",
52 + "1107",
53 + "3085",
54 + "2309",
55 + "1748",
56 + "14500",
57 + "1107",
58 + "1476",
59 + "3085",
60 + "2309",
61 + "1261",
62 + "13549",
63 + "14226",
64 + "13913",
65 + "1697",
66 + "1967",
67 + "1167",
68 + "11725",
69 + "2250",
70 + "1991",
71 + "7562",
72 + "2178",
73 + "4963",
74 + "2667",
75 + "1707",
76 + "11724",
77 + "1260",
78 + "13023",
79 + "11652",
80 + "1377",
81 + "11004",
82 + "10825",
83 + "2751",
84 + "9461",
85 + "1699",
86 + "9095",
87 + "2225",
88 + "2133",
89 + "11727",
90 + "11726",
91 + "1463",
92 + "2748",
93 + "2747",
94 + "11656",
95 + "10824",
96 + "2743",
97 + "10820",
98 + "10808",
99 + "11655",
100 + "11720",
101 + "1008",
102 + "10951",
103 + "2557",
104 + "1021",
105 + "1966",
106 + "2164",
107 + "10799",
108 + "17413",
109 + "10866",
110 + "1158",
111 + "10845",
112 + "1406",
113 + "1874",
114 + "9012",
115 + "9093",
116 + "10828",
117 + "11721",
118 + "11719",
119 + "11718",
120 + "10953",
121 + "2558",
122 + "10814",
123 + "1181",
124 + "11651",
125 + "11650",
126 + "1427",
127 + "2108",
128 + "10989",
129 + "2751",
130 + "2750",
131 + "1436",
132 + "1018",
133 + "7568",
134 + "2231",
135 + "2798",
136 + "1002",
137 + "3053",
138 + "4153",
139 + "3009",
140 + "1085",
141 + "9020",
142 + "4948",
143 + "1929",
144 + "2581",
145 + "1978",
146 + "2292",
147 + "6064",
148 + "2775",
149 + "10250",
150 + "2869",
151 + "1011",
152 + "1193",
153 + "2839",
154 + "1712",
155 + "1316",
156 + "2941",
157 + "5622",
158 + "2908",
159 + "1152",
160 + "1157",
161 + "2675",
162 + "10809",
163 + "11720",
164 + "11654",
165 + "11729",
166 + "2447",
167 + "3052",
168 + "10818",
169 + "10872",
170 + "10870",
171 + "1065",
172 + "4673",
173 + "15596",
174 + "4344",
175 + "2920",
176 + "8958",
177 + "1546",
178 + "2577",
179 + "2562",
180 + "1110",
181 + "10951",
182 + "10952",
183 + "10871",
184 + "2439",
185 + "2438",
186 + "11022",
187 + "11021",
188 + "2742",
189 + "2741",
190 + "15552",
191 + "8393",
192 + "10950",
193 + "2739",
194 + "10817",
195 + "2884",
196 + "2753",
197 + "9498",
198 + "1330",
199 + "2588",
200 + "10430",
201 + "10869",
202 + "1008",
203 + "10998",
204 + "7287",
205 + "10172",
206 + "10171",
207 + "10718",
208 + "1001",
209 + "1000",
210 + "2557",
211 +];
212 +
213 +const test = async (userid) => {
214 + let lst = await getBJ.getBJ(userid);
215 + let return_lst = [];
216 + for (let i = 0; i < lst.length; i++) {
217 + return_lst.push(lst[i].problem_number);
218 + }
219 +
220 + var stringJson = JSON.stringify(return_lst) + "\n";
221 + fs.open("test.json", "a", "666", function (err, id) {
222 + if (err) {
223 + console.log("file open err!!");
224 + } else {
225 + fs.write(id, stringJson, null, "utf8", function (err) {
226 + console.log("file was saved!");
227 + });
228 + }
229 + });
230 +};
231 +
232 +/*
233 +
234 +*/
235 +test("jwseo001");
1 +[
2 + "1517",
3 + "2448",
4 + "1891",
5 + "1074",
6 + "2263",
7 + "1780",
8 + "11728",
9 + "10816",
10 + "10815",
11 + "2109",
12 + "1202",
13 + "1285",
14 + "2138",
15 + "1080",
16 + "11399",
17 + "1931",
18 + "11047",
19 + "15666",
20 + "15665",
21 + "15664",
22 + "15663",
23 + "15657",
24 + "15656",
25 + "15655",
26 + "15654",
27 + "15652",
28 + "15651",
29 + "15650",
30 + "15649",
31 + "6603",
32 + "10971",
33 + "10819",
34 + "10973",
35 + "10974",
36 + "10972",
37 + "7576",
38 + "1248",
39 + "2529",
40 + "15661",
41 + "14501",
42 + "1759",
43 + "14391",
44 + "14889",
45 + "1182",
46 + "11723",
47 + "1748",
48 + "6064",
49 + "1107",
50 + "3085",
51 + "2309",
52 + "1748",
53 + "14500",
54 + "1107",
55 + "1476",
56 + "3085",
57 + "2309",
58 + "1261",
59 + "13549",
60 + "14226",
61 + "13913",
62 + "1697",
63 + "1967",
64 + "1167",
65 + "11725",
66 + "2250",
67 + "1991",
68 + "7562",
69 + "2178",
70 + "4963",
71 + "2667",
72 + "1707",
73 + "11724",
74 + "1260",
75 + "13023",
76 + "11652",
77 + "1377",
78 + "11004",
79 + "10825",
80 + "2751",
81 + "9461",
82 + "1699",
83 + "9095",
84 + "2225",
85 + "2133",
86 + "11727",
87 + "11726",
88 + "1463",
89 + "2748",
90 + "2747",
91 + "11656",
92 + "10824",
93 + "2743",
94 + "10820",
95 + "10808",
96 + "11655",
97 + "11720",
98 + "1008",
99 + "10951",
100 + "2557",
101 + "1021",
102 + "1966",
103 + "2164",
104 + "10799",
105 + "17413",
106 + "10866",
107 + "1158",
108 + "10845",
109 + "1406",
110 + "1874",
111 + "9012",
112 + "9093",
113 + "10828",
114 + "11721",
115 + "11719",
116 + "11718",
117 + "10953",
118 + "2558",
119 + "10814",
120 + "1181",
121 + "11651",
122 + "11650",
123 + "1427",
124 + "2108",
125 + "10989",
126 + "2751",
127 + "2750",
128 + "1436",
129 + "1018",
130 + "7568",
131 + "2231",
132 + "2798",
133 + "1002",
134 + "3053",
135 + "4153",
136 + "3009",
137 + "1085",
138 + "9020",
139 + "4948",
140 + "1929",
141 + "2581",
142 + "1978",
143 + "2292",
144 + "6064",
145 + "2775",
146 + "10250",
147 + "2869",
148 + "1011",
149 + "1193",
150 + "2839",
151 + "1712",
152 + "1316",
153 + "2941",
154 + "5622",
155 + "2908",
156 + "1152",
157 + "1157",
158 + "2675",
159 + "10809",
160 + "11720",
161 + "11654",
162 + "11729",
163 + "2447",
164 + "3052",
165 + "10818",
166 + "10872",
167 + "10870",
168 + "1065",
169 + "4673",
170 + "15596",
171 + "4344",
172 + "2920",
173 + "8958",
174 + "1546",
175 + "2577",
176 + "2562",
177 + "1110",
178 + "10951",
179 + "10952",
180 + "10871",
181 + "2439",
182 + "2438",
183 + "11022",
184 + "11021",
185 + "2742",
186 + "2741",
187 + "15552",
188 + "8393",
189 + "10950",
190 + "2739",
191 + "10817",
192 + "2884",
193 + "2753",
194 + "9498",
195 + "1330",
196 + "2588",
197 + "10430",
198 + "10869",
199 + "1008",
200 + "10998",
201 + "7287",
202 + "10172",
203 + "10171",
204 + "10718",
205 + "1001",
206 + "1000",
207 + "2557"
208 +]