@okam/directus-next 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
## 0.3.0 (2024-12-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🚀 Features
|
|
5
|
+
|
|
6
|
+
- **directus-next:** not a real change but need to trigger new version ([57f2a54](https://github.com/OKAMca/stack/commit/57f2a54))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- David Paquet Pitts
|
|
12
|
+
|
|
13
|
+
## 0.1.2 (2024-10-04)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 🩹 Fixes
|
|
17
|
+
|
|
18
|
+
- **directus-next:** make package public ([#172](https://github.com/OKAMca/stack/pull/172))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- yanmorinokamca @yanmorinokamca
|
|
24
|
+
|
|
25
|
+
## 0.2.0 (2024-09-24)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### 🚀 Features
|
|
29
|
+
|
|
30
|
+
- **directus-next:** directus based routing ([196ab1e](https://github.com/OKAMca/stack/commit/196ab1e))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### 🩹 Fixes
|
|
34
|
+
|
|
35
|
+
- **directus-next:** make package public ([#172](https://github.com/OKAMca/stack/pull/172))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### ❤️ Thank You
|
|
39
|
+
|
|
40
|
+
- David Paquet Pitts
|
|
41
|
+
- yanmorinokamca @yanmorinokamca
|
|
42
|
+
|
|
43
|
+
## 0.1.1 (2024-08-13)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### 🩹 Fixes
|
|
47
|
+
|
|
48
|
+
- **directus-next:** update build dependencies, exclude next ([#179](https://github.com/OKAMca/stack/pull/179))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### ❤️ Thank You
|
|
52
|
+
|
|
53
|
+
- mykimd
|
|
54
|
+
- poclerson
|
|
55
|
+
- yanmorinokamca @yanmorinokamca
|
|
56
|
+
|
|
57
|
+
## 0.1.0 (2024-08-01)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### 🚀 Features
|
|
61
|
+
|
|
62
|
+
- **directus-next:** adding draft route code ([64c665d](https://github.com/OKAMca/stack/commit/64c665d))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### 🩹 Fixes
|
|
66
|
+
|
|
67
|
+
- **publish:** add building packages step to workflow ([c9ce442](https://github.com/OKAMca/stack/commit/c9ce442))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### ❤️ Thank You
|
|
71
|
+
|
|
72
|
+
- Jérôme Trottier
|
|
73
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
74
|
+
- Pierre-Olivier Clerson @poclerson
|
|
75
|
+
- Yan Morin
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# directus-next
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build directus-next` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test directus-next` to execute the unit tests via [Jest](https://jestjs.io).
|
|
12
|
+
|
|
13
|
+
## Draft
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
In your next folder app/api/ directory:
|
|
17
|
+
* Create directory draft/
|
|
18
|
+
* Create file draft/route.ts
|
|
19
|
+
* In route.ts, import handleDraftRoute,
|
|
20
|
+
* Define GET function.
|
|
21
|
+
|
|
22
|
+
### Example
|
|
23
|
+
```
|
|
24
|
+
import { handleDraftRoute } from '@okam/directus-next'
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
export async function GET(request: Request) {
|
|
28
|
+
return handleDraftRoute({
|
|
29
|
+
url: request.url,
|
|
30
|
+
getDirectusLanguage: () => 'en-CA' // default language to show
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Environment
|
|
36
|
+
Set the secret in your .env and your directus application (preview_secret field).
|
|
37
|
+
|
|
38
|
+
.env
|
|
39
|
+
```
|
|
40
|
+
NEXT_API_DRAFT_SECRET=123
|
|
41
|
+
```
|
|
42
|
+
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const headers = require("next/headers");
|
|
4
4
|
const navigation = require("next/navigation");
|
|
5
|
-
const
|
|
5
|
+
const radashi = require("radashi");
|
|
6
6
|
const response = require("../response.js");
|
|
7
7
|
const env = require("./env.js");
|
|
8
8
|
function parseParams(url) {
|
|
@@ -81,7 +81,7 @@ function getPathFromRoute(routeUrl, url, index = 0) {
|
|
|
81
81
|
map[key] = param || "";
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
-
return
|
|
84
|
+
return radashi.template(routeUrl, map);
|
|
85
85
|
}
|
|
86
86
|
function handleDraftRoute({
|
|
87
87
|
url,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { draftMode } from "next/headers";
|
|
2
2
|
import { redirect } from "next/navigation";
|
|
3
|
-
import { template } from "
|
|
3
|
+
import { template } from "radashi";
|
|
4
4
|
import { getJsonErrorResponse } from "../response.mjs";
|
|
5
5
|
import { getDraftSecretDefault } from "./env.mjs";
|
|
6
6
|
function parseParams(url) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-next",
|
|
3
3
|
"main": "./index.js",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -18,5 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@okam/logger": "1.1.0",
|
|
24
|
+
"next": "^14.1.1",
|
|
25
|
+
"radashi": "^12.3.0"
|
|
21
26
|
}
|
|
22
27
|
}
|
|
@@ -13,7 +13,7 @@ class Logger {
|
|
|
13
13
|
if (this.env === "production") {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context);
|
|
16
|
+
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
|
|
17
17
|
}
|
|
18
18
|
setLogger(logger2) {
|
|
19
19
|
this.logger = (message, severity, context) => {
|
|
@@ -11,7 +11,7 @@ class Logger {
|
|
|
11
11
|
if (this.env === "production") {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context);
|
|
14
|
+
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
|
|
15
15
|
}
|
|
16
16
|
setLogger(logger2) {
|
|
17
17
|
this.logger = (message, severity, context) => {
|