mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 19:57:06 +00:00
32 lines
707 B
JavaScript
32 lines
707 B
JavaScript
const express = require('express')
|
|
const bodyParser = require('body-parser')
|
|
const db = require('./queries')
|
|
|
|
const app = express()
|
|
const port = 3000
|
|
|
|
const getRealEstates = (request, response) => {
|
|
pool.query('SELECT * FROM real_estae ORDER BY id ASC', (error, results) => {
|
|
if (error) {
|
|
throw error
|
|
}
|
|
response.status(200).json(results.rows)
|
|
})
|
|
}
|
|
|
|
app.use(bodyParser.json());
|
|
app.use(
|
|
bodyParser.urlencoded({
|
|
extended: true,
|
|
})
|
|
);
|
|
|
|
app.get('/', (request, response) => {
|
|
response.json({ info: 'Node.js, Express, and Postgres API' })
|
|
});
|
|
|
|
app.get('/real-estate', db.getAllRealEstate);
|
|
|
|
app.listen(port, () => {
|
|
console.log(`App running on port ${port}.`)
|
|
}); |