-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Directory Structure
Code
viviarentals.com/
βββ .github/
β βββ workflows/
β βββ ci-cd.yml
β βββ code-quality.yml
βββ config/
β βββ auth0.config.ts
β βββ database.config.ts
βββ src/
β βββ middleware/
β β βββ auth0.middleware.ts
β βββ models/
β β βββ property.model.ts
β β βββ listing.model.ts
β βββ routes/
β β βββ properties.api.ts
β βββ database/
β β βββ schema.sql
β β βββ migrations/
β β βββ 001_initial_schema.sql
β βββ index.ts
βββ .env.example
βββ package.json
βββ tsconfig.json
βββ README.md
Complete Implementation Files
- Main Index File
index.ts
// src/index.ts
import express, { Express } from 'express';
import cors from 'cors';
import helmet from 'helmet';
import dotenv from 'dotenv';
2. Complete Auth0 Middleware
auth0.middleware.ts
v2
// src/middleware/auth0.middleware.ts
import { Request, Response, NextFunction } from 'express';
import jwt from 'jsonwebtoken';
import https from 'https';
import jwksClient from 'jwks-rsa';
3. Property Model with Type Definitions
property.model.ts
v2
// src/models/property.model.ts
export interface Address {
street: string;
city: string;
state: string;
4. Listing Model with Grouping/Filtering Logic
listing.model.ts
v2
// src/models/listing.model.ts
import { Property } from './property.model';
export interface LineItem {
propertyAddress: string;
5. Properties API (CRUD Operations)
properties.api.ts
v2
// src/routes/properties.api.ts
import express, { Request, Response } from 'express';
import { Property, PropertyFilter } from '../models/property.model';
import { groupListingsByChannel, advancedFilter, createLineItemGrouping } from '../models/listing.model';
- Auth0 Configuration
auth0.config.ts
v2
// config/auth0.config.ts
export const auth0Config = {
domain: process.env.AUTH0_DOMAIN || '',
clientId: process.env.AUTH0_CLIENT_ID || '',
clientSecret: process.env.AUTH0_CLIENT_SECRET || '',
7. Database Configuration
database.config.ts
// config/database.config.ts
export const databaseConfig = {
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
database: process.env.DB_NAME || 'viviarentals',
8. PostgreSQL Schema
schema.sql
v2
-- src/database/schema.sql
-- Enable UUID extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Properties table
9. GitHub Actions Workflow - CI/CD
ci-cd.yml
v2
.github/workflows/ci-cd.yml
name: CI/CD Pipeline
on:
push:
10. Environment Configuration Template
.env.example
v2
.env.example
Copy to .env and fill with actual values
Node Environment
NODE_ENV=development
PORT=3000
11. Package.json
package.json
v2
{
"name": "viviarentals-property-management",
"version": "1.0.0",
"description": "Property rental management system with Auth0 integration and multi-channel listing support",
"main": "dist/index.js",
"scripts": {
12. TypeScript Configuration
tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
π Implementation Steps
Clone/Navigate to your repository:
bash
cd AP-ILLINOIS-MANAGEMENT-LLC/viviarentals.com
Create all files from the above templates
Install dependencies:
bash
npm install
Set up environment:
bash
cp .env.example .env
Edit .env with your Auth0 credentials
Set up database:
bash
psql -U postgres -f src/database/schema.sql
Start development:
bash
npm run dev
Configure GitHub Secrets:
Go to Settings β Secrets and variables β Actions
Add: SNYK_TOKEN, SONAR_TOKEN, DEPLOY_KEY
Set up branch protection in Settings β Rules