A Node.js application providing a simple greeting service with a REST API. It includes a server built with Express, greeting logic, and comprehensive test suites (unit, integration, and end-to-end).
- Greeting Functionality: Generates personalized greetings via
src/greeting.js. - REST API Server: Built with Express in
src/server.js, supporting GET and POST endpoints for greetings. - Testing: Full test coverage with Jest:
- Unit tests in
tests/unit/greeting.test.js. - Integration tests in
tests/integration/app.test.js. - End-to-end tests in
tests/e2e/e2e.test.js.
- Unit tests in
- Linting: Configured with ESLint (via
.eslintrc.jsand.eslintignore). - Node.js Version Management: Uses
.nvmrcto specify Node.js v22.19.0.
- Node.js ≥22.19.0 (use
.nvmrcwith nvm:nvm use). - npm (included with Node.js).
- Fork the repository:
- Install dependencies:
npm install
Start the server:
npm start
The server runs on port 3000 (or process.env.PORT). Endpoints:
GET /hello/:name?: Returns a greeting (e.g., "Hello world!" or "Hello world! From [name]").POST /hello: Expectsx-nameheader for the name.
Run tests with Jest:
- All tests:
npm test - Unit tests:
npm test -- tests/unit/ - Integration tests:
npm test -- tests/integration/ - E2E tests:
npm test -- tests/e2e/
Check code quality:
npm run lint
src/greeting.js: Core greeting logic.src/server.js: Express server setup.tests/: Test suites (unit, integration, e2e)..eslintrc.js: ESLint configuration..eslintignore: Files/directories excluded from linting..nvmrc: Node.js version specification.package.json: Project metadata, dependencies, and scripts.
- Runtime: Express (web server), Axios (HTTP client), Supertest (testing utility).
- Dev: ESLint (linting), Jest (testing).
- Fork the repo.
- Create a feature branch.
- Run tests and linting.
- Submit a pull request.