-
Notifications
You must be signed in to change notification settings - Fork 0
Workflow
Henrique Rocha edited this page Aug 25, 2021
·
1 revision
- The API starts running on PORT and begins the connection with MongoDB using MONGO_CLIENT_URL.
- It will accept only GET methods on the routes detailed at Endpoints.
- When it receives a GET request on the main route (api/v1/:user) it will do the following
- Call the Intra API:
- First it will send a POST request to https://api.intra.42.fr/oauth/token to get an authorization token, using CLIENT_ID and CLIENT_SECRET.
- Then using the received token, it will send a GET request to https://api.intra.42.fr/v2/users/:user to get a JSON of information about the user.
- Parse the received JSON.
- Send the parsed JSON to the client.
- Persist it on MongoDB Atlas.
- Call the Intra API:
- When stopped (SIGTERM), it frees everything and shuts down gracefully.
- If the requested user isn’t in the database, it will be added, but if it already exits, only its informations are updated.
- Because of the limitations of C, it can only respond one request at a time.
- If you send invalid methods, you’ll get an 400.
- If you send a method on a invalid URI, you’ll get an 404.
- If you send a non-implemented method on a valid URI, you’ll get an 405.