Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,45 @@ Swagger Docs: <https://cms.cow.fi/swagger.html>

# 👨‍💻 Develop

Some requiremets are:
Some requirements are:

- At least Node v16 (use a LTS version)
- Node v18 or v20 (use an LTS version)
- Yarn
- PostgreSQL (optional), for local dev is easier to use sqlite3 (the default). Alternatively you can use PostgreSQL

## Run locally using sqlite3

The CMS relies on a database. The simplest is to use `Sqlite` for development.
The CMS relies on a database. The simplest is to use **Sqlite** for development (it will be created automatically at `data/sqlite.db` when you start the app).

You actually don't need to do anything for this! If you run the project with `yarn dev`, it will automatically create a sqlite database in `data/sqlite.db`
**Steps:**

```
yarn dev
```
1. **Build the project** (required before running):

Then visit:
```bash
yarn build
```

- **Admin**: <http://localhost:1337/admin>
2. **Create a `.env` file** and set at least `APP_KEYS` (required for the app to start):

On its basic setup, you don't need to add any configuration parameter, however you might want to do so. You can do this by creating a `.env` file.
```bash
cp .env.example .env
```

```bash
# Create an ENV file from the example
cp .env.example .env
```
Edit `.env` and set `APP_KEYS` to a comma-separated list of secret keys, for example:

```
APP_KEYS="mySecretKey1,mySecretKey2"
```

You can leave other values as in the example for local dev, or adjust them as needed (see [Strapi environment config](https://docs.strapi.io/dev-docs/configurations/environment)).

3. **Start the dev server:**

```bash
yarn dev
```

4. **Visit** <http://localhost:1337/admin> and create your local admin user.

## Dev locally using PostreSQL

Expand Down Expand Up @@ -64,7 +77,7 @@ yarn dev

# 👷‍♀️ Build

Before running the server for the first time, you need to build it:
Before running the server for the first time, you need to build it (see [Run locally using sqlite3](#run-locally-using-sqlite3) for the full setup). To build:

```bash
yarn build
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"uuid": "e47cb3b3-cc8d-4b31-bc86-634b30862787"
},
"engines": {
"node": ">=16.0.0 <=20.x.x",
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
"allowedTypes": [
"images"
]
},
"location": {
"type": "enumeration",
"enum": [
"default",
"speechBubble"
],
"default": "default"
}
}
}
5 changes: 0 additions & 5 deletions src/api/notification/content-types/notification/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
"data": {
"type": "json"
},
"location": {
"type": "enumeration",
"enum": ["default", "speechBubble"],
"default": "default"
},
"notification_template": {
"type": "relation",
"relation": "oneToOne",
Expand Down
11 changes: 6 additions & 5 deletions src/api/notification/services/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const NOTIFICATIONS_LIMIT = 50

const NOTIFICATIONS_POPULATE = {
notification_template: {
fields: ['id', 'title', 'description', 'url', 'push'],
fields: ['id', 'title', 'description', 'url', 'push', 'location'],
populate: {
thumbnail: {
fields: ['url']
}
}
}
}
} as const

const notificationsTemplateFilter = (push: boolean) => ({
$or: [
Expand Down Expand Up @@ -76,7 +76,8 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
dueDate: notification.notification_template.dueDate,
url: notification.notification_template.url,
createdAt: notification.createdAt,
thumbnail: notification.notification_template.thumbnail?.url
thumbnail: notification.notification_template.thumbnail?.url,
location: notification.notification_template?.location ?? 'default'
}))
},
async getPushNotifications() {
Expand All @@ -94,7 +95,7 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
filters: {
notification_template: notificationsTemplateFilter(push),
...(lastConsumedNotificationDate ? {
createdAt: {$gt: lastConsumedNotificationDate}
createdAt: { $gt: lastConsumedNotificationDate }
} : undefined)
},
populate: NOTIFICATIONS_POPULATE
Expand All @@ -113,7 +114,7 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
}
});

export function templateNotification(description: string, data: {[key: string]: string}): string {
export function templateNotification(description: string, data: { [key: string]: string }): string {
let result = description

if (!data) return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2026-02-04T15:36:58.456Z"
"x-generation-date": "2026-02-24T17:14:45.265Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down Expand Up @@ -18332,6 +18332,13 @@
}
}
},
"location": {
"type": "string",
"enum": [
"default",
"speechBubble"
]
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -18486,6 +18493,13 @@
}
],
"example": "string or id"
},
"location": {
"type": "string",
"enum": [
"default",
"speechBubble"
]
}
}
}
Expand Down Expand Up @@ -19182,6 +19196,13 @@
}
}
},
"location": {
"type": "string",
"enum": [
"default",
"speechBubble"
]
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down
5 changes: 5 additions & 0 deletions src/gen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7499,6 +7499,11 @@ export interface components {
push: boolean;
/** Format: date-time */
dueDate?: string;
/**
* @default default
* @enum {string}
*/
location?: "default" | "speechBubble";
thumbnail?: {
data?: {
id?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/import-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
],
"engines": {
"node": ">=16.0.0 <=20.x.x",
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"scripts": {
Expand Down
Loading