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 @@ ...@@ -21,5 +21,8 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
package-lock.json package-lock.json
.eslintcache .eslintcache
\ No newline at end of file debug.log
.env
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
"react-scripts": "4.0.1", "react-scripts": "4.0.1",
"styled-components": "^5.2.1",
"web-vitals": "^0.2.4" "web-vitals": "^0.2.4"
}, },
"scripts": { "scripts": {
......
import logo from './logo.svg'; import logo from './logo.svg';
import './App.css'; import './App.css';
import Hello from './Hello';
function App() { function App() {
return ( return (
<div className="App"> <Hello name='대기'/>
<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>
); );
} }
......
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 @@ ...@@ -5,8 +5,8 @@
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
"scripts": { "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": { "repository": {
"type": "git", "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({ ...@@ -45,4 +45,4 @@ const UserSchema = new mongoose.Schema({
}) })
export default mongoose.models.User || mongoose.model('User', UserSchema) export default mongoose.models.User || mongoose.model('User', UserSchema)
//user라는 이름이 있으면 앞을 return하고 없으면 뒤를 실행함 //user라는 이름이 있으면 앞을 return하고 없으면 뒤를 실행함
\ No newline at end of file
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