app.js 821 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import express from 'express';
kusang96's avatar
dd    
kusang96 committed
2
import fs from 'fs';
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
9
import productRouter from './routes/product.routes.js';
import path from 'path'
import kakaopayRoutes from './routes/kakaopay.routes.js'
import config from './config.js'
import cors from 'cors'
Kim, Subin's avatar
Kim, Subin committed
10

kusang96's avatar
dd    
kusang96 committed
11
12
13
14
15
16
fs.readdir('uploads', (error) => {
  if (error) {
      fs.mkdirSync('uploads');
  }
})

Kim, Subin's avatar
Kim, Subin committed
17
18
connectDb()

Kim, Subin's avatar
Kim, Subin committed
19
20
const app = express();

Jiwon Yoon's avatar
Jiwon Yoon committed
21
22
23
app.use(cors())
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)
kusang96's avatar
kusang96 committed
28
app.use('/api/product', productRouter)
Kim, Subin's avatar
Kim, Subin committed
29

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