The backend system for boklisten. This readme only describes development, testing and technical info. For a more deep-dive into what bl-api is, please read our documentation
- Clone this repo to your own computer
$ git clone https://github.com/boklisten/bl-api
- Inside the newly created folder do:
$ yarn install
- After the installation is done you must create a file
.env
and populate it with the required environment variables. - Ensure that mongodb is running and that you have set
MONGODB_URI
environment variable to the running instance. - In the terminal run
$ yarn dev
- You will now see a confirmation in the terminal that the application is running
- The server is by default running on
http://localhost:1337
If this is the first time you have ever set up bl-api
on your system then
the database is empty. To populate the database with some basic data you can do
so manually in the mongo shell or adding it through MongoDB compass. It is also
possible to add the data through bl-admin
.
Under is a list of data that is needed in the database for a minimal test environment.
- One user with
admin
permission- Can be done by registering a user in
bl-admin
and then editing theuser
object in the database. Change thepermission
field fromcustomer
toadmin
.
- Can be done by registering a user in
- One branch object in
branches
- Fully populated with a
name
andpaymentInformation
- Can be done manually or by uploading a excel file through
bl-admin
- Fully populated with a
- At least one Item in
items
- Can be done manually or by uploading a ecel file through
bl-admin
- Can be done manually or by uploading a ecel file through
- At least one BranchItem in
branchitems
.- Is done in
bl-admin
- Is done in
The testing is done with mocha
and chai
. Test driven development (TDD) is easy when the testing is simple to use and fast.
- Run all the tests once:
yarn test
Every typescript source file .ts
in src/
has a corresponding .spec.ts
file. This is the unit-test file for that .ts
file. Example:
order.patch.hook.ts
has a corresponding order.patch.hook.spec.ts
. This file
has all the unit-tests for the order patch hook file.
The terminal is the best place to view status when testing bl-api
. Under
development you can view every action done to the system by viewing the
terminal output.
error
warn
info
- This is the level the production server is on, only shows bear minumum information, and
error
andwarn
output.
- This is the level the production server is on, only shows bear minumum information, and
verbose
debug
silly
- This level is perferred for local development as it shows every log message the system outputs.
bl-api
is a web-server database handler. It is a nodeJS applicatin build on top of express
and MongoDB
.
- Express
- MongoDB
- NodeJS