- Node.js
- Express.js
- PostgreSQL
- Docker
-
Build and Run with Docker:
docker compose up --build
Make sure you have Docker daemon installed locally on your system. Once this is up, it should create a container called
hashstack-finance-assignment
.
- (Optional) Add a .env file in root:
I have added the .env for setting it up on local with convenience (ideally a .env file should be created before running the application, & put the below mentioned in that .env file)
POSTGRES_DB= Enter postgres_db_name POSTGRES_USER= Enter postgres_db_user POSTGRES_PASSWORD= Enter postgres_db_password DB_HOST=postgres DB_PORT= Enter postgres_db_port PORT= Enter application_port
-
Create user API:
curl -X POST http://localhost:3000/create-user -H "Content-Type: application/json" -d '{"mobile": "7778889990", "username": "Snehomoy"}'
-
To get an user using mobile number API:
curl "http://localhost:3000/get-user?mobile=7778889990"
-
Logout user API:
curl -X POST http://localhost:3000/logout -H "Content-Type: application/json" -d '{"mobile": "7778889990"}'
/user-session-management
|-- app.js
|-- server.js
|-- .env
|-- Dockerfile
|-- docker-compose.yml
|-- /controllers
| |-- userController.js
|-- /models
| |-- userModel.js
| |-- sessionModel.js
|-- /db
| |-- index.js
|-- /utils
| |-- generateSessionKey.js
|-- package.json