23 lines
511 B
JavaScript
23 lines
511 B
JavaScript
|
const express = require('express')
|
||
|
const router = express.Router()
|
||
|
const Vegetables = require('../middleware/Vegetables')
|
||
|
|
||
|
module.exports = function () {
|
||
|
const basePath = '/api/search/vegetables'
|
||
|
|
||
|
router.route(basePath)
|
||
|
.get(
|
||
|
function (req, res) {
|
||
|
Vegetables.searchAll(req, function (err, items) {
|
||
|
if (err) {
|
||
|
res.status(items || 500).send(err.message)
|
||
|
} else {
|
||
|
res.status(200).json(items)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
)
|
||
|
|
||
|
return router
|
||
|
}
|