Changed functions in database/utils.ts

This commit is contained in:
Lynixen
2024-11-06 21:35:41 +01:00
parent 064b864246
commit f45945474d
2 changed files with 44 additions and 12 deletions

View File

@@ -18,19 +18,19 @@ const app = new Application();
// Example: localhost:8000/api will show "testAPIPoint"
// in the HTML
router
.get("/", (ctx) => {
.get("/", (ctx):void => {
ctx.response.body = "ESP API Site";
})
.get("/api", (ctx) => {
.get("/api", (ctx):void => {
ctx.response.body = "testAPIPoint";
})
.get("/api/users", (ctx) => {
const getUsers = db_utils.getAllUsersFromDB();
.get("/api/users", async (ctx):Promise<void> => {
const getUsers = await db_utils.getAllUsersFromDB();
ctx.response.body = getUsers; //getAllUsers();
})
.get("/api/posts", async (ctx) => {
.get("/api/posts", async (ctx):Promise<void> => {
const getPosts = await db_utils.getPostsFromDB();
const countedPosts = await db_utils.countPosts();
const countedPosts:number = await db_utils.countPosts();
ctx.response.body = { getPosts, countedPosts };
});