2023-02-04 20:08:28 -05:00
|
|
|
const express = require('express');
|
2023-02-05 23:05:07 -05:00
|
|
|
const dbConnect = require('../models/dbConnect');
|
|
|
|
|
const path = require('path');
|
2023-02-06 13:28:21 -05:00
|
|
|
const cors = require('cors');
|
2023-02-12 16:38:33 -05:00
|
|
|
const routes = require('./routes');
|
2023-02-04 20:08:28 -05:00
|
|
|
const app = express();
|
2023-03-06 10:15:07 -05:00
|
|
|
const port = process.env.PORT || 3050;
|
|
|
|
|
const projectPath = path.join(__dirname, '..', '..');
|
2023-02-12 16:38:33 -05:00
|
|
|
dbConnect().then(() => console.log('Connected to MongoDB'));
|
|
|
|
|
|
2023-02-05 15:26:59 -05:00
|
|
|
app.use(cors());
|
2023-02-04 20:08:28 -05:00
|
|
|
app.use(express.json());
|
|
|
|
|
app.use(express.static(path.join(projectPath, 'public')));
|
|
|
|
|
|
|
|
|
|
app.get('/', function (req, res) {
|
|
|
|
|
console.log(path.join(projectPath, 'public', 'index.html'));
|
|
|
|
|
res.sendFile(path.join(projectPath, 'public', 'index.html'));
|
|
|
|
|
});
|
|
|
|
|
|
2023-02-12 16:38:33 -05:00
|
|
|
app.use('/ask', routes.ask);
|
|
|
|
|
app.use('/messages', routes.messages);
|
|
|
|
|
app.use('/convos', routes.convos);
|
2023-03-04 17:39:06 -05:00
|
|
|
app.use('/customGpts', routes.customGpts);
|
2023-02-12 16:38:33 -05:00
|
|
|
app.use('/prompts', routes.prompts);
|
2023-02-04 20:08:28 -05:00
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
|
console.log(`Server listening at http://localhost:${port}`);
|
2023-02-12 16:38:33 -05:00
|
|
|
});
|