Create a new file in the project root called .env
:
vim .env
Populate it with this data, changing the foo
to whatever you want. This will be your private key for your JWT.
PRIVATE_KEY='foo'
npm install
npm test
npm run reloadseed # create and populate development database with dummy data
npm run dev
curl -X POST http://localhost:3000/dev/service_provider \
-H 'Content-Type: application/json' \
-d '{"name": "Example Name", "reimbursement_percentage": 20.5, "reimbursement_cadence": "monthly"}'
curl -X GET http://localhost:3000/dev/service_provider/1/jwt \
-H 'Content-Type: application/json'
curl -X POST http://localhost:3000/dev/service_provider/members \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_JWT_TOKEN' \
-d '{"members": [{"name": "John Doe", "registration_date": "2024-01-01T00:00:00Z"}]}'
curl -X POST http://localhost:3000/dev/service_provider/activity \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_JWT_TOKEN' \
-d '{"activities": [{"member_id": 1, "activity_date": "2024-02-01T00:00:00Z", "description": "Test Activity", "value": 100.00}]}'
curl -X POST http://localhost:3000/dev/service_provider/reimburse
DATETIME should be given in UTC, like 2024-03-28T23:24:11.666
curl -X GET http://localhost:3000/dev/service_provider/reimbursement/DATETIME \
-H 'Authorization: Bearer YOUR_JWT_TOKEN'
We can also use GraphQL to access our data.
mutation {
registerServiceProviderMembers(
members: [
{
name: "John Doe",
registration_date: "2023-03-29T12:34:56Z"
}
]
) {
member_id
name
registration_date
}
}
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
--data '{"query": "mutation { registerServiceProviderMembers(members: [{name: \"John Doe\", registration_date: \"2023-03-29T12:34:56Z\"}]) { member_id name registration_date } }"}' \
http://localhost:3000/graphql
This is the GraphQL version of queryReimbursementStatus
, above. Sorry for not using the same name.
query {
serviceProviderReimbursementStatus(datetime: "2024-03-28T23:24:11.666") {
reimbursement_id
cycle_start_date
cycle_end_date
total_activity_value
reimbursed_amount
status
processed_at
}
}
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
--data '{"query": "query { serviceProviderReimbursementStatus(datetime: \"2024-03-28T23:24:11.666\") { reimbursement_id cycle_start_date cycle_end_date total_activity_value reimbursed_amount status processed_at } }"}' \
http://localhost:3000/graphql
Another example with an included association to service_provider
:
query {
serviceProviderReimbursementStatus(datetime: "2024-03-28T23:24:11.666") {
reimbursement_id
service_provider {
name
}
}
}
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
--data '{"query": "query { serviceProviderReimbursementStatus(datetime: \"2024-03-28T23:24:11.666\") { reimbursement_id service_provider { name } } }"}' \
http://localhost:3000/graphql
Migrations are used as change control on the database.
./node_modules/.bin/sequelize-cli migration:create --name create_service_providers
Then you need to edit the file in the /migrations
directory to flesh out the migration.
An example can be found at migrations/20240328170544-create_service_providers.js