https://github.com/giorgimakharadze/file-image-upload-nodejs-typescript
https://file-image-upload-diiv.onrender.com
https://github.com/giorgimakharadze/file-image-upload-nodejs-typescript
express javascript mongodb mongoos nodejs typescipt
Last synced: about 2 months ago
JSON representation
https://file-image-upload-diiv.onrender.com
- Host: GitHub
- URL: https://github.com/giorgimakharadze/file-image-upload-nodejs-typescript
- Owner: GiorgiMakharadze
- Created: 2023-04-16T11:08:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-16T14:06:31.000Z (about 2 years ago)
- Last Synced: 2025-01-10T23:19:34.487Z (3 months ago)
- Topics: express, javascript, mongodb, mongoos, nodejs, typescipt
- Language: TypeScript
- Homepage:
- Size: 756 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Project Title
## Photo upload app
## Description
This is a REST API application for uploading files to either a local server or to the cloud using Cloudinary. It provides endpoints for uploading images and getting a list of uploaded images.
## Used Technologies
In this build, I used Node.js, Express.js, MongoDB, Mongoose, TypeScript, Morgan, Dotenv, Express-FileUpload, Cloudinary.
## How to install
Download and run npm install, then create a .env file at the root of the project and set the following environment variables:
```bash
PORT=
MONGO_URI=
IMAGE_MAX_SIZE=
```if you want to upload images on Cloudinary in additon create this environment variables:
```bash
CLOUD_NAME=
CLOUD_API_KEY=
CLOUD_API_SECRET=
```Mongo uri example:
```bash
MONGO_URI=mongodb+srv://giorgi:[email protected]/yourDatabaseName?retryWrites=true&w=majority
```then run npm start.
## API Reference
## important
If you want to save photos in your local server go to api->routes->productRoutes.ts->uncomment commented code lines, and comment out the line of code responsible for saving the photo in the Cloudinary.
### Uploads
#### Upload Image to Local Server or Cloudinary
```http
POST /api/v1/products/uploads
```| Parameter | Type | Description |
| :-------- | :----- | :------------------------------------------ |
| `image` | `File` | **Required**. Photo that you want to upload |#### Products
```http
POST /api/v1/products
```| Parameter | Type | Description |
| :-------- | :------- | :---------------------------------- |
| `name` | `string` | **Required**. Name of your product |
| `price` | `number` | **Required**. Price of your product |
| `image` | `string` | **Required**. Image of your product |### Get All Products
```http
GET /api/v1/products
```Returns a list of all products.