Backend of Avengers Phantom project for team Avengers
Phantom is platform chich facilitate the transport into town, we track bus location, we assign the buses to drivers and operators.
- Get some stuffs on table
- Run
npm install
- Create
.env
in project root directory - Take a look at the
.env.example
file which is in the project root directory to have a clue on environment variables that are being used in this project - Copy all keys from the
.env.example
file to.env
file and add values to corresponding keys. These can be obtained from the project administrator - Feel free to add other keys and values according to your feature requirements
Note: Add keys in
.env.example
to ease next setup for other developers.
- Time to serve
- For you to use your new environment variable you have to import
dotenv
module in the file where you want to utilise your environment variables and configure it. like this:import dotenv from 'dotenv'; dotenv.config();
- Then you'll be able to access your environment variables via
process.env.YOUR_KEY
- That's it, you're good to go!, happy coding!
- Configuring
.env
- Download and install pgAdmin
- Create three databases, one for testing and another for development and other one for production.
- Copy
DEV_DATABASE_URL=postgres://postgres:yourpassword@yourhost:yourport/database-name
TEST_DATABASE_URL=postgres://postgres:yourpassword@yourhost:yourport/database-name
DATABASE_URL=postgres://postgres:yourpassword@yourhost:yourport/database-name
URLs from.env.example
to.env
- Edit them with your real database user, password and database name.
- Running Migrations
- Run
npx sequelize-cli db:migrate
in terminal to fire up migration
- Run
- Undoing Migrations
- Run
npx sequelize-cli db:migrate:undo
to undo all migrations
- Running Seeds
- Run
npnpxm sequelize-cli db:seed:all
in terminal to run all seeds
- Undoing Seeds
- Run
npx sequelize-cli db:seed:undo:all
in termninal to undo all seeds data from the database
- Run
npm run start:dev
in terminal
- Run
npm run test
in terminal