Tutorials wiki api is an api that will allow users to create blogs alike tutorials in serveral topics.
The purpose is to have a platform to share quality information among the users.
In order to publish or read these tutorials, a user must be authenticated.
-
The general architecture of this implementation follows the rules of The Clean Code Architecture by Robert C. Martin (Uncle Bob), and the purpose is to make a distinction between the core functionalities and the used technologies, which will make the api less independent on these technologies we can easily change a framework without affecting the main functions
-
Main used technologies in this implementation:
- Make sure to have a running instance of Mongodb (Either locally or on the cloud using Mongodb Atlas)
- Clone the current repository
git clone https://github.com/iSamBa/tutoswiki-api.git - In the root folder create a
.envfile in which you need to specify the url to your data baseDATA_BASE_URL=<url to your data base> - Open a terminal in the root folder of this project and run
npm installto install all the dependencies - Start the server with
npm start
The API contains 3 main routes:
/users: Accessible by authenticated users only, and contains CRUD operations for the user entity/posts: Accessible by authenticated users only, and contains CRUD operations for the post entity/auth: User authentication, used for the/login,/registerand/logout
The authentication has been implemented using Passportjs, especially the Passport-local strategy.
The password given by the user is hashed with a generated salt using crypto.
After login in, a session with the user information is stored in the data base in the sessions collection, and a cookie is generated for that specific user and will be added to the headers.
Besides the status, the body of all responses sent by the API are structured in the following way : {ok: true, data} or {ok: false, message}
- The possibility to create an Admin user
- Restrict the access to
/usersroute to Admins only - Implement automatic testing
- Deploy to Heroku
- Create a docker image of this api