Coder Social home page Coder Social logo

roadmapbackend's Introduction

RoadmapBackend πŸ—ΊοΈ

A swift vapor back-end to run your own Roadmap server and database. The database uses postgreSQL.

To run your own back-end there is 2 solutions:

  1. Use a free Remote server & database
  2. Use your server

Remote server & database

This method has the advantage of being free and accessible for the roadmap usage.

Requirements πŸ‘·

Database - ElephantSQL πŸ“¦

It is pretty straightforward. Create your account with a Tiny Turtle plan, and you are ready.

πŸ—‘οΈ API - Koyeb

Koyeb offers the possibility to deploy an API easily. Once you have your account and started to create your instance, this is the configuration you could use to run a healthy service:

  1. Choose deployment using a Github repository.
  2. Add the github project link (I recommend you to fork the repository as koyeb will deploy each time there is a commit).
  3. Choose the Dockerfile builder.
  4. Override the entrypoint : ["./App"]
  5. Override the command: serve
  6. Override the arguments ["--env","production","--hostname","0.0.0.0","--port","8080"]
  7. Choose the Web Service type.
  8. Choose the region you want.
  9. Choose the instance (nano instance should be sufficient for this API)
  10. Next add the following environment variables so your API knows how to connect to the database:
Variable Name Type Value
DATABASE_HOST PlainText db_server
DATABASE_USERNAME PlainText db_username
DATABASE_PASSWORD PlainText db_password
APP_PORT PlainText 8080

Note

You can find and manage that informations in your elephantSQL account console.

  1. Expose the 8080 port with the HTTP protocol and / for the Path.
  2. Put a scaling number of one (it should be plenty for our usage).
Step 1 to 6 in image

CleanShot 2023-09-13 at 21 52 22

Step 7 to 12 in image

CleanShot 2023-09-13 at 21 11 27@2x

Your server

Requirements πŸ‘·

  • Docker to deploy the API and the database.

Deployment

If you have your own server already, you can put a .env file at the root of this repository with the following values:

DATABASE_HOST=[db_host]
DATABASE_USERNAME=[db_username]
DATABASE_PASSWORD=[password]
APP_PORT=8080
Those values depend on how you want to configure your database. See a simple and complete example here πŸ‘‡
DATABASE_HOST=db
DATABASE_USERNAME=vapor_username
DATABASE_PASSWORD=vapor_password
APP_PORT=8080

When you have the .env file set up, you can run this command at the repository root to build and run the API and the database:

docker-compose up --build

Next you should expose the API port and you are ready.

How to call your in server in your iOS app?

You can take inspiration from the gist from Tyler Stillwater that already shows how to use a custom API.

⚠️ You must change the URL endpoint call to be:

https://[YOUR_APP].koyeb.app/get/{namespace}/{featureId} to get the feature count.

https://[YOUR_APP].koyeb.app/add/{namespace}/{featureId}/{delta} to increment or decrement the feature count.

Acknowledgement πŸ™

Thanks for Antoine, Jordi and Hidde van der Ploeg to have developed a valuable Swift Package like Roadmap.

Also thanks for Tyler Stillwater for integrating the possibility to use a custom API and inspire me to develop this project.

roadmapbackend's People

Contributors

valentin-mille avatar macintosh-hd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.