Skip to content

raphaelpg/thumbnails-to-postgres

Repository files navigation

thumbnails-to-postgres

NodeJS+Postgres+Sharp

Upload an image to a local server, create thumbnails and save the urls to a postgres database.

Features

  • Generate thumbnails via Sharp

Running Locally

Prerequisites

1. Clone the repo and install dependencies

2. Modify the .env file

Save sampledotenv as .env and then add your database user and password.

3. Modify the .env file

Customize the setups in the config file '/src/config/config.ts'.

4. Startup your Postgres

Start your postgres database and run the commands contained in the database.sql file to create the database and two tables.

5. Start the server

Compile with Typescript and run command npm start.

6. Open html and test

Go to http://localhost:8080 with your favorite browser and try the functions:
Upload an image.
The file is saved in the 'build/src/public/uploads' folder.
Thumbnails are created and stored in the 'build/src/public/thumbnails' folder.
Files urls are stored in the database tables.

Get all images: returns the infos of all images uploaded.

Get image by id: returns the infos and the thumbnails urls of a specific image.

About

NodeJS+Postgres+Sharp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published