The backend server for PINUS Website.
- Ensure you have the latest:
- npm
- node
- yarn (Install it via
npm install -g yarn
) - Firebase CLI (Install it via
npm install -g firebase-tools
)
- Install all the dependencies:
> yarn install
- Create and set up the development database:
(Note: <USERNAME>
and <PASSWORD>
are available in src/db/config/config.js
,
<POSTGRES_PASSWORD>
is your local postgres
password)
> createuser -U postgres --createdb --pwprompt <USERNAME>
Enter password for new role: <PASSWORD>
Enter it again: <PASSWORD>
Password: <POSTGRES_PASSWORD>
> yarn db:setup
-
Duplicate the
.env.sample
file and rename the copy to be.env
. -
Start the development server:
> yarn start:dev
- Open another terminal and start the Firebase Authentication Emulator:
> yarn firebase:dev
Run any of the scripts below by yarn <SCRIPT>
.
Runs the server with nodemon
.
The server will reload if you make edits.
You can also manually restart the server by typing rs
into the console.
Starts the Firebase Authentication Emulator.
This service will act as the local version of the real Firebase Authentication.
Creates the local database and sets up the tables, relations, and fill in with dummy data.
Runs db:create
, db:migrate
, and
db:seed
behind the scenes.
Fixes formatting errors in all project files with eslint --fix
in quiet mode.
Runs the server with node
, provided that the project is already built
(see: build
).
Builds the project with tsc
.
Creates the local database, with the credentials provided at src/db/config/config.js
.
Deletes the local database.
Runs pending database migrations.
If executed on a newly created database (e.g. via db:create
) or a
database that has just been reset (e.g. via db:reset
), essentially
sets up all the database tables and relations.
Reverts the latest database migration.
Resets the database, removing all tables and relations.
Seeds the database with dummy data specified in src/db/seeders/
files.
Clears the database.
Usage: yarn migration:generate --name MIGRATION_NAME
Creates a migration file with the specified migration name.
Usage: yarn model:generate --name MODEL_NAME --attributes ATTRIBUTES_1:TYPE_1 ...
Creates a model file with the specified name and attributes.
Also creates a migration file for creating the corresponding model.
Usage: yarn seed:generate --name <SEED_NAME>
Creates a seed file with the specified seed name.