Files
classroomio/apps/backend/server.js
T
Em_DevandRotimi Best 3fe15e6633 feat: remove defer (#243)
* working on moving the email logic to the backend

* Moved nodemailer to the backend

* uninstall defer

* updated relative import path in tsconfig

* working on the zod validation

* Merge branch 'main' into send-email

* fixed the zod import issue

* fixed the zod import issue

* updated the env example files

* docs: update README.md (#249)

* fix: handle catex error

* chore: remove fly.io github action

* Update README.md

Updated the Readme to reflect changes made to the emailing flow

---------

Co-authored-by: Rotimi Best <best@classroomio.com>

* chore: wrapp up email sending

---------

Co-authored-by: Rotimi Best <best@classroomio.com>
2024-04-12 04:57:19 +01:00

51 lines
1.3 KiB
JavaScript

require('dotenv').config();
const express = require('express');
const rateLimit = require('express-rate-limit');
const cors = require('cors');
const bodyParser = require('body-parser');
const uploadVideo = require('./src/routes/uploadVideo');
const downloadCertificate = require('./src/routes/downloadCertificate');
const downloadLesson = require('./src/routes/downloadLesson');
const downloadCourse = require('./src/routes/downloadCourse');
const katex = require('./src/routes/katex');
const sendEmail = require('./src/routes/sendEmail');
// Express server
const app = express();
const port = process.env.PORT || 3002;
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
// Rate limiting middleware
const limiter = rateLimit({
windowMs: 1000,
max: 10
});
app.use(limiter);
app.use('/downloadCertificate', downloadCertificate);
app.use('/downloadLesson', downloadLesson);
app.use('/downloadCourse', downloadCourse);
app.use('/uploadVideo', uploadVideo);
app.use('/katex', katex);
app.use('/sendEmail', sendEmail);
app.get('/', (req, res) => {
res.send('Welcome to ClassroomIO');
});
app.listen(port, () => {
console.log(`ClassroomIO Backend listening on port ${port}!`);
});
process.on('uncaughtException', (err) => {
console.error('Uncaught error, err');
});