https://github.com/benjaminpla/express_sql
This project is a demonstration of a highly scalable web application built using SQL, MariaDB (Docker), MySQL, Express.js with Express Router, Middlewares, TypeScript, and environment variables. Postman is used for testing the API endpoints.
https://github.com/benjaminpla/express_sql
api backend database docker environment-variables express git mariadb middlewares mysql node postman routing sql typescript
Last synced: 3 months ago
JSON representation
This project is a demonstration of a highly scalable web application built using SQL, MariaDB (Docker), MySQL, Express.js with Express Router, Middlewares, TypeScript, and environment variables. Postman is used for testing the API endpoints.
- Host: GitHub
- URL: https://github.com/benjaminpla/express_sql
- Owner: benjaminPla
- Created: 2023-09-14T09:28:33.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-15T18:43:53.000Z (almost 2 years ago)
- Last Synced: 2025-02-06T20:01:04.108Z (5 months ago)
- Topics: api, backend, database, docker, environment-variables, express, git, mariadb, middlewares, mysql, node, postman, routing, sql, typescript
- Language: TypeScript
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API | Express + SQL
## Overview
This project is a demonstration of a highly scalable web application built using SQL, MariaDB (Docker), MySQL, Express.js with Express Router, Middlewares, TypeScript, and environment variables.
Postman is used for testing the API endpoints.## Structure
```
├── README.md
├── api
│ ├── index.ts
│ ├── middlewares
│ │ ├── orders.ts
│ │ └── users.ts
│ ├── models
│ │ ├── Orders.ts
│ │ └── Users.ts
│ ├── routes
│ │ └── index.ts
│ └── utils
│ └── index.ts
├── database
│ ├── config.ts
│ ├── index.ts
│ ├── mock
│ │ ├── orders.sql
│ │ └── users.sql
│ └── tables
│ ├── orders.ts
│ └── users.ts
├── interfaces
│ └── index.ts
├── package-lock.json
├── package.json
└── tsconfig.json
```## Database
This project utilizes both MariaDB (Docker) and MySQL databases. You can set up the databases by following these steps:
1. Start the MariaDB container:
```bash
docker run --name mariadb-container -e MYSQL_ROOT_PASSWORD=yourpassword -d -p 3306:3306 mariadb
```Replace `yourpassword` with your desired root password.
2. Create a MySQL database using your preferred MySQL client and configure the connection in the .env file.
3. Populate the Database (Optional), populate the database with mock data provided in `./database/mock`.
## Configuration
To configure the project, follow these steps:
1. Create a .env file in the project root and add the necessary environment variables:
```env
API_PORT=3000
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
```## Running Locally
To run the project locally, follow these steps:
1. Install project dependencies:
```bash
npm install
```2. Start the development server:
```bash
npm run start
```## Endpoints
This project provides a RESTful API with the following endpoints for managing users and orders:
| Endpoint | Description | HTTP Method |
| ------------- | ----------------------------------------------- | ----------- |
| `/users` | Retrieve a list of all users | GET |
| `/users/:id` | Retrieve a user by their unique ID | GET |
| `/users` | Create a new user | POST |
| `/users/:id` | Update an existing user by their unique ID | PUT |
| `/users/:id` | Delete a user by their unique ID | DELETE |
| `/orders` | Retrieve a list of all orders with user details | GET |
| `/orders/:id` | Retrieve an order by its unique ID | GET |
| `/orders` | Create a new order | POST |
| `/orders/:id` | Update an existing order by its unique ID | PUT |
| `/orders/:id` | Delete an order by its unique ID | DELETE |## Images





