First homework assignment from the Node.js course. A basic HTTP server built with Express, using ES modules, request logging via Pino, and CORS support.
| Package | Purpose |
|---|---|
| Express 5 | HTTP framework |
| cors | Cross-Origin Resource Sharing |
| pino-http | HTTP logging |
| pino-pretty | Log formatting in the console |
| dotenv | Loading environment variables |
| nodemon | Auto-restart server during development |
| ESLint | Static code analysis |
| Prettier | Code formatting |
nodejs-hw/
├── src/
│ └── server.js # Entry point — Express server
├── .env # Environment variables (not committed to git)
├── .editorconfig # Editor settings
├── .gitignore
├── .prettierrc
├── eslint.config.js
└── package.json
git clone https://github.com/DmytroHlushchenko17/nodejs-hw.git
cd nodejs-hw
npm install
Create a .env file in the root directory:
PORT=3000
NODE_ENV=development
Development mode (with auto-restart):
npm run dev
Production mode:
npm start
The server will start at http://localhost:3000
| Method | Route | Description |
|---|---|---|
GET |
/notes |
Get all notes |
GET |
/notes/:noteId |
Get a note by ID |
GET |
/test-error |
Test error handling (500) |
* |
* |
404 — Route not found |
# All notes
curl http://localhost:3000/notes
# Note with ID 5
curl http://localhost:3000/notes/5
# Error test
curl http://localhost:3000/test-error
npm run dev # Start with nodemon (development)
npm start # Start without nodemon (production)
npm run lint # Check code with ESLint
npm run lint:fix # Auto-fix ESLint errors
npm run format # Format code with Prettier
ISC © Dmytro Hlushchenko