Error responce body in every fail
const error = {
error: true,
errorCode: number,
message: message
}
const success = {
token:string,
props:[key], // returns object with only these props
... otherParams
}
const success = {
error: false,
...data,
}
/users
✅Creates a user.
const input = {
username: string,
password: string,
intrests: [string],
about: string,
email: string,
avatar:url,
}
const output = {
error: false,
}
/users/userId
const output = {
username: string,
intrests: [string],
about: string,
userId: number,
isFolowing: boolean,
folowers:number,
available,
projects:[
{
name:string,
projectId:number,
upvotes:number,
logo: url,
}
]
}
/connect
✅const input = {
login: string,
password: string
}
const output = {
error:false,
notifications:[{
notificationId,
type: string, // team, messages
text: string,
date:date,
data: string
}],
myUpvotes,
followers: number,
projects:[project],
isAvailable:boolean,
token: {
username,
userId,
avatar,
}
}
/search/users?q=
const input = {
q: string,
}
const output = {
error:false,
users:[],
}
users/folow/
const input = {
userId: number,
token,
}
const output = {
error:false,
}
users/unfolow/
const input = {
userId: number,
token,
}
const output = {
error:false,
}
/messages/${projectId}
Get messages
const input = {
token: string
}
const output = {
error:false,
messages:[
{
content: string,
date: date,
from: number, // userId
projectId: number,
}
]
}
/messages/${projectId}
Create message
const input = {
token: string,
message:{
content: string,
}
}
const output = {
error:false,
}
/projects?page=
const input = {
page: number,
}
const output = {
error: false,
projects: [{
projectId: integer,
name:string,
team:[{
username:string,
avatar:url,
userId:number
}], // max lenght MAX_TEAM_LENGHT
upvotes: integer // number of likes
}] /// array of length <= NB_ELEMENTS_PER_PAGE
}
/projects
creates a project const input = {
project: {
name:string
acceptsAnyColaborators: boolean,
team:[{
userId: string || null,
username: string || null,
avatar: string || null,
role:string, // 'PO', 'DEV-FRONT', 'DESIGNER', 'LOGO DESIGNER', 'DEV-BACK'..., 'DATABASE'
isAvailable: boolean
}], // required if anyColaborators === false
markdown: text, // required
},
token: string, // identification token
}
const output = {
error: false,
projectId: number,
}
/projects/${projectId}
const input = {
project: {
project_filed: data,
},
token: string, // identification token
}
const output = {
error:false,
projectId:number,
}
/projects/${projectId}
const input = {
projectId
}
const output = {
acceptsAnyColaborator:boolean
creationDate:date,
projectId: number,
name: string,
upvotes: number,
userUpvoted: boolean,
master: userId,
team:[
{
userId: string,
username: string,
role:string, // 'PO', 'DEV-FRONT', 'DESIGNER', 'LOGO DESIGNER', 'DEV-BACK'..., 'DATABASE'
isAvailable: boolean
}
], // max lenght MAX_TEAM_LENGHT,
availableRoles:[string], // this is generated not stoed in db
description: string // markdown description part
}
/upvote/projectId
const input = {
token,
}
const output = {
error:false,
projectId,
upvotes: integer,
}
/dowvote/projectId
const input = {
token,
}
const output = {
error:false,
projectId,
upvotes: integer,
}
comment/projectId
const input = {
token,
message:{
text:string,
},
}
const output = {
error:false,
}
comment/commentId
const input = {
token,
message:{
text:string,
},
comentId:integer,
}
const output = {
error:false,
projectId,
upvotes: integer,
}
project/${projectId}/apply
Creates an application request
const input = {
token,
role,
}
const output = {
error:false,
projectId
}
requests/${requestId}
Accepts a request
const input = {
token,
isRejected:boolean,
}
const output = {
error:false,
projectId
}
/search/projects?q=
:
const input = {
token,
q: string,
filters:{
role:string,
name:string
}
}
const output = {
error:false,
projects:[
{
projectId,
name,
team:[],
availableRoles:[],
}
]
}
user/verify/?data=
✅
const input = {
token,
data:string
}
const output = {
error:false
}
{
username: string,
password: string,
intrests: [string],
about: string,
email: string,
userId: number,
creationDate: current_time_stamp,
isVerified:boolean,
myUpvotes:number,
isAvailable:boolean,
}
{
userId,
projectId,
requestId,
role:string,
rejected:boolean,
}
{ tags:[string]
creationDate:date,
projectId: number,
name: string,
master: userId,
upvotes: number,
team:[
{
userId: string || null,
username: string || null,
avatar: string || null,
role: string,
isOpen: boolean,
}
],
description: string // markdown description part
}
{
upvoteId: number,
projectId: numbre,
userId: number
}
{
date: date,
messageId: numbre,
message: string,
projectId: numbre,
userId: number
}
{
date: date,
commentId: numbre,
message: string,
projectId: numbre,
userId: number
}
{
creationDate: date
notificationType: string,
text: string,
elementId: integer, // link to the project or message
isRead: boolean,
}
{ linkId: integer, user:userId, folows:userId, }
/projects /users/userId /roles
messages are visible by team members only one user one role only master can add users
+-- node_modules +-- src | +-- Rooter | | +-- users | | | index.js (all sub roots user/*) | | | user.logic.js (logic functions of every sub-root) | constant.js (ALL CONSTANTS) | index.js (the server start) | utils.js (utils functions: type validation, tocken validation...) .eslint.rc .gitignore package-lock.json package.json readme.md
1 the user provides an email and a password
2 the email and password are verified if they have the valid format, validation functions are in utils.js
3 the email is looked up in the database, send email again
is sent if the email exists and the flag verified === false
4 if not, a user (see ### user db shema) is added to the the database with the flag verified:false
, creationDate: current_time_stamp
5 an email is generated that links to /verify-email?userId=userId&hash=hashOf(SEECRET_KEY, userId)
6 the validated
flag is set to false
and the password to hash(password)
7 a respose message is send
1 the user goes to /user/verify?userId=userId&hash=hashOf(SEECRET_KEY, userId)
2 varify that hash===hashOf(SEECRET_KEY, userId)
send bad request if not
3 verify that user.creationDate + VALIDATION_URL_LIFE_TIME < current_time_stamp
send bad request if not
4 set validated
flag to true
5 the user is redirected to the main page
1 the user provides an email and a password
2 the email and password are verified if they have the valid format (utils.js
)
3 if the user with email
and hash(password)
is not in the table send an error
4 if he is than create a jwt token signed with SECRETE_KEY
and life time of JWT_LIFE_TIME
5 store userId
, email
, name
, avatar
in the jwt tocken
6 remove hidden data
7 select all the notifications of the user where notification.red === false
ordered by creationDate
8 count the number of the upvotes of the user
9 return the success output of POST:/connect
1 if token is unvalid return an error
2 check new data format (utils.js
)
3 update data with new data
4 return success message
1 if token is unvalid return an error
2 check the data format (utils.js
) return error message if data is invalid
3 create project in db (see ### mproject db shema)
4 return success message