Skip to content

Commit e4b08cc

Browse files
authored
27 application report (#33)
* test laravel cloud * refactor: 1NF to 3 NF * refactor: test case * update readme * feat: update readme and license * feat: update on github workflow * feat: fix trigger on sqlite database testing * feat: fix trigger on sqlite database testing * feat: remove update database * feat: github workflow update * feat: github workflow update * feat: github workflow update * feat: github workflow update * feat: github workflow update
1 parent acd0dab commit e4b08cc

194 files changed

Lines changed: 11139 additions & 3054 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ DB_PORT=3306
1515
DB_DATABASE=
1616
DB_USERNAME=root
1717
DB_PASSWORD=
18+
DATABASE_URL=
1819

1920
BROADCAST_DRIVER=log
2021
CACHE_DRIVER=file

.env.testing

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
APP_NAME=Dpos
2+
APP_ENV=local
3+
APP_KEY=base64:nfghI37KMmoF9uQLoJklvbFU16RSoJUIC8+H3AUzYZI=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
APP_SECRET="Doglex"
7+
APP_SUBS="OFF"
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
NIGHTWATCH_TOKEN=
11+
LOG_CHANNEL=nightwatch
12+
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
13+
14+
DB_CONNECTION=sqlite
15+
# DB_HOST=127.0.0.1
16+
# DB_PORT=3306
17+
DB_DATABASE=
18+
DATABASE_URL="/database/database.sqlite"
19+
DB_FOREIGN_KEYS="true"
20+
21+
BROADCAST_DRIVER=log
22+
CACHE_DRIVER=array
23+
FILESYSTEM_DISK=local
24+
QUEUE_CONNECTION=sync
25+
SESSION_DRIVER=array
26+
SESSION_LIFETIME=240
27+
28+
MEMCACHED_HOST=127.0.0.1
29+
30+
REDIS_HOST=127.0.0.1
31+
REDIS_USERNAME=
32+
REDIS_PASSWORD=
33+
REDIS_PREFIX=
34+
REDIS_DB=
35+
REDIS_PORT=
36+
REDIS_TTL=
37+
38+
MAIL_MAILER=smtp
39+
MAIL_HOST=mailpit
40+
MAIL_PORT=1025
41+
MAIL_USERNAME=null
42+
MAIL_PASSWORD=null
43+
MAIL_ENCRYPTION=null
44+
MAIL_FROM_ADDRESS="hello@example.com"
45+
MAIL_FROM_NAME="${APP_NAME}"
46+
47+
AWS_ACCESS_KEY_ID=
48+
AWS_SECRET_ACCESS_KEY=
49+
AWS_DEFAULT_REGION=us-east-1
50+
AWS_BUCKET=
51+
AWS_USE_PATH_STYLE_ENDPOINT=false
52+
53+
PUSHER_APP_ID=
54+
PUSHER_APP_KEY=
55+
PUSHER_APP_SECRET=
56+
PUSHER_HOST=
57+
PUSHER_PORT=443
58+
PUSHER_SCHEME=https
59+
PUSHER_APP_CLUSTER=mt1
60+
61+
VITE_APP_NAME="${APP_NAME}"
62+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
63+
VITE_PUSHER_HOST="${PUSHER_HOST}"
64+
VITE_PUSHER_PORT="${PUSHER_PORT}"
65+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
66+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.github/workflows/laravel-local.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ on:
88
jobs:
99
laravel-local-test:
1010
runs-on: self-hosted
11-
12-
env:
13-
DB_CONNECTION: mysql
14-
DB_HOST: 127.0.0.1
15-
DB_PORT: 3306
16-
DB_DATABASE: laravel_pos
17-
DB_USERNAME: root
18-
DB_PASSWORD: Dbmaman17
19-
11+
defaults:
12+
run:
13+
working-directory: /srv/http
14+
if: success()
2015
steps:
2116
- name: 🧾 Checkout code
22-
uses: actions/checkout@v3
17+
run: |
18+
cd /srv/http
19+
git fetch --all
20+
git pull
2321
2422
- name: 🧰 Install PHP dependencies
25-
run: composer install --no-interaction --prefer-dist
23+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
24+
25+
# - name: ⚙️ Copy .env.testing
26+
# run: cp .env.example .env
2627

27-
- name: ⚙️ Copy .env
28-
run: cp .env.example .env
28+
# - name: 🔐 Generate app key
29+
# run: php artisan key:generate
2930

30-
- name: 🔐 Generate app key
31-
run: php artisan key:generate
31+
# - name: Directory Permissions
32+
# run: chmod -R 777 storage bootstrap/cache
3233

3334
# - name: 🗄️ Run database migrations
34-
# run: php artisan migrate --force
35+
# run: php artisan migrate::fresh
3536
# - name: ✅ Run Laravel tests
36-
# run: php artisan test
37+
# run: php artisan test

API_AUTH_DOCUMENTATION.md

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# API Authentication Documentation
2+
3+
This document describes the API authentication endpoints using Laravel Sanctum.
4+
5+
## Base URL
6+
All API endpoints are prefixed with `/api`
7+
8+
## Authentication Flow
9+
10+
### 1. Login
11+
**POST** `/api/login`
12+
13+
Request body:
14+
```json
15+
{
16+
"username": "user@example.com",
17+
"password": "password123"
18+
}
19+
```
20+
21+
Response:
22+
```json
23+
{
24+
"message": "Login successful",
25+
"token": "1|abc123...",
26+
"user": {
27+
"user": {
28+
"id": 1,
29+
"name": "John Doe",
30+
"username": "johndoe",
31+
"email": "user@example.com"
32+
},
33+
"role": {
34+
"id": 1,
35+
"name": "Manager"
36+
},
37+
"user_id": 1,
38+
"company": {
39+
"id": 1,
40+
"name": "Company Name",
41+
"address": {
42+
"place": "Building",
43+
"address": "Street Address",
44+
"city": "City",
45+
"province": "Province",
46+
"zip_code": "12345"
47+
}
48+
}
49+
},
50+
"token_type": "Bearer"
51+
}
52+
```
53+
54+
### 2. Using the Token
55+
Include the token in the Authorization header for all protected endpoints:
56+
```
57+
Authorization: Bearer 1|abc123...
58+
```
59+
60+
## Protected Endpoints
61+
62+
### Get Current User
63+
**GET** `/api/me`
64+
65+
Returns the current authenticated user's information.
66+
67+
### Logout
68+
**POST** `/api/logout`
69+
70+
Revokes the current token.
71+
72+
### Logout All Devices
73+
**POST** `/api/logout-all`
74+
75+
Revokes all tokens for the current user.
76+
77+
### Select Company
78+
**POST** `/api/select-company`
79+
80+
Request body:
81+
```json
82+
{
83+
"company_id": 1
84+
}
85+
```
86+
87+
### Login As Another User
88+
**POST** `/api/login-as/{user_id}`
89+
90+
Request body:
91+
```json
92+
{
93+
"company_id": 1
94+
}
95+
```
96+
97+
Returns a new token for the target user.
98+
99+
### Change Password
100+
**POST** `/api/change-password`
101+
102+
Request body:
103+
```json
104+
{
105+
"current_password": "oldpassword",
106+
"new_password": "newpassword123",
107+
"confirm_password": "newpassword123"
108+
}
109+
```
110+
111+
### Activate Access Pin
112+
**POST** `/api/activate-access-pin`
113+
114+
Request body:
115+
```json
116+
{
117+
"current_access_pin": "123456",
118+
"access_pin": "654321",
119+
"confirm_access_pin": "654321"
120+
}
121+
```
122+
123+
### Unlock Screen
124+
**POST** `/api/unlock-screen`
125+
126+
Request body:
127+
```json
128+
{
129+
"access_pin": "123456"
130+
}
131+
```
132+
133+
### Get Customer Companies
134+
**GET** `/api/customer-companies`
135+
136+
Returns list of companies associated with the current user.
137+
138+
## Public Endpoints
139+
140+
### Register
141+
**POST** `/api/register`
142+
143+
Request body:
144+
```json
145+
{
146+
"user": {
147+
"name": "John Doe",
148+
"username": "johndoe",
149+
"email": "user@example.com",
150+
"phone_number": "08123456789",
151+
"password": "password123"
152+
},
153+
"company": {
154+
"name": "Company Name",
155+
"email": "company@example.com",
156+
"phone_number": "08123456789"
157+
},
158+
"address": {
159+
"place": "Building",
160+
"address": "Street Address",
161+
"city": "City",
162+
"province": "Province",
163+
"zip_code": "12345"
164+
}
165+
}
166+
```
167+
168+
### Check Available User
169+
**GET** `/api/check-available-user`
170+
171+
Query parameters:
172+
- `name`
173+
- `username`
174+
- `email`
175+
- `phone_number`
176+
177+
### Get Company Types
178+
**GET** `/api/company-types`
179+
180+
### Check Company Availability
181+
**GET** `/api/check-company-availability`
182+
183+
Query parameters:
184+
- `name`
185+
- `email`
186+
- `phone_number`
187+
- `bussiness_id`
188+
189+
## Error Responses
190+
191+
All endpoints return appropriate HTTP status codes:
192+
193+
- `200` - Success
194+
- `201` - Created (for registration)
195+
- `400` - Bad Request
196+
- `401` - Unauthorized
197+
- `403` - Forbidden
198+
- `404` - Not Found
199+
- `422` - Validation Error
200+
- `500` - Server Error
201+
202+
Error response format:
203+
```json
204+
{
205+
"message": "Error description",
206+
"errors": {
207+
"field": ["Error message"]
208+
}
209+
}
210+
```
211+
212+
## Rate Limiting
213+
214+
All endpoints are rate limited to 100 requests per minute per IP address.

CaddyFile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
log {
3+
level INFO
4+
}
5+
}
6+
:8000 {
7+
root public/
8+
encode zstd br gzip
9+
@blockPHP {
10+
path_regexp blockphp .*\.php$
11+
}
12+
respond @blockPHP "Forbidden" 403
13+
php_server {
14+
try_files {path} index.php
15+
}
16+
header /assets/* Cache-Control "public, max-age=31536000, immutable"
17+
}

0 commit comments

Comments
 (0)