- PostgreSQL must be installed and running
- Node.js v18+
# Create database
createdb task_api_db
# Login to PostgreSQL (if needed)
psql -U postgresCopy and configure your environment:
cp .env.example .envUpdate .env with your PostgreSQL credentials if different from defaults.
npm install
npm run start:devThe application will:
- Start on
http://localhost:5002 - Auto-create tables using TypeORM synchronization
- GraphQL playground at
http://localhost:5002/graphql
-
Sign Up - Create a new user account
mutation { signUp(input: { email: "user@example.com" password: "password123" firstName: "John" lastName: "Doe" }) { accessToken id email firstName lastName } }
-
Sign In - Get access token
mutation { signIn(input: { email: "user@example.com" password: "password123" }) { accessToken id email firstName lastName } }
-
Use Token - Add to GraphQL headers:
{ "Authorization": "Bearer YOUR_ACCESS_TOKEN" }
query {
getUser(id: "user-uuid") {
id
email
firstName
lastName
isVerified
createdAt
updatedAt
}
}npm run start- Start production servernpm run start:dev- Start in watch modenpm run build- Build for productionnpm run test- Run unit testsnpm run test:e2e- Run e2e tests
- Verify PostgreSQL is running:
psql -U postgres -l - Check
.envcredentials match your PostgreSQL setup - Ensure database
task_api_dbexists
Change PORT in .env to an available port (default: 5002)
The schema.gql file is auto-generated. If missing, rebuild:
npm run start:dev- Runtime: Node.js
- Framework: NestJS
- API: GraphQL (Apollo Server)
- Database: PostgreSQL
- ORM: TypeORM
- Authentication: JWT with Passport
- Language: TypeScript
- Password Hash: bcryptjs
- Validation: class-validator
src/
├── auth/ # Authentication logic
│ ├── auth.service.ts
│ ├── auth.resolver.ts # GraphQL mutations
│ ├── auth.module.ts
│ ├── dto/ # Input/Output types
│ └── strategies/ # Passport JWT strategy
├── users/ # User management
│ ├── users.service.ts
│ ├── users.resolver.ts # GraphQL queries
│ ├── users.module.ts
│ └── entities/ # Database entities
├── config/
│ └── database.config.ts # Database configuration
└── app.module.ts # Main application module
- Start the development server
- Visit
http://localhost:5002/graphql - Test sign-up and sign-in mutations
- Implement additional features as needed
For NestJS documentation, visit: https://docs.nestjs.com For GraphQL Apollo documentation: https://www.apollographql.com/docs/apollo-server/