This project is a web application using Express.js, PocketBase, and Pug for rendering views. It includes user authentication, session management, and secure routing for a dynamic web experience.
The application uses the following environment variables:
PORT: The port number where the server runs (default is3000).SESSION_SECRET: A secret key for managing session encryption. Use a strong, random string.POCKETHOST_BASE_URL: The base URL of your PocketBase instance.NODE_ENV: node environment (local -> NODE_ENV=development)
Create a .env file in the root of your project with the following structure:
# Server Configuration
PORT=3000
# Session Configuration
SESSION_SECRET=your_super_secret_key
# PocketBase Configuration
POCKETHOST_BASE_URL=https://your-pocketbase-instance.com
Ensure .env is listed in your .gitignore file to avoid committing sensitive information.
The project follows this structure:
/project-root
├── /public # Static assets (CSS, JS, images)
│ ├── /css # Tailwind CSS output
│ ├── /js # Client-side scripts
│ └── ...
├── /views
│ ├── /layouts # Base layouts for Pug views
│ ├── /user # User-specific views (e.g., login)
│ └── ...
├── /routes # API routes
├── /middleware # Middleware logic
├── .env # Environment variables
├── server.js # Main server file
└── README.md # Documentation
-
Ensure you have
nvm(Node Version Manager) installed. Usenvmto manage and apply the correct Node.js version:nvm use
-
Install dependencies:
npm install
-
Start the development server with live reload:
npm start
-
For production, build the CSS and serve:
npm run build:all npm run serve
- Authentication: Login and session management using PocketBase.
- Secure Routes: Middleware-protected endpoints for authorized users.
- Dynamic Views: Server-side rendering with Pug.
- Static Assets: Tailwind CSS for styling, served from the
publicdirectory.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Submit a pull request.
MIT License. See LICENSE file for details.