This in an experimenatl API written in Elixir using Ash framework
This api is powered by Ash JSON:API along with elixir-plug as the webserver.
Run the following commands:
mix deps.getto download all the dependenciesmix ash_postgres.createto create the database. please cheeck theconfig/dev.exsto correct username and password is set.mix ash_postgres.generate_migrations --name initto create the necessary databse migration filesmix ash_postgres.migrateto run the database migrationiex -S mixto start the apploication in interactive mode
This API has 6 resources i.e. geo, locations, route, seat, trip and vehicle. to learn more about resources and ash framework philosophy, please refer to the docs.
To view all the routes that are avialable for a given resource, run this in your iex session
BusApi.Booking.Resources.GeoPoint
|> AshJsonApi.Resource.Info.routes()
Your can do the same for any other resource. To test if the api is working run http request using any client of your choice.
curl -X POST 'localhost:4000/geo' \
--header 'Accept: application/vnd.api+json' \
--header 'Content-Type: application/vnd.api+json' \
--data-raw '{
"data": {
"type": "geo",
"attributes": {
"name": "Newyork",
"lat": 200202,
"lon": 1161616
}
}
}'
To view the created data
curl -X GET 'localhost:4000/geo' \
--header 'Accept: application/vnd.api+json' \
--header 'Content-Type: application/vnd.api+json'
To learn more about JSON:API specification refer to the following docs