Copy or rename the env
file to .env
. Populate the environment values with the appropriate values.
Currently, we are using Africa's Talking for SMSes. The plan is to use Africa's Talking for messages to countries where it is cheaper to use them and another API (eg. Twillio, Routee) for every other country.
You will need to setup Africa's talking credentials in your .env
if you want to test out SMS related functionality (eg. Sending OTP).
After that, run npm install
to install any dependencies we are using
To start the server locally, use npm run debug
to start a nodemon process. The application should now be running at localhost:8080
and all endpoints can be accessed by using that as the base url.
Example:
To send a request to the endpoint /auth
we'd use the full path: localhost:8080/auth
as the url to send the request to.
This document will constantly be evolving as the project grows.
HipGlam uses Jest to run unit tests on various components (utils and services at the moment).
To run tests, use npm run test
. All tests should be succeeding.
When defining the relationship between models, we are torn between two approaches belongs*
or has*
. How we have decided to handle this depends on the context in which we want to define the relationship between two models/tables.
If we want the owner's deletion to cascade down to the children, we use belongsTo
while if we want to retain the child even after the owner dies, we use hasMany
or hasOne
Inserts into the database always return the full sequelize response. This helps us view extra metadata about the insert operation
To access functions in another directory, one MUST access the functions through the aggregator.
Any function whose file name starts with an underscore (_
) is internal to the directory it is in and is not exposed by the aggregator for that directory. For example services/Auth/otp/_saveOtp.js
can only be accessed by files in the services/Auth/otp/
directory. Accessing these files (with underscores at the beginning) from any directory other than the directory they belong in is FORBIDDEN. These functions are meant to act as "private" functions within their directories.
-
Add subscription handling probably going to make this a separate repository that can be dragged into this codebase
-
Add payment handling (MPesa + Stripe) - Probably going to bundle this with the subscription.
-
Implement image upload & thumbnail generation functionality - Probably going to make this its own repository that can be dragged into the project
-
Refactor the code to allow for more custom behaviour as far as setting different user types is concerned. Currently, this information is loaded from the server while it should actually come from the database. Yet to figure out how to properly abstract this
The goal is to eventually make this a good NodeJS boilerplate for applications that require OTP verification (SMS for now) and no password equipped with a built in subscription system as well as payment system.
The only thing left to implement in most cases would be your business logic
Figure out how to prevent the package.json
files from clashing.