/Meetups-Backend

This is an app to find the meetups and other important events, Strapi is used in the backend as the CMS and Next.js as the React Server-side renderer to give a very fast and seamless usage.

Primary LanguageJavaScript

Meetups (Backend)

Contents

About Project

This is an app to create, join, find or manage meetings, reunions, conferences and other important events. Uses the Google Maps API for picking location, registered users have CRUD access for events and much more.

A frontend app which consumes the API from this app can be found at the meetups website.

The react frontend code built with next.js can be found on github here

Setup

Add environmental vars

Create a .env file in the main project folder and add your cloudinary info for image CRUD tasks in the format below.

HOST = 0.0.0.0
PORT=1337
CLOUDINARY_NAME = "xxxx"
CLOUDINARY_KEY = "xxxx"
CLOUDINARY_SECRET = "xxxx"

Install Dependencies

In the root folder of this project. Run the following command in the terminal to install all necessary dependencies required for the project.

npm install 

Start the Server

In the project top level 'server' directory, the following script will run the app in development mode by initiating both the client and backend server: To start the app, run the following command.

npm run develop
# or
yarn develop

Open http://localhost:1337/admin to access the CMS Backend

Tech Stack

The tech stack mainly comprises of PostgresQL as the database, react, and node.js and deployed to Heroku.

Deployment

The backend app is already deployed on Heroku here.

Needed Tools

This is a nodejs backend built with StrapiCMS, so be sure to get that installed. Other requirements include free developer accounts from Cloudinary for handling picture uploads, Heroku for cloud hosting, Postgres Database for backend database hosting, Mapbox and Google Maps API for geolocation.

Documentation

JSON Objects returned by API:

Make sure the right content type like Content-Type: application/json; charset=utf-8 is correctly returned.

User (Object Model)

{
  "attributes": {
    "username": "tester",
    "email": "test@test.com",
    "password": "tyfughl",
    "role": {
      "model": "role",
      "via": "users",
      "configurable": false
    },
    "events": {
      "via": "user",
      "collection": "events"
    }
  }
}

Event

  {
  	"name": "New event",
  	"slug": "new-event",
    "venue": "Villa Park",
    "address": "Villa Park, London ",
    "date": "22-10-2020",
    "time":"12:00PM",
    "performers": "VC",
    "description": "good event",
    "image": "file.png",
    "user": "tester"
}

Errors and Status Codes

If a request fails any validations, expect a 422 and errors in the following format:

{
  "errors":{
    "body": [
      "can't be empty"
    ]
  }
}
Other status codes:

401 for Unauthorized requests, when a request requires authentication but it isn't provided

403 for Forbidden requests, when a request may be valid but the user doesn't have permissions to perform the action e.g "Insufficient credits. Please add credits."

404 for Not found requests, when a resource can't be found to fulfill the request

Event Endpoints:

View all events:

GET "/events"

No authentication required, returns a list of events

View all current user events

GET "/events/me"

Authentication required

Get the total number of events in the db

GET /events/count"

View a specific event given its id

GET "/events/:id"

No authentication required, returns an event

Create a new event

POST "/events"

Authentication required.

Required fields name, venue, address, date, time, performers, description

Optional field image

Update event with given id

PUT "/events/:id"

Authentication required. All fields are optional

Delete event with given id

DELETE "/events/:id"

Authentication required.