|
|
2 vuotta sitten | |
|---|---|---|
| .. | ||
| db | 2 vuotta sitten | |
| lib | 2 vuotta sitten | |
| server | 3 vuotta sitten | |
| tests | 2 vuotta sitten | |
| .env.sample | 2 vuotta sitten | |
| .eslintrc | 3 vuotta sitten | |
| .nycrc | 5 vuotta sitten | |
| .prettierrc | 3 vuotta sitten | |
| README.md | 2 vuotta sitten | |
| docker-compose.yml | 3 vuotta sitten | |
| knexfile.js | 3 vuotta sitten | |
| package-lock.json | 2 vuotta sitten | |
| package.json | 2 vuotta sitten | |
An API for the siimee application
You will need…
brew install node using Homebrewapt install nodejs (see Ubuntu/Debian specific instructions) or pacman -S nodejs (Arch Linux)npm install./backend/.env.sample and rename it to ./backend/.env./backend/.envdocker-compose up -dnpm run generate && npm run reseedThis note is added in case Brevo fails to install correctly, as it requires some extra configuration:
npm install @getbrevo/brevo --save
npm link .
Transactional emails using the Brevo api should now be working.
We use Knex.js,which comes with a couple nice database migration and seeding tools.
Migrating tracks changes in schema. Migration steps are contained in the ./db/migrations folder. Seeding adds dummy data once our database tables have been created and schemas are set. Starting seed steps are contained in ./db/seeds and use the mock.js file as the main dummy data source.
npm run migrate to run all migrations and establish the base schemanpm run unmigrate to roll back one migrationnpm run generate to generate dummy datanpm run seed to seed the database with generated dummy dataSince we can’t unseed the database, it’s best to destroy the dev database and rebuild it.
cd ../ and running docker-compose downdocker volume rm siimee_siimee_db. BE CAREFUL.docker-compose up -d./backend and running npm run reseednpm run start to start up the serverhttp://localhost:3001/documentation to see the interactive API documentationTBD
Tests are run with AVA with code coverage reporting via nyc. Look at the example test for ideas, as well as the ava documentation
npm testusers, responses, profiles, authentication TRUNCATE TABLE users; TRUNCATE TABLE responses; TRUNCATE TABLE profiles; TRUNCATE TABLE authentication;