The API that is used in our last project at Ironhack. We applied the REST guidelines for creating an API.
The API supports the following routes:
Description | Route | Method | Expects | Description | Returns | Error |
---|---|---|---|---|---|---|
AUTH | /auth/signup | POST | email, name, password in form-encode | Sign up a user | 201, {email, name, _id} | 500, Internal server Error |
AUTH | /auth/login | POST | email, password in form-encode | Login a user | 200, {JWT, userId} | 401, Unable to authenticate / User not found |
AUTH | /auth/verify | GET | A header : '{ Authorization: Bearer ${storedToken} }' |
Authenticate the JWT | 200, {user} | 500, Internal server error |
API | /api/activities | GET | - | Get all activities | 200, [{activity}] | 500, Internal server error |
API | /api/activities/:activityID | GET | Valid activity ID in URL / A header : '{ Authorization: Bearer ${storedToken} }' |
Get details about activity | 200, {activity} | 400, Specified id is not valid / 401 Wrong credentials |
API | /api/sports | GET | - | Get all sports and their activities | 200, [{sport}] | 500, Internal server error |
API | /api/sports | POST | name, iconUrl, imageUrl in form-encode | Create a new Sport | 200, {sport} | 500, Internal server error |
API | /api/sports/:sportID | GET | Valid sport ID in URL | Get details about a Sport | 200, {sport}, populated | 400, Specified id is not valid |
https://sportup-server.cyclic.app/api
Currently hosted at cyclic our API is fully functional and can be tested via POSTMAN/Insomnia/ any other client. Feel free to give it a shot and see what activities we have stored.
- Node JS
- Express JS
- Mongoose / MongoDB
- Cloudinary / Mutler
- bcryptjs
- jsonwebtoken
If you want to install our API on your own host:
- Clone the repository
- Run "npm -i" to install all packages
- Create a .env file in root directory and set the proper variables:
- PORT=
- ORIGIN=
- MONGODB_URI=
- TOKEN_SECRET=
- CLOUDINARY_NAME=
- CLOUDINARY_KEY=
- CLOUDINARY_SECRET=
- Run "npm run dev" to run the server through nodemon
- Run "npm run start" to run the server for normal operation
- If everything is set up correctly you should get this message:
Server listening on port <url:port>
Connected to Mongo! Database name: <database name>