Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

PostgreSQL example

A simple user app using tinyhttp and PostgreSQL.

Setup

Clone the example

tinyhttp new postgresql

Install PostgreSQL

PostgreSQL Wiki has a good list of guides for installing postgres on different operating systems.

Create a database

Use createdb to create a database

createdb [dbname]

Create .env file

touch .env

Then add DB_CONNECTION=<POSTGRESQL_URL> to the .env file. PostgreSQL URL is broken down to:

postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName

Run

node index.js

Endpoints

  • GET /users - list users

  • GET /users/:id - get user by id

  • POST /users - create a user from a provided name

  • DELETE /users - delete a user with specified id

  • PUT /users - update a user by ID from a provided name