Example #1
0
/* eslint-disable no-console */
var express = require('express');
var app = new express.Router();

app.post('/sms', function getCb(req, res) {


	console.log(req.body);
	var twiml = [
    			'<?xml version="1.0" encoding="UTF-8" ?>',
    			'<Response>',
    			'  <Message>You said: ' + req.body.Body + '</Message>',
    			'</Response>'
  				].join('');

  res.set('Content-Type', 'text/xml');
  res.send(twiml);



  res.send({ ok: true });
});

module.exports = app;
Example #2
0
module.exports = function(config) {
    var files = config.files;
    var ui = config.ui;
    var framework_dir = config.framework_dir;
    var prj_dir = config.prj_dir;

    var bundle_opts = { debug: true };

    var user_html = '';
    if (config.html) {
        user_html = fs.readFileSync(path.join(prj_dir, config.html), 'utf-8');
    }

    var app = express();

    expstate.extend(app);

    app.set('state namespace', 'zuul');
    app.expose(ui, 'ui');
    app.expose(config.name, 'title');

    app.set('views', __dirname + '/../frameworks');
    app.set('view engine', 'html');
    app.engine('html', require('hbs').__express);

    app.use(function(req, res, next) {
        res.locals.title = config.name;
        res.locals.user_scripts = config.scripts || [];
        res.locals.user_html = user_html;
        next();
    });

    app.use(app.router);

    var bundle_router = new express.Router();

    app.use(bundle_router.middleware);

    // zuul files
    app.use('/__zuul', express.static(__dirname + '/../frameworks'));
    // framework files
    app.use('/__zuul', express.static(framework_dir));

    // any user's files
    app.use(express.static(process.cwd()));

    app.get('/__zuul', function(req, res) {
        res.render('index');
    });

    var map = undefined;

    bundle_router.get('/__zuul/client.js', function(req, res, next) {
        res.contentType('application/javascript');
        create_bundle([framework_dir + '/client.js']).bundle(bundle_opts, function(err, src) {
            if (err) {
                return next(err);
            }

            res.send(src);
        });
    });

    bundle_router.get('/__zuul/test-bundle.map.json', function(req, res, next) {
        res.json(map);
    });

    bundle_router.get('/__zuul/test-bundle.js', function(req, res, next) {
        res.contentType('application/javascript');
        create_bundle(files).bundle(bundle_opts, function(err, src) {
            if (err) {
                return next(err);
            }

            var srcmap = convert.fromSource(src);
            src = convert.removeComments(src);

            if (srcmap) {
                srcmap.setProperty('file', '/__zuul/test-bundle.js');

                src += '//# sourceMappingURL=' + '/__zuul/test-bundle.map.json';
                map = srcmap.toObject();
            }

            res.send(src);
        });
    });

    return app;
};
Example #3
0
'use strict';

import { Router } from 'express';

/**
 * @description Allocation route Controller
 * @param AllocationController
 */
import * as AllocationController from './allocation.controller';

import * as auth from '../auth';

var router = new Router();

// /api/allocations routes configs
router.get('/', auth.validateApiKey(), AllocationController.index);
router.post('/', auth.validateApiKey(), AllocationController.create);

// /api/allocations/:id routes configs
router.put('/:id', auth.validateApiKey(), AllocationController.update);
router.delete('/:id', auth.validateApiKey(), AllocationController.destroy);

module.exports = router;
"use strict";

const Router = require('express').Router;
const router = new Router();
const marketsliveCtrl = require('../lib/controllers/marketsliveCtrl');
const marketsLiveApiCtrl = require('../lib/controllers/marketsLiveApiCtrl');
const auth = require('alphaville-auth-middleware');

router.get('/', marketsliveCtrl.index);
router.get('/about', marketsliveCtrl.about);
router.get(/^\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/, auth(), marketsliveCtrl.byUuid);
router.get(/^\/([0-9]+\-[0-9]+\-[0-9]+-?[0-9]+?\/?)$/, auth(), marketsliveCtrl.byVanity);

router.get('/api/sessions/all', marketsLiveApiCtrl.sessions.all);
router.get('/api/sessions/latest', marketsLiveApiCtrl.sessions.latest);
router.get('/api/sessions/channel', marketsLiveApiCtrl.sessions.channel);

module.exports = router;
Example #5
0
import { Router } from 'express';
import { json } from 'body-parser';
import system from '../../lib/system';

const routes = new Router();
routes.use(json());

routes.get('/', (req, res) => {
  res.status(200).send({
    enabled: system.enabled,
    fps: system.stats.fps,
    maxPixels: system.pixels.length,
  });
});

routes.patch('/', (req, res) => {
  const patch = req.body;
  if ('enabled' in patch) {
    system.enabled = patch.enabled;
  }
  res.status(200).send({});
});

export default routes;
Example #6
0
var express = require('express');
var router = new express.Router();
var Models = require('../models');
var _ = require('lodash');

router.get('/indicators', (req, res, next) => {
  return Models.VitalSignsIndicators.query(qb => qb.select())
  .fetch({
    withRelated: [
      'vitalSignsSection',
      'vitalSignsDataBreaks.vitalSignsColor'
    ]
  })
  .then(rows => rows.toJSON({pretty: true}))
  .then(rows => {
    res.json(rows);
    next();
  });
});

router.post('/boundary', (req, res, next) => {
  var id = JSON.parse(req.body.id);
  return Models.VitalSignsDataPoints.query(qb => qb.select().where({
    vital_signs_indicator_id: id
  })).fetch({
    withRelated: [
      'communityStatisticalArea.boundary',
      'vitalSignsDataBreak.vitalSignsColor'
    ]
  }).then(data => {
    var geo = data.toGeoJSON();
Example #7
0
const {Router} = require('express');
const exams = require('./exams');
module.exports = router = new Router;

router
    .use('/exam', exams)
    .get('/', (req, res) => res.render('site/index'))
Example #8
0
function barcodeRoute() {
  var barcode = new express.Router();
  barcode.use(cors());
  barcode.use(bodyParser());

  barcode.all('/recent', function(req, res) {
    logger.info('************************');
    logger.info('/barcode/recent');

    // Check if we have recent searches in cache
    fh.cache({act : 'load', key : 'barcode-recent'}, function (err, cacheRes) {
      if(err || !cacheRes) {
        logger.info('No cached data for recent barcodes - calling barcode service');
        fh.service({guid : services.barcode, path : '/barcode/recent' , method : 'GET'},
          function(err, body, serviceRes) {
//            logger.debug('Res Status Code = ',  serviceRes.statusCode);
            if (err || (serviceRes && serviceRes.statusCode != 200)) {
              logger.warn('Error calling barcode service - Error = ', err, " - body = ", body);
              return res.status(500).send({"error":"Unable to reach barcode microservice", "body":body});
            } else {
              var barcodeSearches = JSON.stringify(body);
              logger.info('Returning service data for recent barcode searches: ' + barcodeSearches);

              // Cache the recent barcode searches for 10 seconds
              fh.cache({act : 'save', key : 'barcode-recent', value : barcodeSearches, expire : 10}, function (err, cacheRes) {
                return res.json(JSON.parse(barcodeSearches));
              });
            }
          }
        );
      } else {
        logger.info('Returning cached data for recent barcode searches: ' + cacheRes);
        return res.json(JSON.parse(cacheRes));
      }
    });
  });

  barcode.all('/read', function(req, res) {
    logger.info('************************');
    logger.info('/barcode/read');

    var barcodeId = req.query.barcode || req.body.barcode;
    logger.info('barcodeId = ' + barcodeId);

    // Check if we have data on this barcode in cache
    fh.cache({'act':'load','key':'barcode-' + barcodeId}, function (err, cacheRes) {
      if(err || !cacheRes) {
        logger.info('No cached data for barcode - calling barcode service');
        fh.service({guid : services.barcode, path : '/barcode/read', method : 'GET',params : {barcode : barcodeId}},
          function(err, body, barcodeServiceRes) {
            if (err || (barcodeServiceRes && barcodeServiceRes.statusCode != 200)) {
              logger.warn('Error calling barcode service - ' + err);
              return res.status(500).send({"error":"Unable to reach barcode microservice", "msg":err});
            } else {
              logger.info('Response from Barcode Sercice = ', body);

              var barcodeInfo = {}
              if( body && body.code === 'NO-BARCODE') {
                return barcodeInfo = setUnknownBarcodeInfo(barcodeInfo, res);
              }

              // Potentially more then one item can be returned for a barcode - just take the first one
              barcodeInfo = body[0];

              if(barcodeInfo && barcodeInfo.imageurl && barcodeInfo.imageurl != 'N/A') {
                logger.info('Calling image service to get base64 encoded data for barcode item image');
                fh.service({guid : services.image, path : '/image', method : 'GET', params : {url : barcodeInfo.imageurl, base64 : true}},
                  function(err, body, imageServiceRes) {
                    if (err || (imageServiceRes && imageServiceRes.statusCode && imageServiceRes.statusCode != 200)) {
                      logger.warn('Error calling image service. Returning "unknown" image. Err = ' + err);
                      barcodeInfo.imagebase64 = getUnknownImage();
                      return returnBarcodeInfo(barcodeId, barcodeInfo, res);
                    } else {
                      var mimeType = mime.lookup(barcodeInfo.imageurl);
                      logger.info('mime type of image = ' + mimeType);
                      var base64Image = 'data:' + mimeType + ';base64,' + body

                      // Store the base64 encoded image in the object
                      barcodeInfo.imagebase64 = base64Image;
                      return returnBarcodeInfo(barcodeId, barcodeInfo, res);
                    }
                  }
                );
              } else {
                barcodeInfo.imagebase64 = getUnknownImage();
                return returnBarcodeInfo(barcodeId, barcodeInfo, res);
              }
            }
          }
        );
      } else {
        // Trim the log data so the full base64 image is not pumped into the logs
        logger.info('Returning cached data for barcode : ' + cacheRes.substring(0,256) + '...');
        return res.json(JSON.parse(cacheRes));
      }
    });
  });

  return barcode;
}
import { Router } from 'express'
import validate from 'express-validation'
import jwt from 'express-jwt'

import config from '../config'
import validator from '../validators/users.validator'
import controller from '../controllers/users.controller'

const auth = jwt({
  secret: config.jwt.secret,
})
const router = new Router()

router.route('/me')
  .get(auth, controller.me)
  .put(auth, validate(validator.update), controller.update)

export default router
Example #10
0
'use strict';

import {Router} from 'express';
import * as controller from './attendance.controller';
import * as auth from '../../auth/auth.service';

var router = new Router();

router.get('/',       auth.isAuthenticated(), controller.index);
router.get('/:id',    auth.isAuthenticated(), controller.show);
router.post('/',      auth.isAuthenticated(), controller.create);
router.put('/:id',    auth.isAuthenticated(), controller.update);
router.patch('/:id',  auth.isAuthenticated(), controller.update);
router.delete('/:id', auth.isAuthenticated(), controller.destroy);

router.post('/quickset', auth.hasRole('admin'),  controller.quickSet);

export default router;
Example #11
0
var express = require('express');
var buildPayment = require(__dirname+'/lib/build_payment');

var router = new express.Router();
router.use('/', express.static(__dirname+'/public'));
/*router.use('/buy-xrp', function(request, response) {
  response.render('buy-xrp');
});
*/

router.get('/bridge/payments/:alipay_username/:amount', buildPayment);

module.exports =  router;

Example #12
0
File: private.js Project: ffis/sici
	function Api(metaenvironment){
		const app = new express.Router();
		app.get('/permisosList', metaenvironment.permiso.permisosList);
		app.get('/permisosList/:idjerarquia/:recursivo', metaenvironment.permiso.permisosList);

		app.get('/permisosDirectosProcedimientoList/:codigoprocedimiento', metaenvironment.permiso.permisosDirectosProcedimientoList);
		app.get('/permisosProcedimientoList/:codigoprocedimiento', metaenvironment.permiso.permisosProcedimientoList);

		app.get('/permisosDirectosEntidadObjetoList/:codigoentidadobjeto', metaenvironment.permiso.permisosDirectosEntidadObjetoList);
		app.get('/permisosEntidadObjetoList/:codigoentidadobjeto', metaenvironment.permiso.permisosEntidadObjetoList);

		app.put('/permisos/:id', metaenvironment.permiso.update);
		app.get('/permisos/:id', metaenvironment.permiso.get);
		app.delete('/permisos/:id', metaenvironment.permiso.removePermiso);
		app.post('/permisos', metaenvironment.permiso.create);

		app.get('/permisosByLoginPlaza/:login/:cod_plaza', metaenvironment.permiso.permisosByLoginPlaza);
		app.get('/personasByPuesto/:cod_plaza', metaenvironment.persona.personasByPuesto);
		app.get('/personasByLogin/:login', metaenvironment.persona.personasByLogin);
		app.get('/personasByRegexp/:regex', metaenvironment.persona.personasByRegex);

		//cambiar por post
		app.get('/permisos/delete-jerarquia/:idpermiso/:idjerarquia', metaenvironment.permiso.removePermisoJerarquia);
		app.get('/permisos/delete-procedimiento/:idpermiso/:idprocedimiento', metaenvironment.permiso.removePermisoJerarquia);
		app.get('/permisosdelegar/:login/:cod_plaza', metaenvironment.permiso.delegarpermisos);
		app.get('/permisosdelegar/:login/:cod_plaza/:procedimiento', metaenvironment.permiso.delegarpermisosProcedimiento);

		app.get('/persona/:id', metaenvironment.persona.get);

		this.app = app;
	}
'use strict';
const express = require('express');
const moment = require('moment');

const router = new express.Router();

// Redirect to start page
router.get('/', (req, res) => {
  res.redirect('/version-6/start');
});

// Start page
router.get('/start', (req, res) => {
  res.cookie('checklist', {
    bsp: 'No',
    sffp: 'No',
    ihtax: 'No'
  });
  res.render('version-6/start-page.html');
});

router.post('/start', (req, res) => {
  res.redirect('details-partner');
});

// About the deceased person
router.get('/details-partner', (req, res) => {
  res.render('version-6/details-partner.html');
});

router.post('/details-partner', (req, res) => {
Example #14
0
var express			= require('express');
var bodyParser		= require('body-parser')

// Metrics - TODO - move to a small app with one dyno
require('./lib/metrics/sqsAttributes');
require('./lib/metrics/cloudwatch');

const PORT		= process.env.PORT || 5101; 

var app = express();

var ingest = new express.Router();

ingest.use(bodyParser.raw({ limit: '50kb', type: 'application/json' }));
ingest.use(require('./lib/middleware/stats'));
ingest.use(require('./lib/middleware/anonymous-uuid'));
ingest.use('/',	require('./lib/middleware/response'));

app.use('/px.gif', ingest);
app.use('/ingest', ingest);

// FIXME - handle errors, 404s etc.

app.listen(PORT, function() {
    console.log("Server listening on: http://localhost:%s", PORT);
});
Example #15
0
const express = require('express')
const passport = require('passport')
const validator = require('validator')

const router = new express.Router()

function validateSignupForm (payload) {
  const errors = {}
  let isFormValid = true
  let message = ''

  if (!payload || typeof payload.email !== 'string' || !validator.isEmail(payload.email)) {
    isFormValid = false
    errors.email = 'Please provide a correct email address.'
  }

  if (!payload || typeof payload.password !== 'string' || payload.password.trim().length < 4) {
    isFormValid = false
    errors.password = 'Password must have at least 4 characters.'
  }

  if (!payload || typeof payload.name !== 'string' || payload.name.trim().length === 0) {
    isFormValid = false
    errors.name = 'Please provide your name.'
  }

  if (!isFormValid) {
    message = 'Check the form for errors.'
  }

  return {
Example #16
0
function todoRoute() {
  var todo = new express.Router();
  todo.use(cors());
  todo.use(bodyParser());


  // REST GET: List todo entries
  todo.get('/', function(req, res) {
    return todoLib.list(function(err, listResult){
      if (err){
        return res.status(500).json(err);
      }
      return res.json(listResult);
    });
  });

  // REST POST: Create a single todo entry
  todo.post('/', function(req, res) {
    var itemName = req.body.name;
    
    if (!itemName){
      return res.status(400).json({ error : 'Todo entries must have a name' });
    }
    
    return todoLib.create(itemName, function(err, createResult){
      if (err){
        return res.status(500).json(err);
      }
      return res.json(createResult);
    });
  });
  
  // REST GET by ID: Read a single todo entry
  todo.get('/:id', function(req, res) {
    var idToRead = req.params.id;
    return todoLib.read(idToRead, function(err, readResult){
      if (err){
        return res.status(500).json(err);
      }
      return res.json(readResult);
    });
  });
  
  // PUT by ID: Update a single todo entry
  todo.put('/:id', function(req, res){
    var idToUpdate = req.params.id,
    updatedName = req.body.name;
    
    if (!updatedName){
      return res.status(400).json({ error : 'Todo entries must have a name' });
    }
    
    return todoLib.update(idToUpdate, updatedName, function(err, updateResult){
      if (err){
        return res.status(500).json(err);
      }
      return res.json(updateResult);
    });
  });
  
  // DELETE by ID: Delete a single todo entry
  todo['delete']('/:id', function(req, res){
    var idToDelete = req.params.id;
    return todoLib['delete'](idToDelete, function(err, deleteResult){
      if (err){
        return res.status(500).json(err);
      }
      return res.json(deleteResult);
    });
  });
  
  return todo;
}
Example #17
0
'use strict';

let express = require('express');
let router = new express.Router();
let passport = require('../lib/passport');
let lists = require('../lib/models/lists');
let segments = require('../lib/models/segments');
let tools = require('../lib/tools');

router.all('/*', (req, res, next) => {
    if (!req.user) {
        req.flash('danger', 'Need to be logged in to access restricted content');
        return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
    }
    res.setSelectedMenu('lists');
    next();
});

router.get('/:list', (req, res) => {
    lists.get(req.params.list, (err, list) => {
        if (err) {
            req.flash('danger', err.message || err);
            return res.redirect('/');
        }

        if (!list) {
            req.flash('danger', 'Selected list ID not found');
            return res.redirect('/');
        }

        segments.list(list.id, (err, rows) => {
Example #18
0
var express = require('express');
var router = new express.Router();
var user = require('../controllers/user');
var groups = require('../controllers/groups');
var auth = require('../controllers/auth');

/*
 ---------- /api/v1 API ------------
 Every url added to router is prefaced by /api/v1
 See ./routes/coffee for routes

 v1 user. Requires x-api-user (user id) and x-api-key (api key) headers, Test with:
 $ cd node_modules/racer && npm install && cd ../..
 $ mocha test/user.mocha.coffee
 */

var verifyTaskExists = user.verifyTaskExists
var cron = user.cron;

router.get('/status', function(req, res) {
  return res.json({
    status: 'up'
  });
});

/* Scoring*/
router.post('/user/task/:id/:direction', auth.auth, cron, user.scoreTask);
router.post('/user/tasks/:id/:direction', auth.auth, cron, user.scoreTask);

/* Tasks*/
router.get('/user/tasks', auth.auth, cron, user.getTasks);
Example #19
0
var express = require( "express" );
var passport = require( "passport" );
var router = new express.Router();

router.use( passport.initialize() );
router.use(passport.session());

require( "../middleware/passport" )( passport )

// Redirect the user to Facebook for authentication.  When complete,
// Facebook will redirect the user back to the application at
//     /auth/facebook/callback
router.get( "/facebook", passport.authenticate( "facebook" ) );

// Facebook will redirect the user to this URL after approval.  Finish the
// authentication process by attempting to obtain an access token.  If
// access was granted, the user will be logged in.  Otherwise,
// authentication has failed.
router.get(
	"/facebook/callback",
    passport.authenticate( "facebook", 
    	{

    		successRedirect: "/leaf",
            failureRedirect: "/"

        }
    )
);

// GET /auth/google
Example #20
0
import { Router } from 'express';
import * as eventsController from '../controllers/eventsController';


const router = new Router();
router.route('/events').get(eventsController.getEvents);


export default router;
Example #21
0
import { Router } from 'express';
import dictionaryController from '../controllers/dictionaryController';
import searchController from '../controllers/searchController';
import weatherController from '../controllers/weatherController';
import calculatorController from '../controllers/calculatorController';
import mongoController from '../controllers/mongoController';
import youtubeController from '../controllers/youtubeController';
import yelpController from '../controllers/yelpController';
import quotesController from '../controllers/quotesController';
import mapsController from '../controllers/mapsController';
// import redis from '../../dictionary/redisDictionary';

const router = new Router();

router.route('/api/dict').post(dictionaryController.getDefinition);
router.route('/api/thes').post(dictionaryController.getSynonyms);

router.route('/api/searches/').post(searchController.getSearch);
router.route('/api/news/').post(searchController.getNews);
router.route('/api/website/').post(searchController.getWebsite);
router.route('/api/images/').post(searchController.getImages);

router.route('/api/weather').post(weatherController.getWeather);

router.route('/api/calculate').post(calculatorController.getCalculation);

router.route('/api/writemongo').post(mongoController.writeWord);
router.route('/api/searchmongo').post(mongoController.searchWord);

router.route('/api/youtube').post(youtubeController.searchVideo);
Example #22
0
'use strict';

import {Router} from 'express';
import * as controller from './user.controller';
import * as auth from '../../auth/auth.service';

var router = new Router();

router.get('/me', auth.isAuthenticated(), controller.me);
router.post('/', controller.create);



module.exports = router;
Example #23
0
import { Router }        from 'express'
import { NotFoundError } from '../../../src/error'
import { Team }          from '../../../models'

let router = new Router
export default router

router.get('/teams', async(req, res, next) => {
  let teams = await Team.find(req.query).lean(true).exec()

  res.send({ teams })
})

router.get('/teams/:id', async(req, res, next) => {
  let team = await Team.findById(req.params.id).lean(true).exec()

  if (!team) {
    throw new NotFoundError
  }

  res.send({ team })
})

router.post('/teams', async(req, res, next) => {
  let team = new Team(req.body.team)

  await team.save()

  res.status(201)
  res.pushModel({ team })
})
const express = require('express');
const router = new express.Router();

const helpers = require('../helpers');
const AgencyService = require('../services/AgencyService');

const services = {};
let setUpServices = (config) => {
  services.agency = services.agency || new AgencyService(config);

  setUpServices = () => {};
};

const createAgenciesViewModel = (agencies) =>
  ({
    columns: [
      'id',
      'type',
    ],
    links: {
      id: 'ref',
      type: 'ref',
    },
    agencies: (agencies || []),
    recordCount: (agencies || []).length || 0,
  });

const createAgencyTypesViewModel = (types) =>
  ({
    columns: [
      'id',
Example #25
0
import { Router } from 'express'
import { models } from 'lib/database'
import restful from 'controllers/restful'

const { index, show, create, update, remove } = restful(models.menu)
const router = new Router()

router.get('/', index)
router.get('/:id', show)
router.post('/', create)
router.put('/:id', update)
router.delete('/:id', remove)

export default router

Example #26
0
app.use('/router', (req: express$Request, res: express$Response, next: express$NextFunction) => {
  router.handle(req, res, next);
});
Example #27
0
import { Router } from 'express';

import AuthController from '../controllers/AuthController';
import checkForParams from '../middleware/checkForParams';

const controller = new AuthController();
const router = new Router();

router.route('/tokens')
  .post(checkForParams(['email', 'password']), controller.postToken);
router.route('/signUpEmail')
  .post(checkForParams(['email', 'password']), controller.postSignUpEmail);

export default router;
Example #28
0
'use strict';

import { Router } from 'express';
import Mraa from 'mraa';
import Gate from './gate';

const router = new Router;
const gate = new Gate;

router.get('/open', (req, res) => {
  gate.open();
  res.status(200).end();
});

router.get('/close', (req, res) => {
  gate.close();
  res.status(200).end();
});

export default router;
Example #29
0
import { Router } from 'express';
import Controller from '../controllers/notification';

let router = new Router();

router.post('/send', Controller.send);

export default router;
Example #30
0
import {Router} from 'express';
import config from '../../config/config';
import RedisCache from '../../redis/RedisCache';
import logger from '../../utils/logger';
import Lesson from '../models/Lesson';
import Course from '../models/Course';

const router = new Router();

router.get('/', async (req, res, next) => {
  try {
    const page = req.query.page || 1;
    const limit = req.query.limit || config.pagination.defaultSize;
    const {courseNo, hasListen, hasTranslate} = req.query;
    const query = {};
    query.courseNo = courseNo;
    if (hasListen) {
      query.hasListen = hasListen;
    }
    if (hasTranslate) {
      query.hasTranslate = hasTranslate;
    }
    query.publishedDate = {$lt: new Date()};
    const result = await Lesson.paginate(query, {page, limit, sort: {lessonNo: -1}});
    const course = await Course.findOne({courseNo});
    result.course = course;
    res.send(result);
  } catch (err) {
    next(err);
  }
});