Last active
May 11, 2021 16:48
-
-
Save fhsinchy/aa0b4b32a27ab41b99faec665452c0ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Status } from "https://deno.land/x/oak@v6.5.0/mod.ts"; | |
import client from "../db/mysql.ts"; | |
export async function index(ctx: any) { | |
const blogs: any = (await client.execute("SELECT * FROM blogs")).rows; | |
ctx.response.status = Status.OK; | |
ctx.response.type = "json"; | |
ctx.response.body = { | |
status: "success", | |
message: `${blogs.length} blogs found in database`, | |
data: { blogs }, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment