You cloned repository already and you want to start. Okay, let's go together through all the steps.
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.
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"
-
Type
libretaxi-development
as project name. Click "Create Project". -
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.
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 this page:
"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:
In Telegram app open dialog with @botfather
:
Type /newbot
command and follow instructions.
(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:
- Docs for firebase-server - package that we use to mock Firebase for local tests.
Redis installation is covered in REDIS.md. Nothing fancy here. before-all
test
will fail if you did something wrong.
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 cli
- Start CLI version of the bot.
It's recommended to shut down Telegram bot gracefully. With pkill -f "node.*libretaxi"
command you should see the following output:
$ npm run telegram
> [email protected] telegram /Users/ro/work/libretaxi
> babel-node ./src/app-telegram.js
OK telegram bot is waiting for messages...
Shutting down gracefully...
Kue shutdown: OK
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.