A place where all edu profiles can be stored and accessed.
- Node.js
- Express.js
- JSON web token (JWT)
- Bcrypt
|-- src
|-- index.js' ** the main driver of the app'
|-- server
|-- app.js
|-- config
| |-- connect.js
| |-- envTypes.js
|-- controllers
| |-- profile.js
| |-- user.js
|-- helpers
| |-- validation.js
| |-- schemas
| |-- profiles.js
| |-- users.js
|-- models
| |-- profile.js
| |-- user.js
| |-- schemas
| |-- profile.js
| |-- user.js
| |-- usersAllowed.js
|-- routers
|-- profileRouter.js
|-- userRouter.js
- PORT --
server port number
- DB_URL --
database URL
- SECRET --
Secret key for verifying the token
- NODE_ENV --
Specifies the Server environment (development, local, production)
clone
this repository.cd
into project root directory.- run
npm install
to install all dependencies. (you must have node installed) - Run
npm start
to start the server. - Open up
Postman
and then test out the Endpoints.
Signs in a single user into the Application.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/users/signup |
POST | None |
None |
-
Request Body
{ "username" : "[email protected]", "method" : "Local-auth", "firstName" : "mefirst", "otherName" : "meOther", "password" : "mePassword", "userLevel" :"1" }
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ Message: "User account succesfully created!", token:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV CJ9eyJpZCI6IjVmMGYwY2UxZmZjNTQ1MGI 3YzllMzk4OSIsI" }
-
Error Response:
- Status: 409 CONFLICT
Content:{ "Error": "User Already Exists" }
OR
- Status: 417 EXPECTATION_FAILED
Content:{ Error: 'Server error occured, user account creation failed!'}
- Status: 409 CONFLICT
Logs in a single user in the application.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/users/login |
GET | None |
None |
-
Request Body
{ "username" : "[email protected]", "password" : "mePassword" }
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ token:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV CJ9eyJpZCI6IjVmMGYwY2UxZmZjNTQ1MGI 3YzllMzk4OSIsI" }
-
Error Response:
- Status: 400 BAD REQUEST
Content:{ error: 'Invalid password, retry with correct password!' }
OR
- Status: 404 NOT FOUND
Content:{ error: 'No such user exists!', err }
OR
- Status: 417 EXPECTATION_FAILED
Content:{ error: 'Server error occured during login, please try again later!'}
- Status: 400 BAD REQUEST
Returns json data about a single user.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/users/ |
GET | None |
None |
-
Request Body
None
-
Request Headers
{ authorization: "Bearer Token" }
-
Success Response:
Status: 200 OK
Sample Content:{ "username": "[email protected]", "firstName": "firstname", "otherName": "otherName" }
-
Error Response:
- Status: 403 FORBIDDEN
Content:{ Error: 'Something Went Wrong!' }
- Status: 403 FORBIDDEN
Updates data about a single user in the database.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/users/ |
PATCH | None |
None |
-
Request Body
Fields are not all required since its an update
{ "username" : "[email protected]", "method" : "Local-auth", "firstName" : "mefirst", "otherName" : "meOther", "password" : "mePassword", "userLevel" :"1" }
-
Request Headers
{ authorization: "Bearer Token" }
-
Success Response:
Status: 200 OK
Sample Content:{ Message: "User has been successfully Updated" }
-
Error Response:
- Status: 404 NOT FOUND
Content:{ Error: 'Something Went Wrong >>> User of Given ID was Not Found'}
- Status: 404 NOT FOUND
Delets a single user from the Data Base.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/users/:id |
DELETE | required |
string |
-
Request Body
None
-
Request Headers
{ authorization: "Bearer Token" }
-
Success Response:
Status: 200 OK
Sample Content:{ "Message": "User has been Deleted Successfully" }
-
Error Response:
- Status: 400 BAD REQUEST
Content:{ Error: "Something went Wrong >> User OF given ID was not found",err}
- Status: 400 BAD REQUEST
Create in a single user profile into the Application.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/profiles/ |
POST | None |
None |
-
Request Body
{ "username" : "meusername", "email" : ['[email protected]','[email protected]'], "phone" : ['0736284897','0736284897'], "organisation" : [{name:"MTN",position:"PRO", date:"24/09/2018"}], "skills" : [{name:"playing",proficiency: "champion",favorite:true}], "address" : [{country: "Uganda",state: "Wakiso",address_line: "plot_20"}], "strength" :"Agility", "topics_of_interest" :['currentStuff','Google'] }
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ Message: 'Your profile was successfully created', Profile } }
-
Error Response:
- Status: 403 BAD REQUEST
Content:{ Error: 'User Profile Already Exists' }
OR
- Status: 403 BAD REQUEST
Content:{ error: 'An unknown server error occured while creating your profile, please retry!'}
- Status: 403 BAD REQUEST
Logs in all single user profiles in the application.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/profiles/ |
GET | None |
None |
-
Request Body
None
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ Profiles: [] }
-
Error Response:
- Status: 404 NOT FOUND
Content:{ Message: 'No Profiles Available' }
OR
- Status: 404 NOT FOUND
Content:{ Message:
Something Went Wrong. Profiles Not Found, Error: err }
- Status: 404 NOT FOUND
Returns json data about a single user Profile.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/profiles/:id |
GET | required |
string |
-
Request Body
None
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ profile: profile }
-
Error Response:
- Status: 404 NOT FOUND
Content:{ Message: 'profile Not Found' }
OR
- Status: 404 NOT FOUND
Content:{Message :
Something Went Wrong. User Profile of Given id >>profileId
<< was Not Found, Error: err}
- Status: 404 NOT FOUND
Updates data about a single user Profile in the database.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/profiles/:id |
PATCH | required |
string |
-
Request Body
Fields are not all required since its an update update only what you need to update.
{ "username" : "upadatedUsername", "email" : ['[email protected]','[email protected]'], "phone" : ['0736284897','0736284897'], "organisation" : [{name:"MTN",position:"PRO", date:"24/09/2018"}], "skills" : [{name:"playing",proficiency: "champion",favorite:true}], "address" : [{country: "Uganda",state: "Wakiso",address_line: "plot_20"}], "strength" :"Agility", "topics_of_interest" :['currentStuff','Google'] }
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ Message: `User's Profile has been Updated` }
-
Error Response:
- Status: 404 NOT FOUND
Content:{ Message:
Profile of given ID >> profileId << was not Found, Error: err }
OR
- Status: 403 FORBIDDEN
Content:{ Message: 'Username provided Already Taken >> Enter Unique Username' }
- Status: 404 NOT FOUND
Delets a single user Profile from the Data Base.
Endpoint | Method | Params | Data type |
---|---|---|---|
/api/profiles/:id |
DELETE | required |
string |
-
Request Body
None
-
Request Headers
None
-
Success Response:
Status: 200 OK
Sample Content:{ message: `User's Profile has been deleted successfully` }
-
Error Response:
- Status: 400 BAD REQUEST
Content:{ error: 'Profile cannot be deleted.Try again' }
- Status: 400 BAD REQUEST
You can help improve the code base of the application where neccessary by raising an issue or opening a pull request.