Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ribborges/api-with-auth
https://github.com/ribborges/api-with-auth
api authentication express mongodb nodejs typescript
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ribborges/api-with-auth
- Owner: ribborges
- License: mpl-2.0
- Created: 2024-08-01T02:28:13.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-15T03:55:20.000Z (5 months ago)
- Last Synced: 2024-11-05T12:24:17.593Z (2 months ago)
- Topics: api, authentication, express, mongodb, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST API with Authentication
This project is a REST API built with TypeScript and Express. It includes authentication features to secure the endpoints.
## Features
- User authentication (login, registration)
- Protected routes
- CRUD operations for resources
- Error handling## Prerequisites
- Node.js
- npm## Installation
1. Clone the repository:
```sh
git clone https://github.com/ribborges/api-with-auth
```
2. Navigate to the project directory:
```sh
cd api-with-auth
```
3. Install dependencies:
```sh
npm install
```## ENV variables
```sh
DB_URI=your_mongodb_uri
SECRET=secret_for_password_crypto
```## Running the Project
1. Start the development server:
```sh
npm run dev
```## Using the API
### Authentication
- **Register**
```sh
POST /auth/register
```***Body***
```json
{
"email": "[email protected]",
"password": "12345678",
"username": "example"
}
```- **Login**
```sh
POST /auth/login
```***Body***
```json
{
"username": "example",
"password": "12345678"
}
```### User management
- **Get all users (Need authentication)**
```sh
GET /users
```- **Delete user (Need authentication and authorization)**
```sh
DELETE /users/:id
```- **Update user (Need authentication and authorization)**
```sh
PUT /users/:id
```***Body***
```json
{
"username": "new_username"
}
```