Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/habidbesp/rest-api-node-typescript-server
This project is a simple yet complete RESTful API built using Node.js, TypeScript, and PostgreSQL. It simulates an electronic product database for a fictional store, providing a single route for creating products. The API is designed with scalability in mind, includes testing with Jest and Supertest, and is fully documented using Swagger.
https://github.com/habidbesp/rest-api-node-typescript-server
dotenv express express-validator jest-tests nodejs postgresql render restful-api sequelize-orm supertest swagger swagger-ui typescript
Last synced: 3 days ago
JSON representation
This project is a simple yet complete RESTful API built using Node.js, TypeScript, and PostgreSQL. It simulates an electronic product database for a fictional store, providing a single route for creating products. The API is designed with scalability in mind, includes testing with Jest and Supertest, and is fully documented using Swagger.
- Host: GitHub
- URL: https://github.com/habidbesp/rest-api-node-typescript-server
- Owner: habidbesp
- Created: 2024-11-01T12:57:45.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-08T18:50:18.000Z (15 days ago)
- Last Synced: 2024-12-08T19:25:41.485Z (15 days ago)
- Topics: dotenv, express, express-validator, jest-tests, nodejs, postgresql, render, restful-api, sequelize-orm, supertest, swagger, swagger-ui, typescript
- Language: TypeScript
- Homepage: https://rest-api-node-typescript-ke5s.onrender.com/docs/
- Size: 120 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# REST API with Node.js, TypeScript & PostgreSQL
This project is a simple yet complete RESTful API built using **Node.js**, **TypeScript**, and **PostgreSQL**. It simulates an electronic product database for a fictional store, providing a single route for creating products. The API is designed with scalability in mind, includes testing with **Jest** and **Supertest**, and is fully documented using **Swagger**.
## Project Links
- [Live API with Swagger Documentation](https://rest-api-node-typescript-ke5s.onrender.com/docs)
- [Frontend Demo](https://electronic-store-rho.vercel.app)
- [Frontend Repository](https://github.com/habidbesp/Electronic-Products)## Features
- **Express.js** server built with TypeScript.
- **PostgreSQL** as the database for storing electronic products.
- API endpoints to **create products** in the database.
- **Swagger** documentation for easy API exploration.
- **Jest** and **Supertest** tests for API endpoint validation.
- Deployed and accessible via **Render**.### Example Endpoints:
- GET /api/products: Retrieve all products in the store.
- POST /api/products: Create a new product in the store.
- PUT /api/products/:id: Update a product by its ID.
- PATCH /api/products/:id: Update de property `"availability"`.
- DELETE /api/products/:id: Delete a product by its ID.Visit the Swagger UI to explore and test all the endpoints interactively.
## Installation (Optional)
- Node.js (>=16.x)
- PostgreSQL### Steps
1. Clone the repository:
```bash
git clone https://github.com/habidbesp/rest-api-node-typescript-server.gitcd rest-api-node-typescript-server
```2. Install dependencies:
```bash
npm install
```3. Create a `.env` file in the root directory with the following variable (adjust as needed for your environment):
```env
DATABASE_URL=your_postgresql_database_url
```4. Run the development server:
```bash
npm run dev
```This will start the server with Nodemon, and the API will be available at http://localhost:4000.
## API Documentation
- The API is fully documented using `Swagger`. You can access the documentation by navigating to:
```bash
http://localhost:4000/docs
```This will open the Swagger UI, where you can explore the available endpoints.
## Testing
To run tests with Jest and Supertest:
```bash
npm run test
```To run tests with coverage:
```bash
npm run test:coverage
```This will execute the tests and provide a detailed coverage report.
## Technologies Used
- **Node.js** and Express for the server.
- **TypeScript** for type safety and development efficiency.
- **PostgreSQL** as the database.
- **Sequelize ORM** for interacting with the database.
- **Swagger** UI and Swagger JSDoc for API documentation.
- **Jest** and **Supertest** for testing.
- **dotenv** for environment variable management.## Future Plans
A frontend application for this API is currently in development using React and TypeScript. The frontend will provide a user-friendly interface to interact with the product data and enhance the functionality of this server. Stay tuned for updates!
## License
This project is licensed under the ISC License