Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require("express");
- const knex = require("knex");
- const bodyParser = require("body-parser");
- const staticAssets = __dirname + "/public";
- const db = knex({
- client: "mysql",
- connection: {
- host: "127.0.0.1",
- user: "root",
- database: "testing-app"
- }
- })
- express()
- .use(bodyParser.json())
- .set("view engine", "hjs")
- .use(express.static(staticAssets))
- .get("/", (req, res, next) => {
- db("users").then((users) => {
- res.render("users", {
- title: "All Users",
- users: users,
- })
- })
- })
- .get("/viewtweets/:user_id", (req, res, next) => {
- db("tweets").then((tweets) => {
- res.render("tweets", {
- title: "My tweets",
- tweets
- })
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement