Skip to content

Instantly share code, notes, and snippets.

@fhsinchy
Last active May 11, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhsinchy/aa0b4b32a27ab41b99faec665452c0ea to your computer and use it in GitHub Desktop.
Save fhsinchy/aa0b4b32a27ab41b99faec665452c0ea to your computer and use it in GitHub Desktop.
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