Express application to handle database session based authentication using homemade classes and middleware. Repo also contains brances for authentication using express-session and passport.js
It follows the clean architecture pattern so that the business logic is separated from the express application. And the database is abstracted so that it can be easily changed.
- Node.js
- Express.js
- Typescript
- Mongoose
- Inversify - For dependency injection
- Node-cron - For scheduling tasks
- Winston - Logger
- Docker
- Docker-compose
- Clone the repository
- Run
docker compose up -dto start the mongodb container anddocker compose downto stop it
make up to start the application
make down to stop the application
make redo to restart the application
- Register a user by sending a POST request to
api/user/registerwith the following payload:
{
"email": "email@email.com",
"password": "password"
}-
Verify the user by sending a GET request to
api/user/verify-emailwith the link received in the mock email that is printed in the apps terminal in Docker. -
Login by sending a POST request to
api/auth/loginwith the following payload:
{
"email": "email@email.com",
"password": "password"
}-
Logout by sending a POST request to
api/auth/logout -
Get password reset token by sending a POST request to
api/user/forgot-passwordwith the following payload:
{
"email": "email@email.com"
}- Reset password by sending a POST request to
api/user/reset-passwordwith the token received in the response from the forgot-password endpoint.
params: ?token=TOKEN
body:
{
"password": "password"
}- GET endpoint
api/testis available to fetch the datas from the database.