Skip to content

Instantly share code, notes, and snippets.

@LukaHarambasic
Created April 17, 2019 12:42
Show Gist options
  • Save LukaHarambasic/65a0e37e30fde9bea9ccc6c4153780d7 to your computer and use it in GitHub Desktop.
Save LukaHarambasic/65a0e37e30fde9bea9ccc6c4153780d7 to your computer and use it in GitHub Desktop.
now-express
const bodyParser = require( 'body-parser' )
const express = require( 'express' )
const morgan = require( 'morgan' )
const { Client } = require( 'pg' )
const squel = require( 'squel' )
console.log('START')
const CLIENT = new Client({
<<TOP-SECRET>>
})
CLIENT.connect()
console.log('CONNECTING')
const PORT = process.env.PORT || 3000
const APP = express()/*
APP.use(morgan('combined'))
APP.use(bodyParser.json())
APP.use(bodyParser.urlencoded({ extended: true })) */
console.log('USE')
APP.get('/', async (req, res) => {
console.log('REQUEST')
res.send('IT WORKS')
/* try {
const users = await CLIENT.query('SELECT * FROM users')
res.send(users.rows.map((user) => user.name))
} catch (error) {
console.log(error)
res.status(500).send(error)
} */
})
APP.listen(PORT, () => {
console.log(`>>>>Server is running on http://localhost:${PORT}`)
})
module.exports = APP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment