app.js 992 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
import productRouter from './routes/product.routes.js';
6
import cartRouter from './routes/cart.routes.js';
Jiwon Yoon's avatar
Jiwon Yoon committed
7
8
9
import path from 'path'
import kakaopayRoutes from './routes/kakaopay.routes.js'
import config from './config.js'
이재연's avatar
이재연 committed
10
import authRouter from './routes/auth.routes.js'
Jiwon Yoon's avatar
Jiwon Yoon committed
11
import cors from 'cors'
Kim, Subin's avatar
Kim, Subin committed
12
13
14

connectDb()

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

박상호's avatar
박상호 committed
17
app.use("/image", express.static("uploads/"))
Kim, Subin's avatar
Kim, Subin committed
18
19

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

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

Jiwon Yoon's avatar
Jiwon Yoon committed
25
26
// app.use('/', indexRouter);
app.use('/', kakaopayRoutes)
이재연's avatar
이재연 committed
27
app.use('/api/users',userRouter)
이재연's avatar
이재연 committed
28
app.use('/api/auth',authRouter)
kusang96's avatar
kusang96 committed
29
app.use('/api/product', productRouter)
30
app.use('/api/addcart', cartRouter)
Kim, Subin's avatar
Kim, Subin committed
31

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