Important: I'm refactoring this project to follow some good practices, tests and some SOLID principles
REST API for managing users, pages, and links with authentication and role-based authorization. Built with TypeScript, Express, Prisma ORM, and PostgreSQL.
- Runtime: Node.js (>= 22)
- Language: TypeScript
- Framework: Express 5
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT + bcrypt
- Testing: Vitest
- Dev Tools: tsx, ESLint
Create a .env file at the project root:
# Database connection
DATABASE_URL="postgresql://user:password@localhost:5432/database"
# JWT Secret (use a strong random string in production)
JWT_SECRET="your-secret-key-here"
# Optional: Server port (defaults to 3001)
PORT=3001
# Optional: Node environment
NODE_ENV=developmentExample for Docker Compose database:
DATABASE_URL="postgresql://linksforall:linksforall@localhost:5432/linksforal-development"
JWT_SECRET="your-secret-key-here"npm installdocker-compose up -dThis starts a PostgreSQL instance on localhost:5432 with:
- Username:
linksforall - Password:
linksforall - Database:
linksforal-development
Create a .env file (see Environment Variables section above)
npx prisma generatenpx prisma migrate devOr use db push for schema prototyping:
npx prisma db pushnpm run prisma:seedThis creates 4 users (1 ADMIN, 3 USER) with pages. All users have password: fakepassword
npm run devThe server runs on http://localhost:3001 by default.
| Script | Description |
|---|---|
npm run dev |
Start development server with hot-reload |
npm run build |
Compile TypeScript to dist/ directory |
npm run lint |
Run ESLint on source files |
npm run lint:fix |
Run ESLint with auto-fix |
npm test |
Run tests once |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Generate test coverage report |
npm run test:ui |
Open Vitest UI for interactive testing |
npm run prisma:seed |
Seed database with fake data |
| Command | Description |
|---|---|
npx prisma studio |
Open Prisma Studio (database GUI) |
npx prisma migrate dev |
Create and apply migrations |
npx prisma migrate deploy |
Apply migrations in production |
npx prisma db push |
Push schema changes (no migration files) |
npx prisma generate |
Generate Prisma Client |
npx prisma db seed |
Run seed script |
The project uses Vitest for testing with coverage support:
# Run all tests
npm test
# Watch mode for TDD
npm run test:watch
# Generate coverage report
npm run test:coverage
# Open interactive UI
npm run test:uiISC