Make sure you have at least Node.js v14, you're running PostgreSQL and create a database called 'gncs_db' before starting the app.
If not:
- Install Postgres
- Check postres installation
psql --version
- Access Postgres database server
psql
- Create database with
Create database gncs_db;
- list user with \du
- list databases: \l
Create a new .env
file copying from the .env.example
file and update the PSQL_X
values
To test, if the database is connected to the server and healthy, check http://127.0.0.1:3333/_api/health
Run installation npm install
.
Before you start you need to:
- Migrate the database: Run the following command to run migration.
npm run migrate
Start the app with
npm run dev
AdonisJS uses Japa for writing and executing tests. So we do.
Make sure you've created a database called gncs_test
.
Update the file .env.test
[See documentation](https://docs.adonisjs.com/guides/testing/introduction#environment-variables) and add the
PSQL_values to use the test database. Make sure you have set the
SESSION_DRIVERto
memory.
SESSION_DRIVER` is switched to persist session data within memory and access it during tests. Using any other driver will break the tests.
Run npm run test
to run the tests.
Japa uses Chai assertions
To list all available routes run node ace list:routes
To checkout the swagger UI, go to /docs. Here you can test each endpoint (don't forget the execute
button!)
You can also see the database models on swagger.
This is defined in the swagger file at docs/swagger/gncs-api.yml
Search for components
and you can see the database parts.
To checkout the swagger UI, go to /docs and scroll down.
On the app server you need to create the database and user initially
CREATE USER gncs_user with encrypted password 'password';
CREATE DATABASE gncs_db;
GRANT ALL PRIVILEGES ON DATABASE gncs_db TO gncs_user;
Recommended extensionsfor your editor for Adonis are as follows:
- VS Code: Edge template support is a community package to syntax highlight the Edge templates.
- official AdonisJS extension
- Swagger Viewer
- OpenAPI (Swagger) Editor