Po receptu sledećeg Medium članka:
This is a simple TODO application built with Node.js, Express, TypeScript, and SQLite. It provides a RESTful API for managing a list of TODO items.
- CRUD operations for TODO items
- API key authentication
- Interactive API documentation with Swagger
.
├── .cursorules
├── docs
│ ├── architecture.mermaid
│ ├── status.md
│ └── technical.md
├── knexfile.ts
├── package.json
├── src
│ ├── config
│ │ └── swagger.ts
│ ├── db
│ │ ├── index.ts
│ │ └── migrations
│ ├── index.ts
│ ├── middleware
│ │ └── auth.middleware.ts
│ ├── routes
│ │ ├── index.ts
│ │ └── todo.routes.ts
│ └── services
│ └── todo.service.ts
├── tasks
│ └── tasks.md
└── tsconfig.json
- Node.js (v14 or later)
- npm
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install the dependencies:
npm install
-
Set up your environment variables by creating a
.envfile in the root of the project. You can use the.env.examplefile as a template:cp .env.example .env
Then, add your secret API key to the
.envfile:API_KEY=your-secret-api-key
Run the following command to create the todos table in your SQLite database:
npx knex migrate:latest --knexfile knexfile.tsTo start the development server, run:
npm run devThe server will start on http://localhost:3000.
All API endpoints under /api/todos require an API key for authentication. You must provide the key in the X-API-KEY header of your requests.
Interactive API documentation is available through Swagger UI at the following endpoint:
- Swagger Docs: http://localhost:3000/api-docs
Po receptu sledećeg Medium članka:
This is a simple TODO application built with Node.js, Express, TypeScript, and SQLite. It provides a RESTful API for managing a list of TODO items.
- CRUD operations for TODO items
- API key authentication
- Interactive API documentation with Swagger
.
├── .cursorules
├── docs
│ ├── architecture.mermaid
│ ├── status.md
│ └── technical.md
├── knexfile.ts
├── package.json
├── src
│ ├── config
│ │ └── swagger.ts
│ ├── db
│ │ ├── index.ts
│ │ └── migrations
│ ├── index.ts
│ ├── middleware
│ │ └── auth.middleware.ts
│ ├── routes
│ │ ├── index.ts
│ │ └── todo.routes.ts
│ └── services
│ └── todo.service.ts
├── tasks
│ └── tasks.md
└── tsconfig.json
- Node.js (v14 or later)
- npm
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install the dependencies:
npm install
-
Set up your environment variables by creating a
.envfile in the root of the project. You can use the.env.examplefile as a template:cp .env.example .env
Then, add your secret API key to the
.envfile:API_KEY=your-secret-api-key
Run the following command to create the todos table in your SQLite database:
npx knex migrate:latest --knexfile knexfile.tsTo start the development server, run:
npm run devThe server will start on http://localhost:3000.
All API endpoints under /api/todos require an API key for authentication. You must provide the key in the X-API-KEY header of your requests.
Interactive API documentation is available through Swagger UI at the following endpoint:
- Swagger Docs: http://localhost:3000/api-docs
You can use the Swagger interface to explore and test all the available API endpoints.