https://github.com/juniorreisx/backend-user
A backend API built with TypeScript, Express, Sequelize, and Supabase. It supports basic CRUD operations for user management, including authentication with JWT. Designed for real-time data handling and secured routes.
https://github.com/juniorreisx/backend-user
cors express jwt middleware postgresql sequelize supabase typescript
Last synced: 2 months ago
JSON representation
A backend API built with TypeScript, Express, Sequelize, and Supabase. It supports basic CRUD operations for user management, including authentication with JWT. Designed for real-time data handling and secured routes.
- Host: GitHub
- URL: https://github.com/juniorreisx/backend-user
- Owner: JuniorReisx
- Created: 2025-03-07T04:41:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-07T04:49:24.000Z (over 1 year ago)
- Last Synced: 2025-10-04T09:57:48.050Z (9 months ago)
- Topics: cors, express, jwt, middleware, postgresql, sequelize, supabase, typescript
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
## Backend-TS2
This is a backend project built with TypeScript, Express, Sequelize, and Supabase, with basic authentication and user management functionalities. It provides an API to manage users in a Supabase database, with routes for creating, reading, updating, and deleting users.
## Technologies Used
- **Node.js** - JavaScript runtime environment for the backend.
- **TypeScript** - A superset of JavaScript that adds static typing.
- **Express** - A framework for building APIs in Node.js.
- **Sequelize** - An ORM for interacting with the database.
- **Supabase** - Real-time and authentic database (similar to Firebase).
- **JWT** - Authentication based on JSON Web Tokens for security.
## Prerequisites
- Node.js (version 16 or higher)
- npm or yarn
- Supabase account
## Installation
1. Clone the repository:
```bash
git clone https://github.com/YourUsername/backend-ts2.git
```
2. Navigate to the project directory:
```bash
cd backend-ts2
```
3. Install the project dependencies:
```bash
npm install
# or
yarn install
```
4. Create a `.env` file at the root of the project with the following environment variables:
```env
SUPABASE_URL=
SUPABASE_KEY=
JWT_SECRET=
```
## Running the Project
1. To run the project in development mode, use the command:
```bash
npm run dev
# or
yarn dev
```
The server will start at `http://localhost:3000`.
## API Routes
### **POST /users** - Create a new user
Create a new user with `name`, `email`, `age`, `gender`, and `password` information.
**Example request body:**
```json
{
"name": "John Doe",
"email": "john@example.com",
"age": 25,
"gender": "Male",
"password": "password123"
}
```
### **GET /users** - Get all users
Retrieve all users registered in the database.
### **PUT /users/:id** - Update a user
Update the information of a specific user.
**Example request body:**
```json
{
"name": "John Doe Updated",
"email": "john.new@example.com",
"age": 26,
"gender": "Male"
}
```
### **DELETE /users/:id** - Delete a user
Delete the user specified by `id`.
## Authentication
The API uses JWT for authentication. To protect private routes, the JWT token must be sent in the `Authorization` header in the format:
```
Bearer
```
## Scripts
- **dev**: Starts the server in development mode.
```bash
npm run dev
```
- **build**: Compiles TypeScript code to JavaScript.
```bash
npm run build
```
- **start**: Starts the server with the compiled code.
```bash
npm start
```
## Contributing
1. Fork this repository.
2. Create a new branch (`git checkout -b feature-feature-name`).
3. Make your changes.
4. Commit your changes (`git commit -m 'feat: add new feature'`).
5. Push to the branch (`git push origin feature-feature-name`).
6. Create a new pull request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
This README provides the basic structure of your project, the technologies used, how to install, run, and contribute. You can adjust the details as needed depending on how the project evolves.