Keep your eyes on the sky!
Created with Elixir and Phoenix.
Made with β€οΈ
- Create, delete, get and updates articles
- List articles all articles
- 9AM cronjob to get data from Space Flight API
- Elixir
- Erlang
- Phoenix
- Postgres database
SSH URLs provide access to a Git repository via SSH, a secure protocol. If you have an SSH key registered in your GitHub account, clone the project using this command:
git clone [email protected]:LuizFerK/SpaceEx.git
In case you don't have an SSH key on your GitHub account, you can clone the project using the HTTPS URL, run this command:
git clone https://github.com/LuizFerK/SpaceEx.git
Both of these commands will generate a folder called SpaceEx, with all the project
- Run
mix deps.get
to install the dependencies - Create a postgres database named
spaceex
- On the
config/dev.exs
andconfig/test.exs
files, change your postgres user and password - Run
mix ecto.migrate
to run the migrations to your database - Run
mix openapi.spec.json --spec SpaceexWeb.ApiSpec
to create the api docs (OpenAPI 3.0) - Run
mix phx.server
to start the server on port 4000
- Run
mix deps.get
to install the dependencies - Change de app url on
config/prod.exs
- Run
mix openapi.spec.json --spec SpaceexWeb.ApiSpec
on a SSL connection or remote-cli to create the api docs (OpenAPI 3.0) on the production environment - Run migrations on your production database with
mix ecto.migrate
on a SSL connection or remote-cli - Run
export SECRET_KEY_BASE="$(mix phx.gen.secret)"
to create a hashed secret key - Run
export DATABASE_URL="<your_database_url>"
to get the database connection - Run
MIX_ENV=prod mix release
to create the first release with Releases - Run
MIX_ENV=prod APP_NAME=spaceex PORT=4000 _build/prod/rel/spaceex/bin/spaceex start
to start the production server
If you use Insomnia as your HTTP API requester, you can use the Insomnia SpaceEx Collection to set up your requests as fast as possible!
This app is hosted on Heroku, if you don't want to set up the project, you can use the already deployed server on
https://apispaceex.herokuapp.com/
.
-
βͺ Wellcome - GET
http://localhost:4000/
- Response - 200 Ok
Back-end Challenge 2021 π - Space Flight News
-
π’ Create - POST
http://localhost:4000/articles
-
Request
{ "id": 0, "featured": false, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] }
-
Response - 201 Created
{ "id": 0, "featured": false, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] }
-
-
π΄ Delete - DELETE
http://localhost:4000/articles/:id
Response - 204 No Content -
π£ Get - GET
http://localhost:4000/articles/:id
-
Response - 200 Ok
{ "id": 0, "featured": false, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] }
-
-
π‘ Update - PUT
http://localhost:4000/articles/:id
-
Request:
{ "featured": true }
-
Response - 200 Ok
{ "id": 0, "featured": true, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] }
-
-
β« List - GET
http://localhost:4000/articles
-
Pagination queries:
-
page: number of the page
-
page_size: number of articles per page
Example:
http://localhost:4000/articles?page=1&page_size=10
-
-
Response - 200 Ok
[ { "id": 0, "featured": true, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] }, { "id": 1, "featured": false, "title": "string", "url": "string", "imageUrl": "string", "newsSite": "string", "summary": "string", "updatedAt": "string", "publishedAt": "string", "launches": [ { "id": "string", "provider": "string" } ], "events": [ { "id": "string", "provider": "string" } ] } ]
-
-
βͺ Get - GET
http://localhost:4000/docs/json
Response - 200 OpenAPI 3.0 docs (JSON) -
β« Get - GET
http://localhost:4000/docs
Response - 200 OpenAPI 3.0 docs (Swagger UI)
- Ecto
- Quantum (articles cronjob)
- Tesla (http client to external apis)
- Scrivener Ecto (database pagination)
- Credo (linting)
- Open API Spec (Docs)
- Mox, Bypass, Ex Machina and Excoveralls (tests)
Find a bug or error on the project? Please, feel free to send me the issue on the SpaceEx issues area, with a title and a description of your found!
If you know the origin of the error and know how to resolve it, please, send me a pull request, I will love to review it!
Released in 2021.
This project is under the MIT license.
This is a challenge by Coodesh
Presentation link on Loom: https://www.loom.com/share/728db4617a9f41a7bd792c888e7ddf05
< keep coding /> π β€οΈ