- App using nodejs with express middleware to connect to a PostgreSQL database and make Create, Read, Update & Delete (CRUD) operations of user data
- Note: to open web links in a new window use: ctrl+click on link
- General info
- Screenshots
- Technologies
- Setup
- Code Examples
- Features
- Status
- Inspiration
- Licence
- Contact
- PostgreSQL needs to be installed and running - I started it from my Windows 10 PostgreSQL 12 dropdown option 'SQL shell (psql)'
- PostgreSQL shell commands:
\llist all databases.\c database1connect to database1.\dtinspect tables.\d userssee detail of table with name users.\qto quit. - Src (source) folder contains raw code in typescript. Dist (distribution) folder will contain minified/concatenated javascript code for production
- tsc --watch command used to run local compiler in watch mode
- PostgreSQL v12 database
- PostgreSQL Installer for Windows
- Express.js middleware v4
- Postman to perform CRUD operations on backend database
- Create PostgreSQL database and add access credentials to your own
src/routes/config.tsfile (seeconfig.example.ts) - Add a
/distfolder at same level as/srcfolder - Run
npm installto install dependencies - Run
npm run devto compile app and connect to serverlocalhost: 3000 - Run
npm run buildto compile app
- code to fetch a user from the Postgres database using id
export const getUserById = async (
req: Request,
res: Response
): Promise<Response> => {
const id = parseInt(req.params.id);
const response: QueryResult = await pool.query(
"SELECT * FROM users WHERE id = $1",
[id]
);
return res.json(response.rows);
};- PostgreSQL access credentials hidden from GitHub in
configfile - Postman used to perform CRUD operations on PostgreSQL database
- Status: Fully working basic CRUD app
- To-do: nothing
- N/A
- Repo created by ABateman, email: gomezbateman@yahoo.com
