Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinyq/express_auth-crud-be-test
Simple Express CRUD with Auth App
https://github.com/shinyq/express_auth-crud-be-test
express nodejs typescript
Last synced: 3 days ago
JSON representation
Simple Express CRUD with Auth App
- Host: GitHub
- URL: https://github.com/shinyq/express_auth-crud-be-test
- Owner: ShinyQ
- Created: 2024-05-15T15:39:15.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-19T16:01:19.000Z (7 months ago)
- Last Synced: 2024-12-22T21:14:46.438Z (3 days ago)
- Topics: express, nodejs, typescript
- Language: TypeScript
- Homepage: https://kurniadi-betest.vercel.app/api
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kurniadi - BE Test
## Stack :
```
1. NodeJS
2. ExpressJS
2. MongoDB
3. Redis Server- Web App : vercel
- MongoDB : cloud.mongodb.com
- Redis : aiven.io
```## Installation :
```
1. Copy ".env.example" to make ".env"
2. Fill the config according to your machine
3. npm install
```### Run :
```
npm start
```### Test :
```
npm test
```### Deployment Link:
```
https://kurniadi-betest.vercel.app/api
```### Postman Collection :
```
https://documenter.getpostman.com/view/2703265/2sA3JRaeth#25ea99b8-c46a-4bba-8bc0-390c329056a9
```### Default Credential :
```
username = admin
password = admin
```### API Endpoints
The provided code implements two controllers in the Express framework to handle various API endpoints related to authentication and user management. Below are the details of the available APIs:#### AuthController
1. Login (POST /login), Description: This API is used to authenticate a user with an email and password.```
Request Body:{
"email": "string",
"password": "string"
}Response:
- 200 OK: If authentication is successful, returns user data.
- 400 Bad Request: If the username or password is invalid.
- 401 Unauthorized: If there is another error during the authentication process.
```#### UserController
1. Get Users (GET /users), Description: This API is used to retrieve a list of all users.```
Response:
- 200 OK: Successfully returns the list of users.
- 500 Internal Server Error: If there is a server error when fetching user data.
```2. Get User by Filter (GET /users/filter), Description: This API is used to retrieve a user based on a specific filter.
```
Query Parameters:
- value: The value to filter by.
- filterType: The type of filter (e.g., based on id or username).Response:
- 200 OK: Successfully returns the user data matching the filter.
- 400 Bad Request: If value or filterType is not provided, or if the user is not found.
- 401 Unauthorized: If there is another error during the authentication process (required bearer token).
- 500 Internal Server Error: If there is a server error.
```3. Create User (POST /users), Description: This API is used to create a new user.
```
Request Body: The user data to be created.Response:
- 201 Created: User successfully created.
- 400 Bad Request: If value duplicate or required.
- 500 Internal Server Error: If there is a server error.
```4. Update User (PUT /users/:id), Description: This API is used to update user data based on the user ID.
```
Request Body: The updated user data.Response:
- 200 OK: Successfully updates the user data.
- 400 Bad Request: If value duplicate or required.
- 500 Internal Server Error: If there is a server error.
```5. Delete User (DELETE /users/:id),
Description: This API is used to delete a user based on the user ID.
```
Response:
- 200 OK: Successfully deletes the user.
- 500 Internal Server Error: If there is a server error.
```