Skip to content

Instantly share code, notes, and snippets.

@w3cj
Created December 8, 2016 20:02
Show Gist options
  • Save w3cj/47149222e1c52fc521ae899dcdbabac3 to your computer and use it in GitHub Desktop.
Save w3cj/47149222e1c52fc521ae899dcdbabac3 to your computer and use it in GitHub Desktop.
const express = require('express');
const bodyParser = require('body-parser');
require('dotenv').config();
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const knex = require('./db/knex');
// Your routes go here!
app.get('/entity_name_here', (req, res) => {
knex('table_name_here')
.then(entities => {
res.json(entities);
})
});
const port = process.env.PORT || 3000;
app.listen(port, () =>{
console.log(`Listening on ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment