app.js 867 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
import express from 'express';
// import bodyParser from "body-parser";
Kim, Subin's avatar
Kim, Subin committed
3
4
import connectDb from './schemas/index.js'
import userRouter from "./routes/user.routes.js";
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
7
8
import productRouter from './routes/product.routes.js';
import path from 'path'
import kakaopayRoutes from './routes/kakaopay.routes.js'
import config from './config.js'
이재연's avatar
이재연 committed
9
import authRouter from './routes/auth.routes.js'
Jiwon Yoon's avatar
Jiwon Yoon committed
10
import cors from 'cors'
Kim, Subin's avatar
Kim, Subin committed
11
12
13

connectDb()

Kim, Subin's avatar
Kim, Subin committed
14
15
16
17
const app = express();


app.use(express.json());
Jiwon Yoon's avatar
Jiwon Yoon committed
18
app.use(cors())
Kim, Subin's avatar
Kim, Subin committed
19

Jiwon Yoon's avatar
Jiwon Yoon committed
20
21
app.use(express.static(path.join(process.cwd(), 'dist')))
// app.use(bodyParser.urlencoded({ extended: true }))
Kim, Subin's avatar
Kim, Subin committed
22

Jiwon Yoon's avatar
Jiwon Yoon committed
23
24
// app.use('/', indexRouter);
app.use('/', kakaopayRoutes)
이재연's avatar
이재연 committed
25
app.use('/api/users',userRouter)
이재연's avatar
이재연 committed
26
app.use('/api/auth/login',authRouter)
Jiwon Yoon's avatar
Jiwon Yoon committed
27
app.use('/api/products', productRouter)
Kim, Subin's avatar
Kim, Subin committed
28

Jiwon Yoon's avatar
Jiwon Yoon committed
29
30
31
app.listen(config.port, () => {
  console.info('Server started on port %s.', config.port)
})
Kim, Subin's avatar
Kim, Subin committed
32