app.js 1.36 KB
Newer Older
1
2
3
4
5
6
7
import express from 'express'
import connectDb from './schemas/index.js'
import userRouter from "./routes/user.routes.js";

connectDb()


Kim, Subin's avatar
Kim, Subin committed
8
// const createError = require('http-errors');
9

10
11
// const express = require('express');
// const path = require('path');
Kim, Subin's avatar
Kim, Subin committed
12
// const cookieParser = require('cookie-parser');
13
// const logger = require('morgan');
14
// const port = 3030;
Kim, Subin's avatar
Kim, Subin committed
15

Kim, Subin's avatar
Kim, Subin committed
16
// const indexRouter = require('./routes/index');
Kim, Subin's avatar
Kim, Subin committed
17
18

const app = express();
Kim, Subin's avatar
Kim, Subin committed
19
// connect();
Kim, Subin's avatar
Kim, Subin committed
20
21
22
23
24
25
26

// view engine setup
// app.set('views', path.join(__dirname, 'views'));
// app.set('view engine', 'pug');

// app.use(logger('dev'));
app.use(express.json());
27
// app.use(express.urlencoded({ extended: false }));
Kim, Subin's avatar
Kim, Subin committed
28
// app.use(cookieParser(process.env.JWT_SECRET));
29
// app.use(express.static(path.join(__dirname, 'public')));
Kim, Subin's avatar
Kim, Subin committed
30

Kim, Subin's avatar
Kim, Subin committed
31
// app.use('/', indexRouter);
Kim, Subin's avatar
Kim, Subin committed
32

33
34
35
36
// app.listen(port, () => console.log(port));
app.listen(3001, () => console.log('Listenning'));

app.use(userRouter)
Kim, Subin's avatar
Kim, Subin committed
37
38

// catch 404 and forward to error handler
39
40
41
// app.use(function(req, res, next) {
//   next(createError(404));
// });
Kim, Subin's avatar
Kim, Subin committed
42
43

// error handler
44
// app.use(function(err, req, res, next) {
Kim, Subin's avatar
Kim, Subin committed
45
  // set locals, only providing error in development
46
  // res.locals.message = err.message;
Kim, Subin's avatar
Kim, Subin committed
47
  // res.locals.error = req.app.get('env') === 'development' ? err : {};
Kim, Subin's avatar
Kim, Subin committed
48
49

  // render the error page
50
  // res.status(err.status || 500);
Kim, Subin's avatar
Kim, Subin committed
51
  // res.render('error');
52
// });
Kim, Subin's avatar
Kim, Subin committed
53

54
// module.exports = app;