This projet is the server for all websites of InsameeApp.
Server: Adonisjs, Postgresql
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.
{
"register": "ok"
}
{
"login": "ok"
}
{
"logout": "ok"
}
{
"verifyEmail": "ok"
}
{
"resetPassword": "ok"
}
{
"sendVerifyEmail": "ok"
}
{
"sendResetPassword": "ok"
}
{
"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"
}
]
}
{
"id": "number",
"email": "string",
"is_verified": "boolean",
"is_admin": "boolean",
"is_blocked": "boolean",
"deleted_at": "string | null",
"created_at": "string",
"updated_at": "string"
}
{
"destroy": "ok"
}
{}
{
"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"
}
]
}
}
]
}
{
"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"
}
{
"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"
}
}
]
}
{
"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": "string"
}
{
"deregistration": "string"
}
{
"mailto": "string"
}
{}
{
"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"
}
]
}
{
"id": "number",
"name": "string",
"image_url": "string",
"school": {
"name": "string"
},
"thematic": {
"name": "string"
},
"tags": [
{
"name": "string"
}
],
"text": "string"
}
{}
{
"id": "number",
"name": "string"
}
{}
{}
{
"id": "number",
"name": "string"
}
{
"id": "number",
"name": "string"
}
[
{
"id": "number",
"name": "string"
}
]
{
"reported": "string",
"already": "boolean"
}
POST /auth/register
Required fields
email
as stringpassword
as stringpassword_confirmation
as string
No authentication required, returns a register object
Throw BadRequestException if user already exists
POST /auth/login
Required fields
email
as stringpassword
as stringrememberMe
as boolean
No authentication required, user must be verified, returns a login object
POST /auth/logout
Authentication required, returns a logout object
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
POST /auth/resetPassword/:email
Required fields
password
as stringpassword_confirmation
as string
No authentication required, returns a resetPassword object
Throw BadRequestException if url can't be validate
POST /auth/send/verifyEmail
Required fields
email
as string
No authentication required, returns a sendVerifyEmail object
Throw ForbiddenException if user is already verified
POST /auth/send/resetPassword
Required fields
email
as string
No authentication required, returns a sendResetPassword object
GET /api/v1/users
Authentication required, returns multiple-users
Authorization: admin
GET /api/v1/users/:id
Authentication required, returns a user
Authorization: admin
PATCH /api/v1/users/:id
Authentication required, returns a user
Body:
isVerified
as booleanisAdmin
as booleanisBlocked
as boolean
Authorization: admin
DELETE /api/v1/users/:id
Authentication required, returns a deleted user object
Authorization: the owner and admin
GET /api/v1/profiles/me
Query string
populate
used to select the profile
Authentication required, returns a profile
GET /api/v1/profiles/me/tutorats/registrations
Authentication required, returns a cards-multiple-tutorats
GET /api/v1/profiles
Query string
limit
as stringpage
as stringpopulate
as string, used to select the profile
Authentication required, returns multiple-profiles
GET /api/v1/profiles/:id
Query string
populate
as string, used to select the profilecurrentRole
as string, filterskill
as number, filterfocusInterest
as number, filterassociation
as number, filterpreferredSubject
as number, filterdifficultiesSubject
as number, filter
Authentication required, returns a profile
GET /api/v1/profiles/:id/tutorats
Query string
limit
as stringpage
as stringtype
, as string, filter
Authentication required, returns multiple tutorats
PATCH /api/v1/profiles/:id
Authentication required, returns a profile
Authorization: only the owner
Query string
populate
as string, used to select the profile
Optional fields
lastName
as stringfirstName
as stringcurrentRole
as stringmobile
as stringgraduationYear
as numbermobile
as stringurlFacebook
as stringurlInstagram
as stringurlTwitter
as string
?populate=mee
Optional fields
text
as stringskills
as array of numbersfocusInterests
as array of numbersassociations
as array of numbers
?populate=tutorat
Optional fields
text
as stringpreferredSubjects
as array of numbersdifficultiesSubjects
as array of numbers
PATCH /api/v1/profiles/:id/picture
Optional field
picture
as file
Authentication required, returns a profile
Authorization: only the owner or an admin
GET /api/v1/tutorats
Authentication required, returns a tutorat
Query string
limit
as stringpage
as stringcurrentRole
as string, filter (=)subject
as number, filter (=)school
as number, filter (=)time
as number, filter (<)type
as number, filter (=)
GET /api/v1/tutorats/:id
Authentication required, returns multiple tutorats
POST /api/v1/tutorats
Required fields
subject
, as numberschool
, as numbertype
, as string
Optional fields
time
, as number, required when type is 'offer'text
, string
Authentication required, returns a tutorat
PATCH /api/v1/tutorats/:id
Optional fields
time
, as numbertext
, string
Authentication required, returns a tutorat
Authorization: only the owner
DELETE /api/v1/tutorats/:id
Authentication required, returns deleted tutorat object
Authorization: only the owner
POST /api/v1/tutorats/:id/reports
Body
reason
as numberdescription
as string
Authentication required, returns a report
GET /api/v1/tutorats/:id/registrations
Authentication required, returns a Cards Multiple Profiles
POST /api/v1/tutorats/:id/registrations
Authentication required, returns a registration object
DELETE /api/v1/tutorats/:id/registrations
Authentication required, returns a deregistration object
GET /api/v1/tutorats/:id/registrations/contacts
Authentication required, returns a contact object
GET /api/v1/associations
Query string
serialize
, as enum (card)page
, as stringname
, as stringthematics[]
, as array of numbertags[]
, as array of numberschools[]
, as array of number
Authentication required, returns multiple associations
GET /api/v1/associations/:id
Query string
platform
, as enum
Authentication required, returns an association
POST /api/v1/associations
Body
name
as stringtext
as stringemail
as stringschoolId
as numberthematicId
as numbertags
as array of number
Authentication required, returns an association
Authorization: admin
PATCH /api/v1/associations/:id
Body
name
as stringtext
as stringemail
as stringschoolId
as numbertags
as array of number
Authentication required, returns an association
Authorization: admin
PATCH /api/v1/associations/:id/picture
Optional field
picture
as file
Authentication required, returns a profile
Authorization: admin
DELETE /api/v1/associations/:id
Authentication required, returns an association
Authorization: admin
PATCH /api/v1/association/:id/restore
Authentication required, returns an association
Authorization: admin
GET /api/v1/associations/:id/profiles
Query string
limit
, as stringpage
, as string
Authentication required, returns a multiple profiles
POST /api/v1/associations/:id/reports
Body
reason
as numberdescription
as string
Authentication required, returns a report
GET /api/v1/reports/profiles
Query string
page
, as string
Authentication required, returns multiple-profiles-reports
Authorization: admin
GET /api/v1/reports/profiles/:id
Authentication required, returns reports
GET /api/v1/reports/:id/profiles
Authentication required, returns a profile-report
Authorization: admin
DELETE /api/v1/reports/:id/profiles
Authentication required, returns a profile-report
Authorization: admin
GET /api/v1/reports/tutorats
Query string
page
, as string
Authentication required, returns multiple-tutorats-reports
Authorization: admin
GET /api/v1/reports/tutorats/:id
Authentication required, returns reports
GET /api/v1/reports/:id/tutorats
Authentication required, returns a tutorat-report
Authorization: admin
DELETE /api/v1/reports/:id/tutorats
Authentication required, returns a tutorat-report
Authorization: admin
GET /api/v1/reports/associations
Query string
page
, as string
Authentication required, returns multiple-associations-reports
Authorization: admin
GET /api/v1/reports/associations/:id
Authentication required, returns reports
GET /api/v1/reports/:id/associations
Authentication required, returns a association-report
Authorization: admin
DELETE /api/v1/reports/:id/associations
Authentication required, returns a association-report
Authorization: admin
GET /api/v1/schools
Query string
platform
as enum
Authentication required, returns multiple schools
POST /api/v1/schools
Body
name
as stringhost
as string
Authentication required, returns a school Authorization: admin
PATCH /api/v1/schools/:id
Body
name
as stringhost
as string
Authentication required, returns a school Authorization: admin
DELETE /api/v1/schools/:id
Authentication required, returns a school Authorization: admin
PATCH /api/v1/schools/:id/restore
Authentication required, returns a school Authorization: admin
GET /api/v1/skills
Authentication required, returns multiple skills
POST /api/v1/skills
Body
name
as string
Authentication required, returns a skill Authorization: admin
PATCH /api/v1/skills/:id
Body
name
as stringhost
as string
Authentication required, returns a skill Authorization: admin
DELETE /api/v1/skills/:id
Authentication required, returns a skill Authorization: admin
PATCH /api/v1/skills/:id/restore
Authentication required, returns a skill Authorization: admin
GET /api/v1/focus_interests
Authentication required, returns multiple focus of interests
POST /api/v1/focus_interests
Body
name
as string
Authentication required, returns a focus_interest Authorization: admin
PATCH /api/v1/focus_interests/:id
Body
name
as stringhost
as string
Authentication required, returns a focus_interest Authorization: admin
DELETE /api/v1/focus_interests/:id
Authentication required, returns a focus_interest Authorization: admin
PATCH /api/v1/focus_interests/:id/restore
Authentication required, returns a focus_interest Authorization: admin
GET /api/v1/subjects
Authentication required, returns multiple subjects
POST /api/v1/subjects
Body
name
as string
Authentication required, returns a Subject Authorization: admin
PATCH /api/v1/subjects/:id
Body
name
as stringhost
as string
Authentication required, returns a Subject Authorization: admin
DELETE /api/v1/subjects/:id
Authentication required, returns a Subject Authorization: admin
PATCH /api/v1/subjects/:id/restore
Authentication required, returns a Subject Authorization: admin
GET /api/v1/thematics
Authentication required, returns multiple thematics
POST /api/v1/thematics
Body
name
as string
Authentication required, returns a thematic Authorization: admin
PATCH /api/v1/thematics/:id
Body
name
as stringhost
as string
Authentication required, returns a thematic Authorization: admin
DELETE /api/v1/thematics/:id
Authentication required, returns a thematic Authorization: admin
PATCH /api/v1/thematics/:id/restore
Authentication required, returns a thematic Authorization: admin
GET /api/v1/tags
Authentication required, returns multiple tags
POST /api/v1/tags
Body
name
as string
Authentication required, returns a tag Authorization: admin
PATCH /api/v1/tags/:id
Body
name
as stringhost
as string
Authentication required, returns a tag Authorization: admin
DELETE /api/v1/tags/:id
Authentication required, returns a tag Authorization: admin
PATCH /api/v1/tags/:id/restore
Authentication required, returns a tag Authorization: admin
GET /api/v1/reasons
Query string
platform
as string
Authentication required, returns multiple reasons
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