Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

insamee-app/server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server

This projet is the server for all websites of InsameeApp.

Tech Stack

Server: Adonisjs, Postgresql

Installation

This project uses npm.

# install dependencies
npm i

# start un dev mode the project
npm run dev

# build the project
npm run build

# start in production mode the project
npm run start

Before to start, you must create a database called 'team' and tables in your database using

node ace migration:run

Then, you can populate your database:

node ace db:seed

In order to be used this server with any of the front-end, you must create a .evn file using the .env.example template.

API Spec

JSON Objects returned by API

Register Object

{
  "register": "ok"
}

Login Object

{
  "login": "ok"
}

Logout Object

{
  "logout": "ok"
}

VerifyEmail Object

{
  "verifyEmail": "ok"
}

ResetPassword Object

{
  "resetPassword": "ok"
}

sendVerifyEmail Object

{
  "sendVerifyEmail": "ok"
}

sendResetPassword Object

{
  "sendResetPassword": "ok"
}

Multiple users

{
  "meta": {
    "total": "number",
    "per_page": "number",
    "current_page": "number",
    "last_page": "number",
    "first_page": "number",
    "first_page_url": "string",
    "last_page_url": "string",
    "next_page_url": "string",
    "previous_page_url": "string"
  },
  "data": [
    {
      "id": "number",
      "email": "string",
      "is_verified": "boolean",
      "is_admin": "boolean",
      "is_blocked": "boolean",
      "deleted_at": "string | null",
      "created_at": "string",
      "updated_at": "string"
    }
  ]
}

user

{
  "id": "number",
  "email": "string",
  "is_verified": "boolean",
  "is_admin": "boolean",
  "is_blocked": "boolean",
  "deleted_at": "string | null",
  "created_at": "string",
  "updated_at": "string"
}

Delete user object

{
  "destroy": "ok"
}

Multiple Profiles

{}
Cards Multiple Profiles
{
  "meta": {
    "total": "number",
    "per_page": "number",
    "current_page": "number",
    "last_page": "number",
    "first_page": "number",
    "first_page_url": "string",
    "last_page_url": "string",
    "next_page_url": "string",
    "previous_page_url": "string"
  },
  "data": [
    {
      "user_id": "string",
      "avatar_url": "string",
      "last_name": "string",
      "first_name": "string",
      "current_role": "string",
      "mee_profile": {
        "short_text": "string",
        "associations": [
          {
            "name": "string",
            "image_url": "string"
          }
        ],
        "skills": [
          {
            "name": "string"
          }
        ]
      }
    }
  ]
}

Profile

{
  "user_id": "string",
  "avatar_url": "string",
  "last_name": "string",
  "first_name": "string",
  "user": {
    "email": "string"
  },
  "school": {
    "name": "string"
  },
  "graduation_year": "number",
  "current_role": "string",
  "mee_profile": {
    "text": "string",
    "skills": [
      {
        "name": "string"
      }
    ],
    "focus_interests": [
      {
        "name": "string"
      }
    ],
    "associations": [
      {
        "name": "string",
        "image_url": "string",
        "school": {
          "name": "string"
        }
      }
    ]
  },
  "tutoratProfile": {
    "text": "string",
    "difficulties_subjects": [
      {
        "name": "string"
      }
    ],
    "preferred_subjects": [
      {
        "name": "string"
      }
    ]
  },
  "mobile": "string",
  "url_facebook": "string",
  "url_instagram": "string",
  "url_twitter": "string"
}

Cards Multiple Tutorats

{
  "meta": {
    "total": "number",
    "per_page": "number",
    "current_page": "number",
    "last_page": "number",
    "first_page": "number",
    "first_page_url": "string",
    "last_page_url": "string",
    "next_page_url": "string",
    "previous_page_url": "string"
  },
  "data": [
    {
      "profile": {
        "avatar_url": "string",
        "last_name": "string",
        "first_name": "string",
        "current_role": "string"
      },
      "id": "number",
      "type": "enum",
      "shortText": "string",
      "time": "number",
      "subject": {
        "name": "string"
      },
      "school": {
        "name": "string"
      }
    }
  ]
}

Tutorat

{
  "type": "enum",
  "time": "number",
  "text": "string",
  "profile": {
    "avatar_url": "string",
    "last_name": "string",
    "first_name": "string",
    "current_role": "string",
    "user": {
      "email": "string"
    }
  },
  "school": {
    "name": "string"
  },
  "subject": {
    "name": "string"
  }
}

Registration Object

{
  "registration": "string"
}

Deregistration Object

{
  "deregistration": "string"
}

Contact Object

{
  "mailto": "string"
}

Multiple Associations

{}
Cards Multiple Associations
{
  "meta": {
    "total": "number",
    "per_page": "number",
    "current_page": "number",
    "last_page": "number",
    "first_page": "number",
    "first_page_url": "string",
    "last_page_url": "string",
    "next_page_url": "string",
    "previous_page_url": "string"
  },
  "data": [
    {
      "id": "number",
      "name": "string",
      "image_url": "string",
      "school": {
        "name": "string"
      },
      "thematic": {
        "name": "string"
      },
      "tags": [
        {
          "name": "string"
        }
      ],
      "short_text": "string"
    }
  ]
}

Association

{
  "id": "number",
  "name": "string",
  "image_url": "string",
  "school": {
    "name": "string"
  },
  "thematic": {
    "name": "string"
  },
  "tags": [
    {
      "name": "string"
    }
  ],
  "text": "string"
}

Multiple Schools

{}
Filter Schools
{
  "id": "number",
  "name": "string"
}

Multiple Focus of Interests

{}

Multiple Subjects

{}

Multiple Thematics

{
  "id": "number",
  "name": "string"
}

Multiple Tags

{
  "id": "number",
  "name": "string"
}

Multiple Reasons

[
  {
    "id": "number",
    "name": "string"
  }
]

Report

{
  "reported": "string",
  "already": "boolean"
}

EndPoints

Registration

POST /auth/register

Required fields

  • email as string
  • password as string
  • password_confirmation as string

No authentication required, returns a register object

Throw BadRequestException if user already exists

Login

POST /auth/login

Required fields

  • email as string
  • password as string
  • rememberMe as boolean

No authentication required, user must be verified, returns a login object

Logout

POST /auth/logout

Authentication required, returns a logout object

Verify Email

POST /auth/verify/:email

No authentication required, returns a verifyEmail object

Throw BadRequestException if url can't be validate

Throw ForbiddenException if user is already verified

Reset Password

POST /auth/resetPassword/:email

Required fields

  • password as string
  • password_confirmation as string

No authentication required, returns a resetPassword object

Throw BadRequestException if url can't be validate

Send Verify Email

POST /auth/send/verifyEmail

Required fields

  • email as string

No authentication required, returns a sendVerifyEmail object

Throw ForbiddenException if user is already verified

Send Reset Password

POST /auth/send/resetPassword

Required fields

  • email as string

No authentication required, returns a sendResetPassword object

Get Users

GET /api/v1/users

Authentication required, returns multiple-users

Authorization: admin

Get User

GET /api/v1/users/:id

Authentication required, returns a user

Authorization: admin

Update User

PATCH /api/v1/users/:id

Authentication required, returns a user

Body:

  • isVerified as boolean
  • isAdmin as boolean
  • isBlocked as boolean

Authorization: admin

Delete User

DELETE /api/v1/users/:id

Authentication required, returns a deleted user object

Authorization: the owner and admin

Get Current Profile

GET /api/v1/profiles/me

Query string

  • populate used to select the profile

Authentication required, returns a profile

Get Tutorats Registrations from Current Profile

GET /api/v1/profiles/me/tutorats/registrations

Authentication required, returns a cards-multiple-tutorats

Get Profiles

GET /api/v1/profiles

Query string

  • limit as string
  • page as string
  • populate as string, used to select the profile

Authentication required, returns multiple-profiles

Get Profile

GET /api/v1/profiles/:id

Query string

  • populate as string, used to select the profile
  • currentRole as string, filter
  • skill as number, filter
  • focusInterest as number, filter
  • association as number, filter
  • preferredSubject as number, filter
  • difficultiesSubject as number, filter

Authentication required, returns a profile

Get Tutorats Profile

GET /api/v1/profiles/:id/tutorats

Query string

  • limit as string
  • page as string
  • type, as string, filter

Authentication required, returns multiple tutorats

Update Profile

PATCH /api/v1/profiles/:id

Authentication required, returns a profile

Authorization: only the owner

Query string

  • populate as string, used to select the profile
Global profile

Optional fields

  • lastName as string
  • firstName as string
  • currentRole as string
  • mobile as string
  • graduationYear as number
  • mobile as string
  • urlFacebook as string
  • urlInstagram as string
  • urlTwitter as string
mee profile

?populate=mee

Optional fields

  • text as string
  • skills as array of numbers
  • focusInterests as array of numbers
  • associations as array of numbers
Tutorat profile

?populate=tutorat

Optional fields

  • text as string
  • preferredSubjects as array of numbers
  • difficultiesSubjects as array of numbers

Update a Profile Picture

PATCH /api/v1/profiles/:id/picture

Optional field

  • picture as file

Authentication required, returns a profile

Authorization: only the owner or an admin

Get Tutorats

GET /api/v1/tutorats

Authentication required, returns a tutorat

Query string

  • limit as string
  • page as string
  • currentRole as string, filter (=)
  • subject as number, filter (=)
  • school as number, filter (=)
  • time as number, filter (<)
  • type as number, filter (=)

Get Tutorat

GET /api/v1/tutorats/:id

Authentication required, returns multiple tutorats

Store Tutorat

POST /api/v1/tutorats

Required fields

  • subject, as number
  • school, as number
  • type, as string

Optional fields

  • time, as number, required when type is 'offer'
  • text, string

Authentication required, returns a tutorat

Update Tutorat

PATCH /api/v1/tutorats/:id

Optional fields

  • time, as number
  • text, string

Authentication required, returns a tutorat

Authorization: only the owner

Delete Tutorat

DELETE /api/v1/tutorats/:id

Authentication required, returns deleted tutorat object

Authorization: only the owner

Report a Tutorat

POST /api/v1/tutorats/:id/reports

Body

  • reason as number
  • description as string

Authentication required, returns a report

Registration Tutorat

GET /api/v1/tutorats/:id/registrations

Authentication required, returns a Cards Multiple Profiles

Registration to a Tutorat

POST /api/v1/tutorats/:id/registrations

Authentication required, returns a registration object

Deregistration to a Tutorat

DELETE /api/v1/tutorats/:id/registrations

Authentication required, returns a deregistration object

Get Contact Registrations from a Tutorat

GET /api/v1/tutorats/:id/registrations/contacts

Authentication required, returns a contact object

Get Associations

GET /api/v1/associations

Query string

  • serialize, as enum (card)
  • page, as string
  • name, as string
  • thematics[], as array of number
  • tags[], as array of number
  • schools[], as array of number

Authentication required, returns multiple associations

Get Association

GET /api/v1/associations/:id

Query string

  • platform, as enum

Authentication required, returns an association

Store Association

POST /api/v1/associations

Body

  • name as string
  • text as string
  • email as string
  • schoolId as number
  • thematicId as number
  • tags as array of number

Authentication required, returns an association

Authorization: admin

Update Association

PATCH /api/v1/associations/:id

Body

  • name as string
  • text as string
  • email as string
  • schoolId as number
  • tags as array of number

Authentication required, returns an association

Authorization: admin

Update an Association Picture

PATCH /api/v1/associations/:id/picture

Optional field

  • picture as file

Authentication required, returns a profile

Authorization: admin

Destroy Association

DELETE /api/v1/associations/:id

Authentication required, returns an association

Authorization: admin

Restore Association

PATCH /api/v1/association/:id/restore

Authentication required, returns an association

Authorization: admin

Get Profiles for One Association

GET /api/v1/associations/:id/profiles

Query string

  • limit, as string
  • page, as string

Authentication required, returns a multiple profiles

Report an Association

POST /api/v1/associations/:id/reports

Body

  • reason as number
  • description as string

Authentication required, returns a report

Get Profiles Reports

GET /api/v1/reports/profiles

Query string

  • page, as string

Authentication required, returns multiple-profiles-reports

Authorization: admin

Get Report by profile's id

GET /api/v1/reports/profiles/:id

Authentication required, returns reports

Get Profile Report by report's id

GET /api/v1/reports/:id/profiles

Authentication required, returns a profile-report

Authorization: admin

Destroy Profile Report by report's id

DELETE /api/v1/reports/:id/profiles

Authentication required, returns a profile-report

Authorization: admin

Get Tutorats Reports

GET /api/v1/reports/tutorats

Query string

  • page, as string

Authentication required, returns multiple-tutorats-reports

Authorization: admin

Get Report by tutorat's id

GET /api/v1/reports/tutorats/:id

Authentication required, returns reports

Get Tutorat Report by report's id

GET /api/v1/reports/:id/tutorats

Authentication required, returns a tutorat-report

Authorization: admin

Destroy Tutorat Report by report's id

DELETE /api/v1/reports/:id/tutorats

Authentication required, returns a tutorat-report

Authorization: admin

Get Associations Reports

GET /api/v1/reports/associations

Query string

  • page, as string

Authentication required, returns multiple-associations-reports

Authorization: admin

Get Report by association's id

GET /api/v1/reports/associations/:id

Authentication required, returns reports

Get Association Report by report's id

GET /api/v1/reports/:id/associations

Authentication required, returns a association-report

Authorization: admin

Destroy Association Report by report's id

DELETE /api/v1/reports/:id/associations

Authentication required, returns a association-report

Authorization: admin

Get Schools

GET /api/v1/schools

Query string

  • platform as enum

Authentication required, returns multiple schools

Create a School

POST /api/v1/schools

Body

  • name as string
  • host as string

Authentication required, returns a school Authorization: admin

Update a School

PATCH /api/v1/schools/:id

Body

  • name as string
  • host as string

Authentication required, returns a school Authorization: admin

Destroy a School

DELETE /api/v1/schools/:id

Authentication required, returns a school Authorization: admin

Restore a School

PATCH /api/v1/schools/:id/restore

Authentication required, returns a school Authorization: admin

Get Skills

GET /api/v1/skills

Authentication required, returns multiple skills

Create a Skill

POST /api/v1/skills

Body

  • name as string

Authentication required, returns a skill Authorization: admin

Update a Skill

PATCH /api/v1/skills/:id

Body

  • name as string
  • host as string

Authentication required, returns a skill Authorization: admin

Destroy a Skill

DELETE /api/v1/skills/:id

Authentication required, returns a skill Authorization: admin

Restore a Skill

PATCH /api/v1/skills/:id/restore

Authentication required, returns a skill Authorization: admin

Get Focus of Interests

GET /api/v1/focus_interests

Authentication required, returns multiple focus of interests

Create a Focus of Interests

POST /api/v1/focus_interests

Body

  • name as string

Authentication required, returns a focus_interest Authorization: admin

Update a Focus of Interests

PATCH /api/v1/focus_interests/:id

Body

  • name as string
  • host as string

Authentication required, returns a focus_interest Authorization: admin

Destroy a Focus of Interests

DELETE /api/v1/focus_interests/:id

Authentication required, returns a focus_interest Authorization: admin

Restore a Focus of Interests

PATCH /api/v1/focus_interests/:id/restore

Authentication required, returns a focus_interest Authorization: admin

Get Subjects

GET /api/v1/subjects

Authentication required, returns multiple subjects

Create a Subjects

POST /api/v1/subjects

Body

  • name as string

Authentication required, returns a Subject Authorization: admin

Update a Subjects

PATCH /api/v1/subjects/:id

Body

  • name as string
  • host as string

Authentication required, returns a Subject Authorization: admin

Destroy a Subjects

DELETE /api/v1/subjects/:id

Authentication required, returns a Subject Authorization: admin

Restore a Subjects

PATCH /api/v1/subjects/:id/restore

Authentication required, returns a Subject Authorization: admin

Get Thematics

GET /api/v1/thematics

Authentication required, returns multiple thematics

Create a Thematic

POST /api/v1/thematics

Body

  • name as string

Authentication required, returns a thematic Authorization: admin

Update a Thematic

PATCH /api/v1/thematics/:id

Body

  • name as string
  • host as string

Authentication required, returns a thematic Authorization: admin

Destroy a Thematic

DELETE /api/v1/thematics/:id

Authentication required, returns a thematic Authorization: admin

Restore a Thematic

PATCH /api/v1/thematics/:id/restore

Authentication required, returns a thematic Authorization: admin

Get Tags

GET /api/v1/tags

Authentication required, returns multiple tags

Create a Tag

POST /api/v1/tags

Body

  • name as string

Authentication required, returns a tag Authorization: admin

Update a Tag

PATCH /api/v1/tags/:id

Body

  • name as string
  • host as string

Authentication required, returns a tag Authorization: admin

Destroy a Tag

DELETE /api/v1/tags/:id

Authentication required, returns a tag Authorization: admin

Restore a Tag

PATCH /api/v1/tags/:id/restore

Authentication required, returns a tag Authorization: admin

Get Reasons

GET /api/v1/reasons

Query string

  • platform as string

Authentication required, returns multiple reasons

Authentication Workflow

To authenticate a user, you must send a request to /auth/login endpoint. Then, you can send a request to /api/v1/profiles/me to get the profile from the user.

When login, you can use the remember me option to authenticate user for a long time.

When user refresh the page or come to the site, you must try to get his profile. If it's ok, the user is authenticated, if it's not, the user is not authenticated

Authors