The app will consist the following user model attributes:
name
email (unique)
password
role (admin or member)
The api provided will be :
GET: /api/users (return list of available users)
POST: /api/users (create a new user). User attributes are
GET: /api/users/:id (get a user by id)
DELETE: /api/users/:id (hard delete user)
POST: /api/login (send login request, pass email and password, and get JWT token)
PATCH: /api/users/:id (update name, email, role)
PUT: /api/password (update password)
Client can also subscribed to an event using websocket by listening to event name eventMemberUsers
on port 3000.
You can try the websocket by opening the client example at folder /client
You can import the postman collection using the following json link Postman JSON Collection
You can access the swagger documentation by running the project and reach to http://localhost:3000/docs
to access the documentation
The following command with created the user with admin role on the database.
npm run typeorm migration:run
The credential for the user will be:
- email: admin@primaku.com
- password: #Admin123
- role: admin
You can run the project using docker by following steps:
- Add .env file containing all the credential needed by following the .env.example file
- using pre-assemble docker image from docker hub using the following command
docker run --env-file .env sudtanj/user-api-with-socket:latest
# install the dependencies
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov