Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7bc8115

Browse files
committed
docs: add README.md
1 parent 3bbf7b4 commit 7bc8115

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# 🐾 Felisnovel API
2+
3+
> **A robust, scalable API built with [AdonisJS](https://adonisjs.com/) and TypeScript, designed for modern web applications.**
4+
5+
---
6+
7+
## ✨ Features
8+
9+
- **AdonisJS 5**: Modern Node.js MVC framework with TypeScript support.
10+
- **Comprehensive CRUD Factory**: Instantly generate models, controllers, migrations, factories, validators, and functional tests for any entity.
11+
- **Extensive Functional Testing**: Uses [@japa/runner](https://github.com/japa-js/japa) for end-to-end and API tests.
12+
- **Modular Structure**: Clean separation of concerns for scalability and maintainability.
13+
14+
---
15+
16+
## 🚀 Getting Started
17+
18+
1. **Install dependencies**
19+
```bash
20+
yarn install
21+
```
22+
23+
2. **Configure environment**
24+
- Copy `.env.example` to `.env` and fill in the required variables.
25+
- See `env.ts` for all required environment variables.
26+
27+
3. **Run migrations & seeders**
28+
```bash
29+
yarn mf # Fresh migration
30+
yarn mfs # Fresh migration with seeders
31+
```
32+
33+
4. **Start the development server**
34+
```bash
35+
yarn dev
36+
```
37+
38+
---
39+
40+
## 🏭 CRUD Factory
41+
42+
Easily scaffold a full CRUD flow for any entity using the custom Ace command:
43+
44+
```bash
45+
node ace crud <EntityName>
46+
```
47+
48+
- Generates:
49+
- Model (`app/Models/`)
50+
- Controller (`app/Controllers/Http/`)
51+
- Migration (`database/migrations/`)
52+
- Factory (`database/factories/`)
53+
- Validator (`app/Validators/`)
54+
- Functional Test (`tests/functional/`)
55+
56+
**Example:**
57+
```bash
58+
node ace crud Country
59+
node ace crud Country --interactive
60+
```
61+
62+
---
63+
64+
## 🧪 Testing
65+
66+
All tests are written with [@japa/runner](https://github.com/japa-js/japa) and live in `tests/functional/`.
67+
68+
### How to run tests
69+
70+
```bash
71+
yarn test
72+
# or
73+
node ace test
74+
```
75+
76+
### Test Philosophy
77+
78+
- **Functional Coverage:** Every CRUD endpoint, authentication flow, and business rule is covered by functional tests.
79+
- **Factories:** Test data is generated using AdonisJS factories for realistic and isolated scenarios.
80+
- **Role-based Testing:** Many tests check both admin and regular user permissions, ensuring robust access control.
81+
- **Setup & Teardown:** Each test group uses a `cleanAll` setup to ensure a clean database state.
82+
- **Assertions:** Tests assert HTTP status codes, response bodies, and side effects (like DB changes or emails sent).
83+
84+
### Test Structure
85+
86+
- **Grouped by Resource:** Each `.spec.ts` file targets a specific resource (e.g., `users`, `novels`, `contacts`).
87+
- **Example Test:**
88+
```ts
89+
test('create a country', async ({ client }) => {
90+
const admin = await UserFactory.apply('admin').create()
91+
const data = { name: 'Turkey', key: 'TR' }
92+
const response = await client.post('/countries').loginAs(admin).form(data)
93+
response.assertStatus(200)
94+
response.assertBodyContains(data)
95+
})
96+
```
97+
- **Plugins & Reporters:**
98+
- Uses `@japa/preset-adonis` for assertions, API client, and failed test reruns.
99+
- Spec reporter for detailed terminal output.
100+
- **Automated Setup:**
101+
- Migrations and seeders run automatically before tests.
102+
- HTTP server starts for functional suites.
103+
104+
### Advanced
105+
106+
- **Test utilities**: Common helpers (like `cleanAll`) are in `tests/utils/`.
107+
- **Email and notification flows** are tested using AdonisJS mail fakes and notification assertions.
108+
- **Reports and analytics endpoints** are covered with realistic data and assertions.
109+
110+
---
111+
112+
## 🛠️ Example Ace Commands
113+
114+
- `node ace crud <EntityName>` – Scaffold full CRUD for an entity
115+
- `node ace test` – Run all tests
116+
- `node ace migration:run` – Run migrations
117+
- `node ace db:seed` – Seed the database
118+
119+
See all available commands:
120+
```bash
121+
node ace list
122+
```
123+
124+
---
125+
126+
## 📄 License
127+
128+
MIT

0 commit comments

Comments
 (0)