Skip to content

Latest commit

 

History

History
154 lines (97 loc) · 6.01 KB

GETTING-STARTED.md

File metadata and controls

154 lines (97 loc) · 6.01 KB

Getting started

You cloned repository already and you want to start. Okay, let's go together through all the steps.

Step 1. Environment

cp settings-sample.js settings.js

Command above will copy sample settings to settings. It's mandatory to have your own settings.js.

In this file you'll see your pre-defined database connection. It should work, but make sure you have your own credentials file.

Step 2. Database connection and credentials

It's important to have ./libretaxi-development-credentials.json before you can run the app.

We encourage you to have at least two files:

  • libretaxi-development-credentials.json - credentials for development environment.
  • libretaxi-production-credentials.json - credentials for production environment.

But for development purposes (and quick start) it's enough to have only first one (development).

Here is how to generate libretaxi-development-credentials.json:

  • Go to Firebase console and click "Create new project" (Note that Firebase and/or Firebase API is not available in some countries. For example, in Iran. You may need to use VPN).

  • Create a Firebase project, type githubusername-development as project name (replace githubusername with your github username or any unique string). Click "Create Project". You will need to update the Firebase connection string in your settings.js file with the Project URL. For example, if you title your project,githubusername-development, your Firebase connection string would likely be: https://githubusername-development.firebaseio.com/ (if the title of your project is not unique to Firebase then Firebase will add unique text to your Firebase connection string)

  • Click on cog icon, select "Project settings", select "Service Accounts" tab. If it doesn't work, try this url.

  • Click on "Generate private key". Download file as libretaxi-development-credentials.json and put it to project directory.

Keep in mind that credentials file is git-ignored. We do not recommend to add it to your git repository.

Step 3. Indexes (recommended)

Also, make sure you have firebase indexes on users.q. If you don't have indexes, software will work anyway, but you may see the following warning:

FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "g" at /users to your security rules for better performance

Here is how you can enable index. Add the following two lines into your rules section on your project's database. For example, if your project was titled, 'githubusername-development', your could edit database rules by putting this in browser: (https://console.firebase.google.com/project/githubusername-development/database/rules):

    "users": {
      ".indexOn": "g"
    },
    "orders": {
      ".indexOn": "g"
    }

(g stands for "geofire" - library used to search by geo location).

So your configuration will look like this:

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null",
    "users": {
      ".indexOn": "g"
    },
    "orders": {
      ".indexOn": "g"
    }
  }
}

IMPORTANT! Do not miss comma (,) on line 4.

Click "Publish" button.

Screenshot:

image

Step 3. Telegram tokens

In Telegram app open dialog with @botfather:

image

Type /newbot command and follow instructions.

Step 4. Get your Google Maps API key

Google Maps API key is required to lookup street addresses, if they're provided. For example, a user can type street address and hit Enter, instead of clicking "Send location" button:

image

In this case LibreTaxi tries to convert this address into coordinates and Google Maps geocoder is used. Also, LibreTaxi can be configured to use other street address resolver (MapQuest, OpenCage, etc). See node-geocoder for details (you may want to skip this link if you're configuring LibreTaxi for the first time).

To get your Goolge Maps API key, go to Developer's Guide here and click "Get a key". Update your settings.js with newly generated key (see GEOCODING_API_KEY);

Step 5. Add changes to your hosts file.

(required for development, optional for production).

Make sure 127.0.0.1 localhost.firebaseio.test is specified in your /etc/hosts. It's required for tests. Don't worry, if you won't specify this, before-all test will fail.

See also:

Step 6. Install Redis.

Redis installation is covered in REDIS.md. Nothing fancy here. before-all test will fail if you did something wrong.

You're good now!

When everything's done, it's time to test and run:

  • npm test - Run tests. All tests should pass.
  • npm run telegram - Start Telegram bot.
  • npm run build-production && npm run telegram-production - Start Telegram bot for production.
  • npm run cli - Start CLI version of the bot.
  • npm run tools:purge - Purge stale orders, see #528

Shutting down

It's recommended to shut down Telegram bot gracefully. With pkill -f "node.*libretaxi" command you should see the following output:

$ npm run telegram

> libretaxi@0.1.0 telegram /Users/ro/work/libretaxi
> babel-node ./src/app-telegram.js

OK telegram bot is waiting for messages...
Shutting down gracefully...
Kue shutdown: OK

Still have issues?

I know we should use Docker, Vagrant or something else. If you feel enthusiastic go ahead and add it! Explain in detail how to use it and create a repo.