@arkstack/http 0.16.4 → 0.16.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/http",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "type": "module",
5
5
  "description": "HTTP module for Arkstack, providing framework-agnostic request and response primitives.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/http",
@@ -17,7 +17,8 @@
17
17
  "arkstack"
18
18
  ],
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "stubs"
21
22
  ],
22
23
  "publishConfig": {
23
24
  "access": "public"
@@ -30,11 +31,11 @@
30
31
  "dependencies": {
31
32
  "clear-router": "^2.9.0",
32
33
  "dotenv": "^17.4.2",
33
- "@arkstack/contract": "^0.16.4",
34
- "@arkstack/common": "^0.16.4"
34
+ "@arkstack/contract": "^0.16.6",
35
+ "@arkstack/common": "^0.16.6"
35
36
  },
36
37
  "peerDependencies": {
37
- "arkormx": "^2.10.1",
38
+ "arkormx": "^2.11.2",
38
39
  "kanun": "^1.2.0"
39
40
  },
40
41
  "peerDependenciesMeta": {
@@ -0,0 +1,52 @@
1
+ import type { ResoraConfig } from 'resora'
2
+
3
+ /**
4
+ * Resora configuration, applied per request by the `resora()` middleware and at
5
+ * generation time by `make:resource`.
6
+ *
7
+ * The object is cast to `ResoraConfig` because it also carries arkstack
8
+ * passthrough fields (`localStubsDir` and the controller/model stub names) that
9
+ * resora accepts at runtime but doesn't surface in its narrower config type.
10
+ */
11
+ export default (): ResoraConfig => {
12
+ return {
13
+ preferredCase: 'camel',
14
+ responseStructure: {
15
+ wrap: true,
16
+ rootKey: 'data',
17
+ },
18
+ paginatedExtras: ['meta', 'links'],
19
+ baseUrl: env('APP_URL', 'http://localhost'),
20
+ pageName: 'page',
21
+ paginatedLinks: {
22
+ first: 'first',
23
+ last: 'last',
24
+ prev: 'prev',
25
+ next: 'next',
26
+ },
27
+ paginatedMeta: {
28
+ to: 'to',
29
+ from: 'from',
30
+ links: 'links',
31
+ path: 'path',
32
+ total: 'total',
33
+ per_page: 'per_page',
34
+ last_page: 'last_page',
35
+ current_page: 'current_page',
36
+ },
37
+ cursorMeta: {
38
+ previous: 'previous',
39
+ next: 'next',
40
+ },
41
+ resourcesDir: 'src/app/http/resources',
42
+ localStubsDir: 'node_modules/@arkstack/driver-express/stubs',
43
+ stubs: {
44
+ resource: 'resource.stub',
45
+ collection: 'resource.collection.stub',
46
+ controller: 'controller.stub',
47
+ api: 'controller.api.stub',
48
+ model: 'controller.model.stub',
49
+ apiResource: 'controller.api.resource.stub',
50
+ },
51
+ } as ResoraConfig
52
+ }
@@ -0,0 +1,86 @@
1
+ import { Arkstack } from '@arkstack/contract'
2
+ import { SessionConfig } from '@arkstack/http'
3
+ import { Str } from '@h3ravel/support'
4
+ import { join } from 'node:path'
5
+
6
+ export default (): SessionConfig => {
7
+ return {
8
+ secret: env('SESSION_SECRET', env('APP_KEY', 'change-me')),
9
+
10
+ /**
11
+ * Session Driver
12
+ *
13
+ * The default session driver that is utilized for incoming requests.
14
+ *
15
+ * Supported: "file", "cookie", "database",
16
+ * (WIP: "apc", "memcached", "redis", "dynamodb", "array")
17
+ */
18
+ driver: env('SESSION_DRIVER', 'file'),
19
+
20
+ /**
21
+ * Cookie Name
22
+ *
23
+ * The name of the session cookie that is created by Arkstack.
24
+ */
25
+ cookie: env(
26
+ 'SESSION_COOKIE',
27
+ Str.slug(env('APP_NAME', 'arkstack'), '_') + '_session'
28
+ ),
29
+
30
+ /**
31
+ * Session Time To Live
32
+ *
33
+ * The number of minutes that the session is allowed to remain idle before
34
+ * it expires.
35
+ */
36
+ ttl: env('SESSION_LIFETIME', 60 * 60 * 24 * 7),
37
+
38
+ /**
39
+ * HTTP Only Access
40
+ *
41
+ * Prevent JavaScript from accessing the value of the cookie making it
42
+ * only accessible through the HTTP protocol.
43
+ */
44
+ http_only: true,
45
+
46
+ /**
47
+ * HTTPS Only Access
48
+ *
49
+ * This option ensures that cookies will only be sent back to the server
50
+ * if the browser has a HTTPS connection if set to "true".
51
+ */
52
+ secure: env('NODE_ENV', 'development') === 'production',
53
+
54
+ /**
55
+ * Same-Site Cookies
56
+ *
57
+ * Determines how cookies behave when cross-site requests take
58
+ * place, and can be used to mitigate CSRF attacks.
59
+ * See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
60
+ *
61
+ * Supported: "Lax", "Strict", "None", undefined
62
+ */
63
+ same_site: 'Lax',
64
+
65
+ /**
66
+ * Session Cookie Path
67
+ *
68
+ * Determines the path for which the cookie will be available.
69
+ */
70
+ path: '/',
71
+ /**
72
+ * Datbase Table
73
+ *
74
+ * For the "database" session driver, this will determine the table to
75
+ * be used to store sessions.
76
+ */
77
+ table: env('SESSION_TABLE', 'sessions'),
78
+
79
+ /**
80
+ * Session Directory
81
+ *
82
+ * For the "file" session driver, the session files are placed in this directory.
83
+ */
84
+ directory: env('SESSION_FILE_PATH', join(Arkstack.rootDir(), './storage/framework/sessions')),
85
+ }
86
+ }