Commit 278f5d67 authored by Park Sungwoo's avatar Park Sungwoo
Browse files

123

parent 16b2e59a
import express from "express"; import express from "express";
import User from "./models/usesrs.models"
const port = 3000; const port = 3000;
const app = express(); const app = express();
app.get("/", (req, res) => { app.get("/", (req, res) => {
console.log("root path get method called.") console.log("root path get method called.");
res.send("!23") res.send("<h1> 안녕하세요. </h1>");
}) })
app.get("/users", async (req, res) => {
app.listen(port, () => { User.create({ password: "xxx", email:"xxx@example.com", name: "dkxkdkf"});
console.log(`server is runnug at ${port} port.`) console.log("new user:", newUser);
const users = await User.find();
res.json(users);
}) })
// app.listen(port, () => {
// console.log(`server is runnug at ${port} port.`)
// })
export default app export default app
\ No newline at end of file
import mongoose from "mongoose";
const validateEmail = (email => {
const re = /^\w+([\,-]?\w+)*@\w+([\,-]?\w+)*(\.\w{2,3})+$/;
return re.test(email)
})
const schema = new mongoose.Schema({
email:{
type: String,
rquired: true,
unique: true,
validate: [validateEmail, "이메일을 입력해주세요."],
},
name: {type:string},
password: { type: string, required: true, select: false},
role:{type:schema.types.objectId, ref: "Role"},
}
);
export default schema;
\ 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