Skip to content
Snippets Groups Projects
Commit 5c18b45f authored by Nayana Mogaveera's avatar Nayana Mogaveera
Browse files

Merge branch 'nayana' into 'development'

commit15-33-sep-05

See merge request !6
parents 5fb8f07b 15216f4c
Branches
No related tags found
1 merge request!6commit15-33-sep-05
......@@ -24,9 +24,9 @@ const createTemplate = async (name, desc, widgets, hashId) => {
};
const getPerticularWidget = async (page) => {
const getParticularTemplate = async (page) => {
try {
const response = await templateService.getPerticularWidget(page);
const response = await templateService.getParticularTemplate(page);
console.log(page,"Pagessssssss");
return { status: '200', response }
} catch (error) {
......@@ -38,5 +38,5 @@ const getPerticularWidget = async (page) => {
module.exports = {
updateAndMapWidget,
createTemplate,
getPerticularWidget
getParticularTemplate
};
......@@ -26,11 +26,11 @@ const createTemplate = async (req, res, next) => {
}
};
const getPerticularWidget = async (req, res) => {
const getParticularTemplate = async (req, res) => {
try {
console.log("GET template details of a particular page");
const { page } = req.params;
const response = await templateBusiness.getPerticularWidget(page);
const response = await templateBusiness.getParticularTemplate(page);
return res.status(response.status).json({ data: response });
} catch (error) {
throw error;
......@@ -40,5 +40,5 @@ const getPerticularWidget = async (req, res) => {
module.exports = {
updateAndMapWidget,
createTemplate,
getPerticularWidget
getParticularTemplate
}
\ No newline at end of file
const templateRouter = require('express').Router();
const { updateAndMapWidget,createTemplate,getPerticularWidget } = require('./controller');
const { updateAndMapWidget,createTemplate,getParticularTemplate } = require('./controller');
templateRouter.put('/:page/widgets/:widgetId', updateAndMapWidget);
templateRouter.post('/createTemplate', createTemplate);
templateRouter.get('/template/:page', getPerticularWidget);
templateRouter.get('/template/:page', getParticularTemplate);
module.exports = templateRouter;
\ No newline at end of file
......@@ -56,11 +56,13 @@ const createTemplate = async (name, desc, widgets, hashId) => {
};
const getPerticularWidget = async (page,res) => {
const getParticularTemplate = async (page,res) => {
try {
const template = await Template.findOne({ name: page}).populate('widgets.widgetId');
if (!template) {
return res.status(404).json({ error: 'Template not found' });
// return res.status(404).json({ error: 'Template not found' });
console.error('Template not found');
res.status(404).send();
}
return template;
} catch (error) {
......@@ -73,5 +75,5 @@ const getPerticularWidget = async (page,res) => {
module.exports = {
updateAndMapWidget,
createTemplate,
getPerticularWidget
getParticularTemplate
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment