generated from lucien/api-template
19 lines
No EOL
555 B
JavaScript
19 lines
No EOL
555 B
JavaScript
const express = require('express');
|
|
const sha256 = require("sha256");
|
|
const { getConnection, getUser, addUser } = require('../libs/mysql');
|
|
|
|
const router = express.Router();
|
|
|
|
router.get('/:id', async (req, res) => {
|
|
const id = req.params.id;
|
|
const connection = await getConnection();
|
|
const users = await getUser(connection, id);
|
|
connection.end();
|
|
if (users[0]) {
|
|
res.send({id: users[0].id, username: users[0].username, admin: users[0].admin});
|
|
} else {
|
|
res.send('No user found');
|
|
}
|
|
});
|
|
|
|
module.exports = router; |