Simple application using types-ddd
lib from npm package.
Inspired in NestJS framework, but In this project no framework was used, to keep a clean architecture, but feel free to use any framework.
Built to work with good performance.
Show how to use
types-ddd
lib
- IUseCase: OK
- AggregateRoot: OK
- IMapper: OK
- ValueObject: OK
- DomainEvents: OK
- IDomainEvent: OK
- IHandle: OK
- Hooks: OK
- Tests: OK
- Entity
Database is running in memory.
- Clone this repo
$ git clone https://github.com/4lessandrodev/simple-ddd-app-example.git
- Install dependencies
$ yarn install
or$ npm install
- Run application
$ yarn dev
or$ npm run dev
Create an user
Body
{
"email":"[email protected]",
"password":"test123",
"name":"John Stuart"
}
Authenticate
Body
{
"email":"[email protected]",
"password":"test123"
}
Response Body
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.WQiOiI4ODAyYjhjOS1iMDljLTQ2M2MtYTI0OC1jODY5MTU0NmI5MW"
}
Get authenticated user
Headers
{
"authorization":"Bearer <token>"
}
Response Body
{
"id": "6043b122-cc60-4f0e-8008-8fcd8089e687",
"name": "John Stuart",
"email": "[email protected]",
"password": "$2b$10$9rZh7nnnW.WcoGYlt5T.s.YciLzju1j2yr1BITAs9wchTBndLOow2",
"createdAt": "2021-08-31T14:48:24.920Z",
"updatedAt": "2021-08-31T14:48:24.920Z"
}
Get registered users
Headers
{
"authorization":"Bearer <token>"
}
Response Body
[
{
"id": "6043b122-cc60-4f0e-8008-8fcd8089e687",
"name": "John Stuart",
"email": "[email protected]",
"password": "$2b$10$9rZh7nnnW.WcoGYlt5T.s.YciLzju1j2yr1BITAs9wchTBndLOow2",
"createdAt": "2021-08-31T14:48:24.920Z",
"updatedAt": "2021-08-31T14:48:24.920Z"
}
]
Create a task todo
Headers
{
"authorization":"Bearer <token>"
}
Body
{
"description":"new task todo",
"isDone": false
}
Mark a task as done
Headers
{
"authorization":"Bearer <token>"
}
Only param on url. PUT Method. This method calls a hook by domain event
Get registered tasks
Headers
{
"authorization":"Bearer <token>"
}
Response Body
[
{
"id": "6043b122-cc60-4f0e-8008-8fcd8089e687",
"description": "new task todo",
"isDone": false,
"ownerId": "a53989f0-3f55-4a66-997f-7fae4a57646b",
"createdAt": "2021-09-01T01:06:30.435Z",
"updatedAt": "2021-09-01T01:06:30.435Z"
}
]