https://github.com/sord-dev/eco.io-backend
https://github.com/sord-dev/eco.io-backend
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/sord-dev/eco.io-backend
- Owner: sord-dev
- Created: 2023-03-24T18:22:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-31T08:47:45.000Z (over 3 years ago)
- Last Synced: 2025-02-11T15:52:48.904Z (over 1 year ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eco.io-backend

## Requirements
- .env file in root directory (with index.js, package.json)

Inside of the .env file put these two values:
```
PORT=3000
DB_URL=[Elephant SQL Instance URL](https://customer.elephantsql.com/instance/create)
SESSION_SECRET=dhjkasdfasdhsdfkjsdfahgasdffasdgsdgsdfasdf
```
*any long string will be sufficient in the SESSION_SECRET row*
- Inside of a terminal from the root directory, install the depenancies of the project.
```
$ npm install
```
- After this, run the command to start the server and go to [localhost:3000](http://localhost:3000)
```
$ npm run dev
```
Expected result:

## Routes
**auth routes**
| Route | Description |
|--------------|-------------|
| POST /auth/login {user details in body} | login to existing account |
| POST /auth/register {user details in body} | create a user |
| GET /auth/logout {nothing in body} | logout |
login user shape:
*to /auth/login*
```
{
"username": "test_usr",
"password": "test123"
}
```
register user shape:
*to /auth/register*
```
{
"username": "admin",
"email": "admin@gmail.com",
"password": "admin",
"isAdmin": true
}
```
**event routes** - AUTH PROTECTED
| Route | Description |
|--------------|-------------|
| GET /events/all | show all events ordered by upvotes |
| GET events/a/all | get all approved events |
| GET /events/ | get all user events (if admin) |
| PATCH events/v/:event_id | vote for an event (if you don't own it) |
| PATCH events/a/:event_id | approve an event |
| POST /events/ {event object in body} | create a new event |
| DELETE events/:event_id | delete a event |
event shape:
*to /events/*
```
{
"event_id": 1,
"owner_id": 2,
"upvotes": 99,
"title": "This is the title of the event.",
"description": "this is the description of the even",
"location": "London"
}
```
event vote shape:
*to /events/v/:event_id*
```
{
"votes": 1
}
// OR
{
"votes": -1
}
```
**user routes**
| Route | Description |
|--------------|-------------|
| GET users/top | get the top 10 users ordered by events attended |
| GET users/bookings/ | get all the users bookings depending on who's signed in |
| GET users/h/bookings/ | get all the users attended bookings depending on who's signed in |
| GET users/bookings/all | get all the users bookings ADMIN ONLY |