Commit f783563f authored by 우지원's avatar 우지원
Browse files

Merge remote-tracking branch 'origin/soo-12-28' into jiweon827

parents 8953bd52 09af2954
......@@ -21,5 +21,8 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
.eslintcache
\ No newline at end of file
.eslintcache
debug.log
.env
......@@ -12,7 +12,6 @@
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"styled-components": "^5.2.1",
"web-vitals": "^0.2.4"
},
"scripts": {
......
import logo from './logo.svg';
import './App.css';
import Hello from './Hello';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
안녕하세요
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<Hello name='대기'/>
);
}
......
import React, { useState } from 'react';
function randCode(){
// const [ranNumArr,setRanNumArr] = useState([]);
const min = 1;
const max = 99999;
let newNum = Math.floor((Math.random()*max)+min);
// for (let i=0;i<ranNumArr.length;i++){
// if (ranNumArr[i]==newNum){
// newNum = Math.floor((Math.random()*max)+min);
// }
// }
let zeroSize = "";
for (let j=0;j<5-newNum.toString().length;j++){
zeroSize += "0";
}
// setRanNumArr(zeroSize+newNum);
return (zeroSize+newNum.toString());
}
export default randCode;
\ No newline at end of file
......@@ -5,8 +5,8 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev": "nodemon server/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"dev" : "nodemon index.js"
},
"repository": {
"type": "git",
......
import User from "../models/User.js"
import isLength from 'validator/lib/isLength.js'
const signup = async (req, res) => {
const { name, email, password } = req.body
try {
if (!isLength(name, { min: 3, max: 10 })) {
return res.status(422).send('Name must be 3-10 characters')
}
const newUser = await new User({
name,
email,
password
}).save()
console.log(newUser)
res.json(newUser)
} catch (error) {
console.log(error)
res.status(500).send('User signup error')
}
}
const hello = (req, res) => {
res.send('Hello from users controller')
}
export default { signup, hello }
\ No newline at end of file
......@@ -45,4 +45,4 @@ const UserSchema = new mongoose.Schema({
})
export default mongoose.models.User || mongoose.model('User', UserSchema)
//user라는 이름이 있으면 앞을 return하고 없으면 뒤를 실행함
\ No newline at end of file
//user라는 이름이 있으면 앞을 return하고 없으면 뒤를 실행함
import mongoose from 'mongoose'
const {String} = mongoose.Schema.Types
const ChatSchema = new mongoose.Schema({
name: {
type: String,
required: true,
},
interest: {
type: String,
required: true,
select: false
},
isOpen: {
type: String,
required: true,
default: 'user',
enum: ['user', 'admin', 'root']
}
}, {
timestamps: true
})
export default mongoose.models.User || mongoose.model('chat', ChatSchema)
\ No newline at end of file
import express from 'express'
import userCtrl from '../controllers/user.controllers.js'
const router = express.Router()
router.route('/api/users/signup')
.post(userCtrl.signup)
.get(userCtrl.hello)
export default router
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment