feat: add classroomio's server to the monorepo (#168)

* add classroomio server to apps

* ReadME upadte

* Update README.md

* rename project to backend

* fix lock file

---------

Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Adeyemi Adetunji
2024-02-28 03:25:25 +01:00
committed by GitHub
co-authored by Rotimi Best
parent d040f9f12e
commit 3a22a73380
24 changed files with 8177 additions and 62 deletions
+42
View File
@@ -0,0 +1,42 @@
const express = require('express');
const zod = require('zod');
const { generateCoursePdf } = require('../utils/course.js');
const router = express.Router();
// localhost:3002/downloadCourse
router.post('/', async (req, res) => {
try {
// Validate
const mySchema = zod.object({
courseTitle: zod.string(),
orgName: zod.string(),
orgTheme: zod.string(),
lessons: zod.array(
zod.object({
lessonTitle: zod.string(),
lessonNumber: zod.string(),
lessonNote: zod.string(),
slideUrl: zod.string().optional(),
video: zod.string().array().optional(),
})
),
});
console.log('req.body', req.body);
mySchema.parse(req.body);
const pdfBuffer = await generateCoursePdf(req.body);
res.contentType('application/pdf');
res.send(pdfBuffer);
} catch (error) {
console.error('Error', error);
res.status(400).json({
success: false,
error,
});
}
});
module.exports = router;