Open-source web API for Votatoon client.
In order for setting up the Votatoon API, you will need to set up the following environment variables:
- DATABASE_HOST - The host where the database server is running
- DATABASE_NAME - The name of the database to connect to
- DATABASE_PASSWORD - The password of the user who owns the database
- DATABASE_PORT - The port where the database server is running
- DATABASE_SYNCHRONIZE - Whether the database should be synchronized with the entities. Set to
1
for development and first set up of the application, and0
for production - DATABASE_USERNAME - The name of the user who owns the database
- INIT_VECTOR - The initial vector that is used to encrypt/decrypt IP addresses from the clients
- SECURITY_KEY - The security key that is used to encrypt/decrypt IP addresses from the clients
IMPORTANT:
- You can generate values for
INIT_VECTOR
andSECURITY_KEY
environment variables by using online tools like All Keys Generator. - Both
INIT_VECTOR
andSECURITY_KEY
must be 512-bit, must have 32 characters and cannot be hex (unless they're 256-bit). - Avoid using the same value for both
INIT_VECTOR
andSECURITY_KEY
environment variables. - You can set the values of the environment variables in your terminal by using the
export
command. - Avoid using characters like
"
,'
,$
and!
in the values of the environment variables. - Once you set the values of the environment variables, you will need to create another session in your terminal in order to allow the application to access the new environment variables.
- You must set up the environment variables by setting them for your Operating System internal use.
-
Windows:
- Open
Settings > System > About > Advanced system settings > Environment Variables
. - Now, you can decide whether defining environment variables for specific users or for the entire Operating System. My personal suggestion is to define them for specific users.
- Click
New...
button. - Type variable name and value.
You have to follow steps 3 and 4 per environment variable.
- Open
-
Linux:
Before starting, you must know that you can use the
export
command to set environment variables on Linux, but they may not be available after you leave your current session, so maybe you will want to set the environment variables using.(bash/zsh)_profile
file.- In order to set the environment variables, you have to use the
export
command followed by the key-value pair (like.env
files). F.E To setDATABASE_NAME
environment variable, you must use the commandexport DATABASE_NAME={{Database name}}
(without{{}}
). - If you used
.(bash/zsh)_profile
to set the environment variables, you have to use the commandsource path/to/profile/file/.(bash/zsh)_profile
, so your current session in the terminal will be updated with the new set environment variables.
For more information about setting environment variables on Linux, you can check out this tutorial.
- In order to set the environment variables, you have to use the
This application needs port 3000 by default for running on, but if you want to use a different port, you can set it by setting the environment variable PORT
.
Note that this behavior allows you to deploy your own instance using a VPS/PaaS like Heroku or Digital Ocean.
Once you have running the application, you can go to http://<address of host where you're running the application>:<port where you're running the application>/api
to see the API documentation, so you can understand how this application works when it receives any request.
# development
$ npm install
# production mode
$ npm install --prod
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
This project is MIT licensed.