app.js 573 Bytes
Newer Older
Park Sungwoo's avatar
123    
Park Sungwoo committed
1
import express from "express";
Park Sungwoo's avatar
123    
Park Sungwoo committed
2
import User from "./models/usesrs.models"
Park Sungwoo's avatar
123    
Park Sungwoo committed
3
4
5
6
7

const port = 3000;
const app = express();

app.get("/", (req, res) => {
Park Sungwoo's avatar
123    
Park Sungwoo committed
8
9
    console.log("root path get method called.");
    res.send("<h1> 안녕하세요. </h1>");
Park Sungwoo's avatar
123    
Park Sungwoo committed
10
})
Park Sungwoo's avatar
123    
Park Sungwoo committed
11
12
13
14
15
app.get("/users", async (req, res) => {
    User.create({ password: "xxx", email:"xxx@example.com", name: "dkxkdkf"});
    console.log("new user:", newUser);
    const users = await User.find();
    res.json(users);
Park Sungwoo's avatar
Park Sungwoo committed
16
17
})

Park Sungwoo's avatar
123    
Park Sungwoo committed
18
19
20
21
22

// app.listen(port, () => {
//     console.log(`server is runnug at ${port} port.`)
// })

Park Sungwoo's avatar
Park Sungwoo committed
23
export default app