This repository was archived by the owner on Feb 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
63 lines (49 loc) · 1.85 KB
/
app.js
File metadata and controls
63 lines (49 loc) · 1.85 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import express from 'express';
import cookieParser from 'cookie-parser';
import bodyParser from 'body-parser';
import logger from 'morgan';
import cors from 'cors';
import indexRouter from './routes/index.js';
import sideQuestRouter from './routes/sideQuest.js';
import mainProjectRouter from './routes/mainProject.js';
import authRouter from './routes/auth.js';
import testEnvRouter from './routes/test-env.js';
import discordBot from './routes/discordBot.js';
import userRouter from './routes/users.js';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
import serveFavicon from 'serve-favicon';
var app = express();
app.use(cors({ credentials: true, origin: ['http://localhost:3000', 'https://dev-dogs-website.vercel.app/', "https://devdogs.uga.edu"] }));
// app.use(cors());
app.use(serveFavicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(bodyParser.json());
app.use('/', indexRouter);
app.use('/auth', authRouter);
app.use('/users', userRouter);
app.use('/sideQuest', sideQuestRouter);
app.use('/mainProject', mainProjectRouter);
app.use('/discord', discordBot);
app.use('/testing', testEnvRouter);
// catch 404 and forward to error handler
app.use(function(req, res) {
res.status(404).send('404: Page not found');
});
// error handler
app.use(function(err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
app.listen(4000, () => console.log('Server ready on port 4000.'))
export default app;