https://github.com/potchangelo/express-unsplash
Web-API for Unsplash-Cloned Web-App (For Educational Purposes Only)
https://github.com/potchangelo/express-unsplash
api express mysql nodejs sequelize sequelize-cli
Last synced: about 2 months ago
JSON representation
Web-API for Unsplash-Cloned Web-App (For Educational Purposes Only)
- Host: GitHub
- URL: https://github.com/potchangelo/express-unsplash
- Owner: potchangelo
- Created: 2020-07-11T17:36:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-19T02:37:23.000Z (almost 2 years ago)
- Last Synced: 2025-05-17T19:38:18.626Z (about 1 year ago)
- Topics: api, express, mysql, nodejs, sequelize, sequelize-cli
- Language: JavaScript
- Homepage: https://express-unsplash.adaptable.app/photos
- Size: 481 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Express Unsplash by Zinglecode
Express Web-API for Unsplash-Cloned web-app (for educational purposes only)
[Front-end web-app](https://github.com/potchangelo/next-unsplash)
## Table of Contents
* [How to Install and Run Offline](#how-to-install-and-run-offline)
* [Base URL Online](#base-url-online)
* [API Documentation](#api-documentation)
* [Credits](#credits)
## How to Install and Run Offline
0. Before running project, make sure that **Node.js** + **PostgreSQL** are installed and already setup on your machine. And the database in PostgreSQL is created already.
1. Download this project, then open project folder in code editor (VSCode or Anything).
2. Rename ".env.sample" file in project folder to ".env", then change database URL string to your config.
Template
```
DATABASE_URL="postgresql://{username}:{password}@{host}:{port}/{database}?schema=public"
```
Example
```
DATABASE_URL="postgresql://root:pass1234@localhost:5432/nodejs_express_unsplash?schema=public"
```
3. Open Terminal or Command Prompt at project folder, then install packages.
```
npm install
```
4. Type Prisma CLI command to updates database migrations and seeds sample data.
```
npx prisma migrate dev
```
5. Start running Node.js Express web-app.
```
npm run start
```
## Base URL Online
Every API is started at ----------. Responses are sent as JSON.
## API Documentation
* [Get photos](#get-photos)
* [Get photo](#get-photo)
* [Get random photo](#get-random-photo)
* [Get user](#get-user)
### Get photos
Get latest photos (Max at 12 photos).
```http
GET /photos
```
#### Query string parameters
Name | Required/Optional | Description
---- | ----------------- | -----------
beforeId | Optional | Get latest photos which id < beforeId.
#### Example request
```
-----------/photos
```
### Get photo
Get single photo
```http
GET /photos/:uid
```
#### Path parameters
Name | Required/Optional | Description
---- | ----------------- | -----------
uid | Required | Unique ID of the photo
#### Example request
```
----------/photos/mRIUGPTtA7
```
### Get random photo
Get single random photo
```http
GET /photos/random
```
#### Example request
```
----------/photos/random
```
### Get user
Get single user profile
```http
GET /users/:username
```
#### Path parameters
Name | Required/Optional | Description
---- | ----------------- | -----------
username | Required | Username of the user
#### Query string parameters
Name | Required/Optional | Description
---- | ----------------- | -----------
latestPhotos | Optional | Set to 1 for included user's latest photos (Max at 12 photos) in the response
#### Example request
```
----------/users/jason555
```
## Credits
The project was inspired by https://unsplash.com/. Every photos in API already included with credit for the author on Unsplash.
### Stack used in the project
- Node.js
- Express
- Prisma
- PostgreSQL