This PR mainly refactors the code by extracting a "core" package which is then used by the "backend" and "frontend" apps. Apart from this the PR also contains several smaller changes like fixing dependabot, upgrading dependencies, aligned "package.json" files, added tests, ... addresses step 1 of #32 closes #136 --------- Co-authored-by: Marco Pasqualetti <marco.pasqualetti@live.com>
29 lines
644 B
JavaScript
29 lines
644 B
JavaScript
import { logger } from "@stats-organization/github-readme-stats-core";
|
|
|
|
import { getUserAccessByKey } from "../src/common/database.js";
|
|
|
|
/**
|
|
* @param {any} req The request.
|
|
* @param {any} res The response.
|
|
*/
|
|
export default async (req, res) => {
|
|
const { user_key } = req.query;
|
|
try {
|
|
const result = await getUserAccessByKey(user_key);
|
|
|
|
if (!result) {
|
|
res.statusCode = 404;
|
|
res.send("user not found");
|
|
return;
|
|
}
|
|
|
|
res.send({
|
|
privateAccess: result.privateAccess,
|
|
token: result.token,
|
|
});
|
|
} catch (err) {
|
|
logger.error(err);
|
|
res.send("Something went wrong: " + err.message);
|
|
}
|
|
};
|