Project created as part of the JS Advanced Course @ FMI
Project Contributors:
Web Nexus
simplifies the process of enhancing websites with complex functionalities effortlessly. The project offers a library, packaged with Webpack, providing users with straightforward functions to seamlessly integrate complex logic into their HTML files.- Simple example:
- I am building a Website and I want to integrade a Live Chat System. Through
Web Nexus
I can do it by just providing an empty div and some Configuration. Everything else is handled for me byWeb Nexus
.
- I am building a Website and I want to integrade a Live Chat System. Through
-
Live Chat
- Facilitates real-time communication on websites through an easy-to-use live chat functionality.
- The Communication is done through WebSockets.
-
Infinite Scroll
- Provides the user with an easy way to integrate an infinite scroll and visualize content dynamically.
- It is customizable. The User must provide us with
div
andstyles
for it as strings. - The
div
has placeholders for thedata
that we will replace. - We display them so the User has Control over how the information is displayed.
-
Live Chat
- V1:
- Done through a BackEnd Call and using a Transform Stream we generate the Chat HTML.
- The SDK adds Event Listeners to the Chat Button and the Chat Form.
- V2:
- The Chat is Generated using Custom HTML Elements that the SDK creates.
- They do everything themselves (the Event Listeners are Logic in the Classes).
- V1:
-
Infinite Scroll
- V1:
- The User Provides URL, Authentication and a
Search Replacement Map
.- If the User chooses, he could append the URL, Authentication and Replacement Map
in a
before callback
instead of providing them in the setup. - He can delete them in an
after callback
.
- If the User chooses, he could append the URL, Authentication and Replacement Map
in a
- The
Search Replacement Map
is a Map that holds fields from the response withtrue
orfalse
value depending on if we need to replace them in thediv
with the value from the response. - We run the REST call, and we search the Response for Elements that match the Replacement Map.
- We replace the Elements in the provided
div
and append it to the HTML. - The Response must be a JSON.
- This is done so the User can have more control over the REST call (a lot of APIs require Pagination using Request Params).
- The User Provides URL, Authentication and a
- V2:
- The User does not provide us with sensitive information like URL or Authentication.
- Instead, he provides us with a Callbacks that return Promises that Resolve in
Replacement Map
. - Note: This is not the
Search Replacement Map
from V1. It holds the information we directly replace in thediv
. - The User has more control over the REST call and the information he wants to display.
- For example, here the API call could not be a JSON. The User needs to just transform it to a JSON.
- V1:
The general idea for the backend is that all the needed data will come from it, including the HTML elements for different functionalities. The library will append them where needed and attach event listeners.
-
Express Server API
- Serves as the primary data source for dynamic HTML content generation by the library.
- Responsible for processing all data and forwarding it to the library for seamless integration.
-
Socket Communication
- Utilizes sockets for live chat and other functionalities requiring periodic live updates.
-
Authorization Mechanism
- All calls to the backend must undergo authorization.
- Authorization is implemented using Json Web Tokens (JWT).
-
Redis Integration
- Usage: Planned for yet-to-be-determined functionality.
- Purpose: Enhance the backend with Redis for optimized data storage, caching, or other potential use cases.
- Consists of functions that call the backend.
- Dynamically appends received data or HTML elements in the appropriate HTML files.
- Attaches event listeners to the elements.
- The library is packaged with Webpack.
- WSL If you are on Windows
- Docker Engine
- Docker Compose
cd /path/to/your/project
docker compose up
If you want to run it in detached mode
docker compose up -d
docker ps
Note that sometimes it requires sudo in front of the command.
Open terminal and navigate to the db folder
cd /src/config/db
Then type:
npx knex migrate:make <migration file name> --knexfile knexfile.js
Open terminal and navigate to the db folder
cd /src/config/db
Then type:
npx seed:make <seed file name> --knexfile knexfile.js
In package.json there are configured commands for both migrations and seeds. When you execute in terminal one of the following commands:
npm run migrate
npm run seed
This instructs Knex to run the migration files that have not been executed yet. It looks at the knex_migrations table in your database to determine which migrations have been applied and which are pending, and it applies the pending migrations.
Knex maintains a knex_seed table (or a table name specified in the configuration) in your database to track which seed files have been executed. When you run knex seed:run, it checks this table to determine which seeds have already been applied.
- Save chat in DB and Redis.
- Use import instead of require when importing a module and not a library.
- Add Successful Request check in all fetch calls. Make Demo an ejs app.
- Attach CSS to head. Fix EventListeners setup in Login/Register Form.
- Add Live Chat V2
- Adapt Infinite Scroll V1/V2 to classes. V2 extends V1.
- Add Infinite Scroll V2
- Fix Authentication Bugs
- Create authentication with JWT. Add Register, Login and Authentication Logic in SDK and Backend.
- Create Infinite Scroll V2. Extract shared Infinite Scroll Logic in common.js.
- Add migrations and seeds with Knex.
- Move Config Files to a Config Directory.
- Added Postgress DB Dockerfile and docker-compose.
- Restructured the Directory Hierarchy.
- Added a Router Logic for the API.
- Added Initial Version of the Infinite Scroll Functionality.
- Added Live Chat Functionality.
- Initial commit.