- Node js
- Express js
- Typescript
- PostgresSQL
src/
config/development.json ...
controllers/
.... #contains the logic
dtos/
... this folder contains validation logic,type strict logic.
entities/.. this folder contains the model logic where db design is been implemented.
exceptions /.. this folder contains exceptions need to throw http error.
interfaces/ .. this folder contains the typescript type of some request and response.
logs/.. the error and debug log folder
This application consist of two part using an mvc Architecture approach
- Auth
- customer core part
The auth section which control api such as
- /api/auth/signup
- /api/auth/login
This section includes the core features used to manage the delivery service logic and the api includes.
- api/customer/createApikey
- api/customer/getApikey
- api/customer/quote
- api/customer/order
To run this application check
yarn install | npm install
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=new
POSTGRES_PASSWORD=1234
POSTGRES_DB=tinymile
PORT=5000
secret_key=loremipsum
LOG_FORMAT=dev
You need to create two db which is as followe
- tinymile for (dev)
- new for unit (test)
Incase you are using the macbook postgresSQL app
- start your postgresSQL server
- go to your terminal and paste
creatdb tinymile
createdb new
yarn dev | npm dev
make sure it is running on port 5000 and db is connected also. Sync the app model with
yarn schema:sync
This seed is needed to populate robots and robotmovement history model
yarn seed:run
or run to execute both command
bash db.sh
To check the application unit test, check the test folder. To run the test file use
yarn test
and watch it do magic
You can either use the postman collections to test or follow this description.
-> localhost:5000/api/auth/signup
Request Sample
{
"email":"john@mail.com",
"password":"johnny1234"
}
Response Sample
{
message: 'signup'
}
-> localhost:5000/api/auth/login
Request Sample
{
"email":"john@mail.com",
"password":"johnny1234"
}
Response Sample
{
token: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
}
GET
localhost:5000/api/customer/createApikey
Header : Bearer xxxxxxxxxxxxxxgxxgxxxxxxxxxxx
use the user bearer token generated here to get a public apiKey which will be use to access order services.
Response Sample
{
'xxxxxxxxxxxxxxxxxxxxxxxxxx'
}
# get user generated ApiKey
localhost:5000/api/customer/key