- update/put intra-crm-backend
.env
file in base directory - run intra-crm-backend application
- generate "ADMIN" token using
/generate-token
endpoint of intra-crm-backend - put the token (from "/generate-token") into client-crm-backend's
.env
file as value of variable/key "INTRA_CRM_API_KEY" - run client-crm-backend
- now generate an admin in intra-crm-backend using
/users
endpoint which will eventually create a same admin in client-crm-backend too. - now update the environment key/variable "SPYRE_CRM_API_SECRET_KEY" in intra-crm-backend's
.env
file. - re run the intra-crm-backend application
Note: These steps are only for the first time setup.
SERVER_PORT=the_port_you_want_to_run_intra_crm_backend_application
LOG_DIR=logs
ERROR_LOG_FILE=error.log
ALL_LOG_FILE=all.log
ENVIRONMENT=production
MYSQL_DB_HOST=your_mysql_database_url
MYSQL_DB_PORT=your_mysql_database_port(default port 3306)
MYSQL_DB_NAME=your_mysql_database_name(i was using Intra_CRM)
MYSQL_DB_USER=your_mysql_database_user_name(can be root)
MYSQL_DB_PASSWORD=your_mysql_database_user_password
DB_DIALECT=mysql
JWT_SECRET=jwt_secret_token_for_jwt_token_generate
JWT_TOKEN_EXPIRE_IN=120d
CV_LIBRARY_BASE_URL=https://jobs-api-2pfgldu3uq-nw.a.run.app
CV_LIBRARY_API_KEY=cv_lib_api_key
CV_LIBRARY_USER_PASSWORD=cv_lib_default_password
SUPER_ADMIN_TOKEN=intra_crm_super_admin_key
SPYRE_CRM_BASE_URL=clinet_crm_backend_base_url
SPYRE_CRM_API_SECRET_KEY=client_crm_admin_token (you can create an admin from clinet crm backend with "/auth/createAdmin" endpoiint and use "CLIENT_CRM_BACKEND_SUPER_TOKEN" env variable as token in the post request body)
CLIENT_CRM_BACKEND_SUPER_TOKEN=clinet_crm_super_token_will_be used_while_creating_admins_from_intra_crm_backend(endpoint POST: "/users")
CLIENT_DEFAULT_PASSWORD=the_default_password_while_creating_client_from_CLIENT_DASHBPARD_in_intra_crm
CLOWN_FISH_API=https://clownfish-app-lryu4.ondigitalocean.app/api/create
CLOWN_FISH_API_KEY=#$$8sflkj@(ACMEU8m,
TOTAL_JOBS_API=https://totaljobs-2pfgldu3uq-nw.a.run.app
TOTAL_JOBS_API_KEY=d5fb8c4fa8bd46638dadc4e751e0d68d
TOTAL_JOBS_USER_PASSWORD=England@123
as we are using join of multiple tables in some api calls, you need to setup/config the database for the first time.
- login to your mysql shell
- Run the command
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
npm install
npm run build
npm start
make sure your .env
file has the environment variable CLIENT_CRM_BACKEND_SUPER_TOKEN.
use postman or any other tool. You need to hit a POST api call on /users
endpoint.
METHOD: POST
ENDPOINT: /users
AUTH: Bearer token from env file "SUPER_ADMIN_TOKEN"
Request Body:
{
"firstName" : string,
"lastName" : string,
"email": string/email,
"role" : "Admin",
"password": string
}
RESPONSE:
{
"id": int,
"name": string,
"email": string,
"role": "Admin",
"clientCRMToken": string,
"userId": string,
"updatedAt": string (Date),
"createdAt": string (Date)
}
POST /users
BEARER TOKEN: mynameismehedihasanshifatandiamnotasoftwareengineer
body:
{
"firstName" : "Intra",
"lastName" : "CRM",
"email": "[email protected]",
"role" : "Admin",
"password":"England@123"
}
Response:
{
"id": 4,
"name": "Intra CRM",
"email": "[email protected]",
"role": "Admin",
"clientCRMToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0ODU3ZmYwZS1iNGZlLTRmMmItOTljYy02ZTZkN2E3NWQyZTkiLCJlbWFpbCI6Im1oc2hpZmF0QHNweXJlLmNvIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzEwMDU5NDEwLCJleHAiOjQ4NjU4MTk0MTB9.5gjjGPxEtPcGj8M6aC_rbbxfQvD3359P3-koAMJ7dn4",
"userId": "4857ff0e-b4fe-4f2b-99cc-6e6d7a75d2e9",
"updatedAt": "2024-03-10T08:30:10.900Z",
"createdAt": "2024-03-10T08:30:10.900Z"
}
when you are creating an admin from intra crm backend, it will create an admin in client crm backend and then save it into intra crm backend too. So, make sure this email doesn't exist already in intra_crm or client_crm either.
METHOD: POST
ENDPOINT: /generate-token
AUTH: Bearer token from env file "SUPER_ADMIN_TOKEN"
REQUEST BODY:
{
"role": "ADMIN"
}
RESPONSE BODY:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MCwiZW1haWwiOiJ0ZXN0MTIzQGdtYWlsLmNvbSIsInJvbGUiOiJBRE1JTiIsImlhdCI6MTcxMDA1OTg4NCwiZXhwIjoxNzIwNDI3ODg0fQ.-YZ-IunQJssyXU9nFPj5z4hnRYk38lXPyV6mo-2AcpQ",
"expiresIn": "120d",
"role": "ADMIN"
}
Note: You can obviously get a token by just login with the credential after creating an admin account too.
NEXT_PUBLIC_API_BASE_URL=http://localhost:5001
NEXTAUTH_SECRET="@#$Sc.wopux5642DFs24gdd"
NEXTAUTH_URL=http://localhost:3001
- NEXT_PUBLIC_API_BASE_URL refers to the intra-crm-backend base url
- NEXTAUTH_URL refers to the intra-crm-frontend base url
- if facing any issue related to login then try to clear the localstorage and reload the page or login again.
Signup API
Fetch Info From CV
Method: POST
Endpoint:
/auth/fetchSignupInfoFromCv
Req body: (just like
signUpWithCV
endpoint)Response:
Signup with fetched info from CV
Method: POST
Endpoint:
/auth/signupWithInfoFromCV
Req body: (just like
signUpWithCV
endpoint)Response: