-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (28 loc) · 960 Bytes
/
Copy pathapp.js
File metadata and controls
44 lines (28 loc) · 960 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
import express from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import path from 'path';
import cookieParser from 'cookie-parser';
import logger from 'morgan';
import 'dotenv/config';
import { red } from 'colorette';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// SETTING MONGOOSE PLUGINS
// IMPORT ROUTES
import animesRouter from './routes/animesRouter.js';
const app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/media/posters', express.static(path.join(__dirname, '/media/posters')));
mongoose.connect(process.env.MONGO_URI, () => {
console.log(red('Connected to the DB...'));
})
// ROUTES
app.use('/api/animes/', animesRouter);
export default app;