Skip to content

Commit 3e182db

Browse files
authored
Merge pull request #35 from mnfst/openapi
doc: openapi
2 parents 9327f55 + b555f20 commit 3e182db

File tree

7 files changed

+30
-28
lines changed

7 files changed

+30
-28
lines changed

config.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ General environment variables.
2828

2929
Environment variables related to paths.
3030

31-
| Variable | Default | Description |
32-
| ------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------- |
33-
| PUBLIC_FOLDER | `/public` | The public folder to show [static files](https://expressjs.com/en/starter/static-files.html) |
34-
| MANIFEST_HANDLERS_FOLDER | `/manifest/handlers` | The folder to put your handlers functions for [custom endpoints](./endpoints.md) |
35-
| MANIFEST_FILE_PATH | `/manifest/backend.yml` | The relative or absolute path of your Manifest YAML file |
36-
| TOKEN_SECRET_KEY | `-` | The secret key behind the JWT authentication. Required on production, you can [generate one here](https://jwtsecrets.com/). |
31+
| Variable | Default | Description |
32+
| ------------------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
33+
| PUBLIC_FOLDER | `/public` | The public folder to show [static files](https://expressjs.com/en/starter/static-files.html) |
34+
| MANIFEST_HANDLERS_FOLDER | `/handlers` | The folder to put your handlers functions for [custom endpoints](./endpoints.md) |
35+
| MANIFEST_FILE_PATH | `/manifest.yml` | The relative or absolute path of your Manifest YAML file |
36+
| TOKEN_SECRET_KEY | `-` | The secret key behind the JWT authentication. Required on production, you can [generate one here](https://jwtsecrets.com/). |
3737

3838
## Database
3939

@@ -44,7 +44,7 @@ We recommend switching to [PostgreSQL](https://www.postgresql.org/) or [MySQL](h
4444
| Variable | Default | Description | Applies To |
4545
| ------------- | ---------------------- | ------------------------------------------------------------------------- | ------------------ |
4646
| DB_CONNECTION | `sqlite` | Choose `postgres` switching to PostgreSQL or `mysql` for MySQL or MariaDB | All |
47-
| DB_PATH | `/manifest/backend.db` | Path of the database. Your server should have access to this path locally | SQLite |
47+
| DB_PATH | `/.manifest/db.sqlite` | Path of the database. Your server should have access to this path locally | SQLite |
4848
| DB_HOST | `localhost` | Database host | PostgreSQL / MySQL |
4949
| DB_PORT | `5432` | Database port | PostgreSQL / MySQL |
5050
| DB_USERNAME | `postgres` | Database username | PostgreSQL / MySQL |
@@ -62,7 +62,7 @@ Here are examples of `.env` files for different database connections:
6262
6363
DB_CONNECTION=sqlite
6464
65-
DB_PATH=/manifest/backend.db
65+
DB_PATH=/.manifest/db.sqlite
6666
6767
```
6868

crud.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ By default CRUD endpoints are private, only accessible for logged-in **admin** u
2121

2222
## Using the REST API
2323

24-
Manifest exposes a REST API for CRUD operations. The **OpenAPI** documentation is automatically generated on http://localhost:1111/api. Have a look!
24+
Manifest exposes a REST API for CRUD operations. The **OpenAPI** documentation is automatically generated and the UI is available at http://localhost:1111/api. Have a look!
25+
26+
An`openapi.yml` file is also generated along a `types.ts` file in the `./manifest` folder. Those 2 files are an amazing source of context for your **LLM**. If you want to connect a frontend to your Manifest backend, make sure that your **AI coding tool** sees those files to simplify your development.
2527

2628
For CRUD endpoints, this prefix is followed by `collections` for [collections entities](#collections) and `singles` for [single entities](#singles) and by the slug of your entity (you can change it in the [entity params](entities.md#entity-params))
2729

endpoints.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ Custom endpoints in Manifest follow a simple structure where you define:
2121

2222
This is an example of a simple endpoint that returns a "Hello world from my new endpoint !" message when requesting `GET /endpoints/hello-world`.
2323

24-
```yaml title="manifest/backend.yml"
24+
```yaml title="manifest.yml"
2525
endpoints:
2626
helloWorld:
2727
path: /hello-world
2828
method: GET
2929
handler: helloWorld
3030
```
3131
32-
```js title="manifest/handlers/helloWorld.js"
32+
```js title="handlers/helloWorld.js"
3333
module.exports = async (req, res) => {
3434
res.json({ message: 'Hello world from my new endpoint!' })
3535
}
3636
```
3737

3838
Manifest handlers are basically [ExpressJS middlewares](https://expressjs.com/en/guide/using-middleware.html) exposed with the [Manifest SDK](./crud.md#using-the-javascript-sdk) to help you work with your data.
3939

40-
Place the handler file in the `/manifest/handlers` folder. For example, if the handler is `helloWorld`, the file should be `helloWorld.js`.
40+
Place the handler file in the `/handlers` folder. For example, if the handler is `helloWorld`, the file should be `helloWorld.js`.
4141

4242
:::tip
4343

@@ -61,9 +61,9 @@ Each endpoint can be defined in the YAML file with the following values:
6161

6262
The next thing you may want to do is to **read and write data from your app**. This can be done using the Manifest backend SDK that shares the same CRUD and upload functions as the [JS SDK](http://localhost:3000/docs/javascript-sdk) for the front-end.
6363

64-
Take the following example of a `backend.yml` file of a **leaderboard**:
64+
Take the following example of a `manifest.yml` file of a **leaderboard**:
6565

66-
```yaml title="manifest/backend.yml"
66+
```yaml title="manifest.yml"
6767
name: Leaderboard app 🏅
6868

6969
entities:
@@ -80,9 +80,9 @@ endpoints:
8080
handler: increaseScore
8181
```
8282
83-
We can now add the handler in the `/manifest/handlers` folder:
83+
We can now add the handler in the `/handlers` folder:
8484

85-
```js title="manifest/handlers/increaseScore.js"
85+
```js title="/handlers/increaseScore.js"
8686
module.exports = async (req, res, manifest) => {
8787
// Get the requested competitor with the Manifest backend SDK.
8888
const competitor = await manifest

entities.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import TabItem from '@theme/TabItem';
1212

1313
An entity is a model of objects linked to real-world concepts. Creating an entity in manifest generates **CRUD endpoints** that can be used by the [REST API](./crud.md#using-the-rest-api) or the [SDK](./crud.md#using-the-javascript-sdk).
1414

15-
All entities are located in the `backend.yml` file under the **entities** property.
15+
All entities are located in the `manifest.yml` file under the **entities** property.
1616

1717
There are 2 types of entities in Manifest: [Collections](#collections) and [Singles](#singles). **Collections** are multiple instances of similar data, stored as a list. E.g., users, customers, videos, etc. Singles are unique, standalone data that are singular in nature. E.g., home content, about content, settings, logo...
1818

1919
## Collections
2020

2121
Let's see a simple example:
2222

23-
```yaml title="manifest/backend.yml"
23+
```yaml title="manifest.yml"
2424
name: A pet app
2525

2626
entities:
@@ -133,9 +133,9 @@ Properties are the characteristics of your [entities](./entities.md). For exampl
133133

134134
### Syntax
135135

136-
You can add the properties to your entities in the **backend.yml file**
136+
You can add the properties to your entities in the **manifest.yml file**
137137

138-
```yaml title="manifest/backend.yml"
138+
```yaml title="manifest.yml"
139139
name: Blog about cats
140140
entities:
141141
Post 📝:
@@ -246,8 +246,8 @@ Timestamp field (ISO 8601 Format)
246246
```
247247

248248
#### Email
249-
You can create one-to-many relationships or many-to-many relationships. Defining relationships in your entities allows you to load relations when you query them and also filter by relations.
250249

250+
You can create one-to-many relationships or many-to-many relationships. Defining relationships in your entities allows you to load relations when you query them and also filter by relations.
251251

252252
```yaml
253253
- { name: email, type: email }
@@ -349,7 +349,7 @@ You can create **one-to-many** relationships or **many-to-many** relationships.
349349

350350
The following example showcases the possibilities of **Manifest relations**:
351351

352-
```yaml title="manifest/backend.yml"
352+
```yaml title="manifest.yml"
353353
name: Basketball League 🏀
354354
355355
entities:

middlewares.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Here are some examples of middleware use cases:
2020

2121
## Syntax
2222

23-
```yaml title="manifest/backend.yml"
23+
```yaml title="manifest.yml"
2424
entities:
2525
Project 🗂️:
2626
properties:
@@ -33,9 +33,9 @@ entities:
3333
- handler: sendEmail
3434
```
3535
36-
This example triggers the handler located at `/manifest/handlers/setDate.js` before the item is created and stored in the database, and triggers `/manifest/handlers/sendEmail.js` after.
36+
This example triggers the handler located at `/handlers/setDate.js` before the item is created and stored in the database, and triggers `/handlers/sendEmail.js` after.
3737

38-
```js title="manifest/handlers/setDate.js"
38+
```js title="/handlers/setDate.js"
3939
module.exports = async (req, res) => {
4040
console.log('Hello from the handler!')
4141
@@ -52,7 +52,7 @@ You can add **several middlewares** for an event. They will be processed sequent
5252

5353
Manifest passes the [JS SDK](./crud.md#using-the-javascript-sdk) to handler functions as third argument. You can use it to fetch or write data.
5454

55-
```js title="manifest/handlers/patchDocumentNameIfEmpty.js"
55+
```js title="/handlers/patchDocumentNameIfEmpty.js"
5656
module.exports = async (req, res, manifest) => {
5757
// If the 'name' property of the item is empty.
5858
if (!req.body['name']) {

validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can use the built-in **custom validators** to ensure that the data you are r
1212

1313
## Syntax
1414

15-
In your **backend.yml**, you can add a _validation_ object that lists the properties and their validators:
15+
In your **manifest.yml**, you can add a _validation_ object that lists the properties and their validators:
1616

1717
```yaml
1818
entities:

webhooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Webhooks are useful to connect other applications or to trigger a micro-service
1212

1313
## Syntax
1414

15-
```yaml title="manifest/backend.yml"
15+
```yaml title="manifest.yml"
1616
entities:
1717
# You can attach one or several webhooks to each entity event.
1818
Cat 😺:

0 commit comments

Comments
 (0)