generated from lucien/api-template
Created two API endpoints.
This commit is contained in:
parent
00e78c2dff
commit
8a61aaa68f
8 changed files with 854 additions and 203 deletions
18
api/shareholders.js
Normal file
18
api/shareholders.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
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;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue