API documentation is separated by main endpoint, you can see a complete liste of avaible route on the main route of the API when your local server is launched: http://localhost:8734/v1.
- AUTH https://documenter.getpostman.com/view/1383513/UVXqDsJq
- CRUD https://documenter.getpostman.com/view/1383513/UVXqDsJr
API documentation is WIP
The main goal of the AUTH system is to define functionality for: REGISTER, LOGIN, LOGOUT and CHECK JWT.
When a user is registered, we still need to implement email check to validate email, he need to login to generate a sever-side JWT send in HTTP read only cookie. The JWT is valide for 60 days and each POST, PUT and DELETE calls on the CRUD System needs JWT.
The authGuard() function is used in all routes, but only specific routes are defined in the RouterService constante to be protected by JWT.
- CRUD system https://bit.ly/3nKPeiH
- RouterService https://bit.ly/3tPcaBf
- apiAuthguard() https://bit.ly/33HgDLN
- JWT https://jwt.io
The main goal of the CRUD system is to define functionality for HTTP vers; POST, GET, PUT and DELETE.
The CRUD structure is based on the endpoints defined in "router.service.js" within the RouterService constant. Each routes are checked within the apiAuthguard function defined in "auth.service.js", to add a new route in the API create a new entry in the RouterService constant.
When you create a new route you dont need to create PostgeSQL table, the function checkTable() in the file "/postgres.service.js" automatically create table if not existe. The structure of the RouterService constant must be set properly to let the system run like it does.
- CRUD system https://bit.ly/3nKPeiH
- RouterService https://bit.ly/3tPcaBf
- apiAuthguard() https://bit.ly/33HgDLN
- checkTable() https://bit.ly/3rMNQh4
For a complete use of the DWS Legalstorm API RestFull you need to install severale dependencies from NPM. We choose them with for there strongness and with the goal to limit there importance. The largest of these is PostgreSQL (https://www.postgresql.org) which is not covered by this documentation. To install it, you need to define your specific setup and follow the PostgreSQL documentation.
- BcryptJS package for cryptography
- Cookie Parser package to manage cookies
- Crypto-js Node.js package for cryptography
- Dotend to set up environment variables
- EJS to set up view engine
- Express has Node.js framework
- JSON WebToken Official package for Web Token in Javascript
- Node Mailjet Official Mailjet package for Node.js
- Node Mailer main package to send email, associated to MailJet
- PG Official PostgreSQL ORM for Node.js
- Socket.io main package to manage Web socket
- UUID package to generate UUID
- Web Push Official Push Notification package
The DWS Legalstorm API RestFull works with environment variables, you first need to create a .env
file in your local folder with the followed informations:
# SERVER
SERVER_URL=...
SERVER_API_VERSION=...
SERVER_ADMIN_UUID=...
SERVER_ADMIN_EMAIL=...
SERVER_ADMIN_PASS=...
SERVER_PORT=...
SERVER_COOKIE_NAME=...
SERVER_JWT_SECRET=...
SERVER_COOKIE_SECRET=...
SERVER_CRYPTO_KEY=...
# POSTGRES
POSTGRES_USER=...
POSTGRES_HOST=...
POSTGRES_DB=...
POSTGRES_PORT=...
# NOTIFICATION
NOTIFICATION_PUBLIC_KEY=...
NOTIFICATION_PRIVATE_KEY=...
# SMS MAILJET
SMS_API=...
SMS_URL=...
SMS_VERSION=...
SMS_SMTP_FROM_NAME=...
# EMAIL MAILJET
SMTP_HOST=...
SMTP_PORT=...
SMTP_USER=...
SMTP_PASS=...
SMTP_FROM_EMAIL=...
SMTP_FROM_NAME=...
SMTP_ADMIN_EMAIL=...
To store informations needed for the DWS Legalstorm API RestFull a PostgreSQL server is used in the background, you need to instal and start it localy before install the dependencies like below:
npm i
Then start the server
npm start
You can use Nodemn with
npm run dev
If server is correctely launched, console must be:
{
api: 'http://localhost:8734',
version: 'v1',
PostgreSQL: '127.0.0.1:5432',
socket: true,
webpush: true,
emailTransporter: true,
smsTransporter: true
}