-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 968 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import express from "express";
import morgan from "morgan";
import { fileURLToPath } from 'url';
import path from "path";
import cors from 'cors';
import userRouter from './routes/userRoutes.js';
import songRouter from './routes/songRoutes.js';
import playlistRouter from './routes/playlistRoutes.js';
import viewRouter from './routes/viewRoutes.js';
import cookieParser from 'cookie-parser';
import globalErrorHandler from "./controllers/errorController.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(cors());
app.use(express.static(path.join(__dirname,`public`)));
app.set('view engine','pug');
app.set('views',path.join(__dirname,'views'))
// Mounting the Routes
app.use('/api/v1/users',userRouter);
app.use('/api/v1/songs',songRouter);
app.use('/api/v1/playlists',playlistRouter);
app.use('/',viewRouter);
app.use(globalErrorHandler);
export default app;