Categorygithub.com/thomas-bouvier/insapp-go
repositorypackage
0.0.0-20200317174444-9ea8f80d35d1
Repository: https://github.com/thomas-bouvier/insapp-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

insapp-go

Go Report Card

Backend part of Insapp written in Go

Installation

go get

go get github.com/thomas-bouvier/insapp-go/...

API

Check that you have MongoDB running.

insapp-api

The process is listening on 0.0.0.0:9000 by default.

CLI

insapp-cli

Docker

Build

docker build -t insapp-go .

Run

docker run -it insapp-go

To ssh into this container, use the following command:

docker exec -it insapp-go ash

Configuration

Edit the configuration file:

cp config.json.dist config.json
vi config.json

Attributes google_email and google_password refer to the credentials of your Google account. These credentials are used to send emails. mongo_password refers to the MongoDB password. env refers to the environment type and should be set to prod, dev or local. Finally, port refers to the API port.

In a local environment:

  • Cookies are not secure ;
  • Push notifications are not sent.

The FCM HTTP v1 API requires some credentials to send push notifications. The service-account.json file can be downloaded from the Firebase Cloud Messaging dashboard, and should be copied at the root of this directory. This way, it will be included in the Docker container.

The authentication mechanism relies on JWT tokens and thus needs a secret key. Please generate the following keys at the root of this directory:

openssl genrsa -out app.rsa 2048
openssl rsa -in app.rsa -pubout > app.rsa.pub

API Endpoints

Public routes

TypeEndpoint callsDescription
GET/Index
GET/how-to-postGet the tutorial for posting content
GET/creditGet the credits
GET/legalGet the legal conditions
POST/login/associationLog an association in
POST/login/user/{ticket}Log a user in with the ticket {ticket} provided by CAS

User routes

TypeEndpoint callsDescription
GET/associationsGet all associations
GET/associations/{id}Get the association with id {id}
GET/associations/{id}/eventsGet all events of the association with id {id}
GET/associations/{id}/postsGet all posts of the association with id {id}
GET/eventsGet all future events
GET/events/{id}Get the event with id {id}
POST/events/{id}/attend/{userID}/status/{status}Post the attendee status {status} for the user with id {userID} on the event with id {id}
DELETE/events/{id}/attend/{userID}Delete the attendee status of the user with id {userID} on the event with id {id}
POST/events/{id}/commentPost a comment on the event with id {id}
DELETE/events/{id}/comment/{commentID}Delete the comment with id {commentID} on the event with id {id}
GET/postsGet all posts. You can provide ?range=[{start},{count}] to get only some posts
GET/posts/{id}Get the post with id {id}
POST/posts/{id}/like/{userID}Post a like for the user with id {userID} on the post with id {id}
DELETE/posts/{id}/like/{userID}Post an unlike for the user with id {userID} on the post with id {id}
POST/posts/{id}/commentPost a comment on the post with id {id}
DELETE/posts/{id}/comment/{commentID}Delete the comment with id {commentID} on the post with id {id}
GET/users/{id}Get the user with id {id}
PUT/users/{id}Update the user with id {id}
DELETE/users/{id}Delete the user with id {id}
POST/notificationsCreate a notification
GET/notifications/{userID}Get all notifications of the user with id {userID}
DELETE/notifications/{userID}/{id}Delete the notification with id {id} for the user with id {userID}
PUT/report/user/{userID}Report the user with id {userID}
PUT/report/{postID}/comment/{commentID}Report the comment with id {commentID} on the post with id {postID}
POST/searchSearch for users, associations, events and posts
POST/search/usersSearch for users
POST/search/associationsSearch for associations
POST/search/eventsSearch for events
POST/search/postsSearch for posts
POST/logout/userLogout the current user

Association routes

TypeEndpoint callsDescription
GET/associationGet the current association
PUT/associations/{id}Update the association with id {id}
POST/eventsCreate an event
PUT/events/{id}Update the event with id {id}
DELETE/events/{id}Delete the event with id {id}
POST/postsCreate a post
PUT/posts/{id}Update the post with id {id}
DELETE/posts/{id}Delete the post with id {id}
POST/imagesPost an image
POST/logout/associationLogout the current association user

Super user routes

TypeEndpoint callsDescription
POST/associationsCreate an association
DELETE/associations/{id}Delete the association with id {id}
GET/associations/{ownerID}/myassociationsGet the associations owned by the association with id {ownerID}
GET/usersGet all users