EDU-API is for the EDU Q&A platform where people can ask questions andprovide responses.
-
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 pre-requisites) -
Run
npm start
to start the server. -
Open up
Postman
and then test out the Endpoints.
Adds in a new single user into the Application.
End Point | Method | Params | Data Type |
---|---|---|---|
/api/v1/auth/signup |
POST | none |
none |
- Request Body
{
"username": "testuser",
"email": "[email protected]",
"password": "password"
}
- Request Headers
None
- Success Response:
Status: 200 OK
- Sample Content:
{
"Message": "User account succesfully created!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJpZCI6IjVmNTc2OTlmM2U4NjFjMDAxNzBhNTFhMSIsImlhdCI6MTU5OTU2NDE5MSwiZXhwIjoxNTk5NjUwNTkxfQ.
Hkp5ruXBMYdJ4pYdQCIJbKfB5PU6hdss5lEXehtNGUc"
}
- Error Response
{
"status": 422,
"message": "an error occured"
}
Logs in a single user into the Application
End Point | Method | Params | Data Type |
---|---|---|---|
/api/v1/auth/login |
POST | none |
none |
- Request Body
{
"username": "testuser",
"password": "password"
}
- Response Body
{
"message": "logged In",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.eyJ1c2VybmFtZSI6ImthbGx5IiwicGFzc3dvcmQiOiJwYXNzd29yZCIsImlhdCI6MTYwMDc4Mjc3MywiZXhwIjoxNjAwODY5MTczfQ
.TfG4lq7AZtWU6ES332_boK6eGdiexPH7eb3IxhXVL2k"
}
- Validation Error Response for Email Missing field
{
"message": "\"username\" is required"
}
- validation Error Response for Password Missing field
{
"message": "\"email\" is required"
}
Returns a single user by their Id
End Point | Method | Params | Data Type |
---|---|---|---|
/api/v1/user/:id |
GET | none |
none |
- Request Headers
{ Authorisation: Bearer Token}
Returns user object