고병후

Fixe file

......@@ -2,12 +2,34 @@ const express = require("express");
const bodyParser = require("body-parser");
const router = express.Router();
const {User}=require('../models');
router.get('/',(req,res)=>{
res.send('회원가입 페이지');
});
router.post('/',(req,res)=>{
return res.status(201).json({success: true})
User.findOne({
where:{name: req.body.Id}
})
.then((result)=>{
//id가 중복되지 않는 경우
if(result === null || result === undefined){
User.create({
name: req.body.Id,
pw:req.body.Password,
personality:req.body.Personality,
status:false
})
console.log(req.body);
return res.sendStatus(200);
}
//id중복
else{
console.log("중복된 id");
return res.sendStatus(401);
}
})
});
//라우트 매개변수사용
......
......@@ -13,14 +13,11 @@ dotenv.config();
const indexRouter = require('./routes/index.js');
const loginRouter = require('./routes/login.js');
const registerRouter = require('./routes/register.js');
<<<<<<< HEAD
const mainRouter = require('./routes/main.js');
const logoutRouter = require('./routes/logout.js');
const authRouter = require('./routes/auth.js');
const userRouter = require('./routes/user.js');
const postRouter = require('./routes/post.js');
=======
>>>>>>> board
const app = express();
app.set('port', process.env.PORT || 3001);
......@@ -39,10 +36,6 @@ sequelize.sync({force: false})
app.use(morgan('dev'));
app.use(express.json()); //json형식으로 데이터 전달
app.use(express.urlencoded({extende: false})); // url형식으로 형식으로 데이터 전달
<<<<<<< HEAD
=======
//app.use(bodyParser().json);
>>>>>>> board
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use(session({
resave: false,
......@@ -65,12 +58,6 @@ app.use('/api/logout',logoutRouter);//로그아웃
app.use('/api/user',userRouter);//유저정보 응답
app.use('/api/post',postRouter);//유저정보 응답
<<<<<<< HEAD
=======
//app.use('/',loginRouter); //로그인 페이지
app.use('/api/register',registerRouter); // 회원가입 페이지
>>>>>>> board
//에러처리 미들웨어
//존재하지 않는 경로가 들어오면 오류 응답
......
<<<<<<< HEAD
import React, {useState} from 'react';
import '../style/Board.scss'
import {CKEditor} from "@ckeditor/ckeditor5-react";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import {Button} from "semantic-ui-react";
import ReactHtmlParser from 'react-html-parser';
function Board() {
const [BoardContent, setBoardContent] = useState({
title: '',
content:''
})
const [viewContent,setViewContent] = useState([]);
const getValue = e => {
const {name, value} = e.target;
setBoardContent({
...BoardContent,
[name]: value
})
console.log(BoardContent);
}
return (
<div className="Board">
<div className="contents-container">
{viewContent.map(element =>
<div>
=======
import React, { useState} from 'react';
import '../style/Board.scss'
import ReactHtmlParser from 'react-html-parser';
......@@ -43,65 +16,14 @@ function Board() {
</div>
{viewContent.map(element =>
<div class="ui segment">
>>>>>>> board
<h2>{element.title}</h2>
<div>
{ReactHtmlParser(element.content)}
</div>
<<<<<<< HEAD
</div>)
}
</div>
<div className="form=wrapper">
<input className="title-input"
type='text'
placeholder='제목'
onChange={getValue}
name = 'title'
/>
<CKEditor
editor={ClassicEditor}
data=""
onReady={editor => {
// You can store the "editor" and use when it is needed.
console.log('Editor is ready to use!', editor);
}}
onChange={(event, editor) => {
const data = editor.getData();
console.log({ event, editor, data });
setBoardContent({
...BoardContent,
content: data
})
console.log(BoardContent);
}}
onBlur={(event, editor) => {
console.log('Blur.', editor);
}}
onFocus={(event, editor) => {
console.log('Focus.', editor);
}}
/>
<div className="write-button">
<Button className="ui animated button"
tabIndex="0"
onClick={() =>{
setViewContent(viewContent.concat({...BoardContent}));
}}
>
<div className="visible content"> 고민 작성하기</div>
<div className="hidden content">
<i className="pencil alternate icon"></i>
</div>
</Button>
</div>
</div>
=======
</div>
)}
>>>>>>> board
</div>
);
};
......
......@@ -3,13 +3,9 @@ import "../style/LoginPage.scss";
import Axios from 'axios'
import { Icon, Input } from "semantic-ui-react"
import { useNavigate } from "react-router-dom";
<<<<<<< HEAD
function LoginPage() {
let navigate = useNavigate();
=======
function LoginPage(props) {
const navigate = useNavigate();
>>>>>>> board
const [Id, setId] = useState("");
const [Password, setPassword] = useState("");
const onIdHandler = (event) => {
......@@ -22,7 +18,6 @@ function LoginPage(props) {
event.preventDefault();
console.log("ID", Id);
console.log("Password", Password);
<<<<<<< HEAD
Axios.post('/api/login',{
Id,
Password,
......@@ -40,9 +35,6 @@ function LoginPage(props) {
alert("잘못된 비밀번호입니다.")
}
})
=======
>>>>>>> board
};
const goToRegister = () => {
navigate('/register');
......
......@@ -22,7 +22,7 @@ function RegisterPage(props) {
//비밀번호를 입력할때마다 password 를 검증하는 함수
setPasswordCheck(event.currentTarget.value);
};
const onSubmitHandler = useCallback((event) => {
const onSubmitHandler = (event) => {
event.preventDefault();
console.log("ID", Id);
console.log("Password", Password);
......@@ -46,7 +46,7 @@ function RegisterPage(props) {
alert("중복된 아이디입니다.")
})
}
},[Id, Password, Personality, PasswordCheck])
}
return (
<div id="Register">
<div className="register-form">
......
......@@ -3,16 +3,11 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import 'semantic-ui-css/semantic.min.css'
<<<<<<< HEAD
ReactDOM.render(
<App />,
document.getElementById('root')
=======
ReactDOM.render(
<App />,
document.getElementById('root')
>>>>>>> board
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
......
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
<<<<<<< HEAD
createProxyMiddleware('/api',{
=======
createProxyMiddleware('/api',{
>>>>>>> board
target: 'http://localhost:3001',
changeOrigin: true,
})
......