-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #710 from OneCommunityGlobal/revert-709-revert-708…
…-development Revert "Revert "Backend Release to Main [1.34]""
- Loading branch information
Showing
7 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const bmNewLessonController = function (BuildingNewLesson) { | ||
const bmGetLessonList = async (req, res) => { | ||
try { | ||
BuildingNewLesson | ||
.find() | ||
.populate() | ||
.then(result => res.status(200).send(result)) | ||
.catch(error => res.status(500).send(error)); | ||
} catch (err) { | ||
res.json(err); | ||
} | ||
}; | ||
const bmPostLessonList = async (req, res) => { | ||
try { | ||
const newLesson = BuildingNewLesson.create(req.body) | ||
.then(result => res.status(201).send(result)) | ||
.catch(error => res.status(500).send(error)); | ||
} catch (err) { | ||
res.json(err); | ||
} | ||
}; | ||
return { bmPostLessonList, bmGetLessonList }; | ||
}; | ||
|
||
module.exports = bmNewLessonController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const { Schema } = mongoose; | ||
|
||
const buildingNewLesson = new Schema({ | ||
title: { type: String, required: true, maxLength: 20 }, | ||
content: { type: String, required: true, maxLength: 500 }, | ||
date: { type: Date, required: true, default: Date.now() }, | ||
author: { type: mongoose.SchemaTypes.ObjectId, ref: 'userProfile', required: true }, | ||
tags: [{ type: String, required: true, maxLength: 10 }], | ||
relatedProject: { type: mongoose.SchemaTypes.ObjectId, ref: 'buildingProject', required: true }, | ||
}); | ||
|
||
module.exports = mongoose.model('buildingNewLesson', buildingNewLesson, 'buildingNewLessons'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const express = require('express'); | ||
|
||
const routes = function (buildingNewLesson) { | ||
const NewLessonRouter = express.Router(); | ||
const controller = require('../../controllers/bmdashboard/bmNewLessonController')(buildingNewLesson); | ||
|
||
// having GET request just for testing: | ||
NewLessonRouter.route('/lessons') | ||
.get(controller.bmGetLessonList); | ||
|
||
NewLessonRouter.route('/lessons/new') | ||
.post(controller.bmPostLessonList); | ||
return NewLessonRouter; | ||
}; | ||
module.exports = routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters