Created two API endpoints.

This commit is contained in:
Lukian 2024-12-11 13:00:19 +01:00
parent 00e78c2dff
commit 8a61aaa68f
8 changed files with 854 additions and 203 deletions

18
api/shareholders.js Normal file
View 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;