Local Development Setup
Purpose and Scope
This document covers the setup and configuration of a local development environment for contributing to the jsjiit library. It explains how to clone the repository, install dependencies, run the local HTTPS test server, and test changes during development.
For information about building distributable artifacts and releasing new versions, see Build and Release Process. For details on the testing methodology and validation strategies, see Testing and Validation.
Prerequisites
The jsjiit development environment requires the following tools:
| Tool | Minimum Version | Purpose |
|---|---|---|
| Node.js | 18.x or higher | Required by esbuild and jsdoc |
| npm | 7.x or higher | Dependency management and script execution |
| Python | 3.x | Required for run_server HTTPS development server |
| OpenSSL | Any recent version | Certificate generation for local HTTPS |
| Git | Any recent version | Version control |
Initial Repository Setup
Cloning the Repository
git clone https://github.com/codeblech/jsjiit.git
cd jsjiit
Installing Dependencies
The project uses npm to manage development dependencies. Install them by running:
npm install
This command installs the dependencies defined in package.json57-60:
esbuild@0.24.0- Build system for bundling ES modulesjsdoc@^4.0.4- Documentation generation tool
The prepare script defined in package.json16 automatically runs npm run build after dependency installation, creating the initial dist/ directory with bundled artifacts.
Project Structure for Development
Understanding the repository structure is essential for effective development:

Key Development Files:
src/- All library source code that gets bundled and publishedtest.html- Interactive test page for manual validationrun_server- Python script for local HTTPS serverbuild.mjs- Build script using esbuild
Running the Local HTTPS Development Server
The JIIT WebPortal API requires HTTPS for security features including Secure Context APIs. The run_server script provides a local HTTPS server for testing.
Starting the Development Server
Execute the Python script from the repository root:
./run_server
Or if the script is not executable:
python run_server
Server Initialization Process

The server performs these operations (from run_server11-23):
- Generates self-signed SSL certificates using OpenSSL
- Creates
cert.pemandkey.pemfiles in the current directory - Starts an HTTPS server on
localhost:8000 - Serves all files from the current directory
Certificate Warning: Browsers will display a security warning for self-signed certificates. This is expected. Accept the warning to proceed with local testing.
Using test.html for Local Testing
The test.html file provides an interactive interface for testing library functionality during development.
Structure of test.html
The test file contains:
| Component | Location | Purpose |
|---|---|---|
| Login Form | test.html11-15 | Username and password input fields |
| Submit Button | test.html15 | Triggers main() function |
| Import Statement | test.html20 | Imports from local src/index.js |
| Test Function | test.html21-88 | Contains test scenarios |
Local Development Import Configuration
The test file imports directly from source code during development:
// Local development (default)
import { WebPortal, LoginError } from "./src/index.js"
// CDN testing (commented out)
// import { WebPortal, LoginError } from "https://cdn.jsdelivr.net/npm/jsjiit@0.0.17/dist/jsjiit.esm.js";
This configuration in test.html18-20 allows testing changes immediately without rebuilding the bundle.
Example Test Workflow

Testing Different API Methods
The test.html file includes commented examples for testing various API methods. Uncomment sections in test.html36-86 to test specific functionality:
- Attendance: Lines 36-42
- Daily Attendance: Lines 44-55
- Registrations: Lines 57-60
- Exams: Lines 62-69
- Grades: Lines 72-86
Development Workflow
Standard Development Cycle

Key npm Scripts
The package.json12-16 file defines these development scripts:
| Script | Command | Purpose |
|---|---|---|
npm run build |
node build.mjs |
Bundles source code using esbuild |
npm run docs |
jsdoc -c jsdoc.conf.json --verbose |
Generates API documentation |
npm run prepare |
npm run build |
Automatically runs on npm install |
Building During Development
To validate that your changes will build correctly:
npm run build
This executes build.mjs which:
- Uses esbuild to bundle
src/index.js - Generates
dist/jsjiit.esm.js(development bundle) - Generates
dist/jsjiit.min.esm.js(production bundle) - Creates source maps for debugging
File Modification and Hot Reloading
Files to Edit
Development typically involves modifying these files in src/:

No Hot Reload
The development server does not support hot module reloading. After editing source files:
- Save your changes
- Manually refresh the browser (F5 or Ctrl+R)
- Re-enter test credentials if testing requires authentication
Certificate Management
Generated Certificate Files
The run_server script generates two certificate files:
| File | Purpose | Validity |
|---|---|---|
cert.pem |
SSL certificate | 365 days |
key.pem |
Private key | 365 days |
These files are created in the repository root and are excluded from version control by .gitignore.
Certificate Regeneration
Certificates are regenerated each time run_server executes. The generation command from run_server12:
openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj /CN=mylocalhost
Security Note: These certificates are for local development only and should never be used in production.
Environment Variables and Configuration
The jsjiit library does not require environment variables for local development. All configuration is embedded in source code or derived from the JIIT WebPortal API.
Configuration Files
| File | Purpose | Modification Needed? |
|---|---|---|
package.json |
Project metadata, scripts, dependencies | Rarely |
jsdoc.conf.json |
Documentation generation config | No |
.gitignore |
Version control exclusions | No |
.npmignore |
npm package exclusions | No |
Common Development Tasks
Testing a Specific API Method
- Start the development server
- Open
test.htmlin your browser - Locate the relevant test code in test.html21-88
- Uncomment the section you want to test
- Enter credentials and click Submit
- Check browser console for results
Adding a New Source File
- Create the new file in
src/ - Add exports to
src/index.js - Refresh
test.htmlto test the new functionality - Run
npm run buildto verify the bundle includes your changes
Debugging with Source Maps
When using the built bundles, source maps enable debugging:
- Build with
npm run build - Import from
dist/jsjiit.esm.jsinstead ofsrc/index.jsin test.html - Browser developer tools will map to original source files
Troubleshooting Common Issues
HTTPS Certificate Errors
Problem: Browser refuses to load test.html due to certificate warning.
Solution:
- Click "Advanced" in the browser warning
- Select "Proceed to localhost (unsafe)"
- This is safe for local development
Module Import Errors
Problem: Browser console shows "Failed to resolve module specifier".
Solution:
- Verify the development server is running
- Check that import path in
test.htmlis"./src/index.js" - Ensure file paths use forward slashes, not backslashes
CORS Errors with JIIT Portal
Problem: CORS errors when calling JIIT WebPortal APIs.
Solution:
- CORS is expected and handled by the library
- The library uses appropriate headers and encryption
- Ensure you're testing with HTTPS, not HTTP
Build Failures
Problem: npm run build fails with errors.
Solution:
- Verify Node.js version is 18.x or higher
- Delete
node_modules/andpackage-lock.json - Run
npm installagain - Check for syntax errors in source files
Next Steps
After setting up your local development environment:
- Testing: See Testing and Validation for comprehensive testing strategies
- Building: See Build and Release Process for creating distribution artifacts
- Architecture: See System Architecture Overview to understand the codebase structure
- API Reference: See API Reference for detailed documentation of all methods