generated from lucien/api-template
18 lines
493 B
JavaScript
18 lines
493 B
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const { getConnection, getShareholders } = require("../libs/mysql.js")
|
|
|
|
router.get('/', async (req, res) => {
|
|
const connection = await getConnection()
|
|
const shareholders = await getShareholders(connection)
|
|
connection.end()
|
|
|
|
if (!shareholders[0]) {
|
|
return res.status(500).send({message: "There are no shareholders in the databse."})
|
|
}
|
|
|
|
return res.status(200).send(shareholders)
|
|
});
|
|
|
|
module.exports = router;
|
|
|