@axium/server 0.1.8 → 0.2.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/dist/config.d.ts CHANGED
@@ -51,6 +51,15 @@ export declare const Log: z.ZodObject<{
51
51
  }>;
52
52
  export type Log = z.infer<typeof Log>;
53
53
  export declare const log: Log;
54
+ export declare const Web: z.ZodObject<{
55
+ prefix: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ prefix: string;
58
+ }, {
59
+ prefix: string;
60
+ }>;
61
+ export type Web = z.infer<typeof Web>;
62
+ export declare const web: Web;
54
63
  export declare const Config: z.ZodObject<{
55
64
  auth: z.ZodObject<{
56
65
  credentials: z.ZodOptional<z.ZodBoolean>;
@@ -98,6 +107,13 @@ export declare const Config: z.ZodObject<{
98
107
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
99
108
  console?: boolean | undefined;
100
109
  }>;
110
+ web: z.ZodObject<{
111
+ prefix: z.ZodOptional<z.ZodString>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ prefix?: string | undefined;
114
+ }, {
115
+ prefix?: string | undefined;
116
+ }>;
101
117
  }, "strip", z.ZodTypeAny, {
102
118
  debug: boolean;
103
119
  auth: {
@@ -117,6 +133,9 @@ export declare const Config: z.ZodObject<{
117
133
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
118
134
  console?: boolean | undefined;
119
135
  };
136
+ web: {
137
+ prefix?: string | undefined;
138
+ };
120
139
  }, {
121
140
  debug: boolean;
122
141
  auth: {
@@ -136,6 +155,9 @@ export declare const Config: z.ZodObject<{
136
155
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
137
156
  console?: boolean | undefined;
138
157
  };
158
+ web: {
159
+ prefix?: string | undefined;
160
+ };
139
161
  }>;
140
162
  export declare const File: z.ZodObject<z.objectUtil.extendShape<{
141
163
  auth: z.ZodOptional<z.ZodObject<{
@@ -184,6 +206,13 @@ export declare const File: z.ZodObject<z.objectUtil.extendShape<{
184
206
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
185
207
  console?: boolean | undefined;
186
208
  }>>;
209
+ web: z.ZodOptional<z.ZodObject<{
210
+ prefix: z.ZodOptional<z.ZodOptional<z.ZodString>>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ prefix?: string | undefined;
213
+ }, {
214
+ prefix?: string | undefined;
215
+ }>>;
187
216
  }, {
188
217
  include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
189
218
  }>, "strip", z.ZodTypeAny, {
@@ -205,6 +234,9 @@ export declare const File: z.ZodObject<z.objectUtil.extendShape<{
205
234
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
206
235
  console?: boolean | undefined;
207
236
  } | undefined;
237
+ web?: {
238
+ prefix?: string | undefined;
239
+ } | undefined;
208
240
  include?: string[] | undefined;
209
241
  }, {
210
242
  debug?: boolean | undefined;
@@ -225,6 +257,9 @@ export declare const File: z.ZodObject<z.objectUtil.extendShape<{
225
257
  level?: "debug" | "error" | "warn" | "notice" | "info" | undefined;
226
258
  console?: boolean | undefined;
227
259
  } | undefined;
260
+ web?: {
261
+ prefix?: string | undefined;
262
+ } | undefined;
228
263
  include?: string[] | undefined;
229
264
  }>;
230
265
  export type File = z.infer<typeof File>;
package/dist/config.js CHANGED
@@ -38,11 +38,18 @@ export const log = {
38
38
  level: 'info',
39
39
  console: true,
40
40
  };
41
+ export const Web = z.object({
42
+ prefix: z.string(),
43
+ });
44
+ export const web = {
45
+ prefix: '',
46
+ };
41
47
  export const Config = z.object({
42
48
  auth: Auth.partial(),
43
49
  debug: z.boolean(),
44
50
  db: Database.partial(),
45
51
  log: Log.partial(),
52
+ web: Web.partial(),
46
53
  });
47
54
  // config from file
48
55
  export const File = Config.deepPartial().extend({
@@ -55,6 +62,7 @@ export function get() {
55
62
  db,
56
63
  debug,
57
64
  log,
65
+ web,
58
66
  };
59
67
  }
60
68
  /**
@@ -65,6 +73,7 @@ export function set(config) {
65
73
  debug = config.debug ?? debug;
66
74
  assignWithDefaults(db, config.db ?? {});
67
75
  assignWithDefaults(log, config.log ?? {});
76
+ assignWithDefaults(web, config.web ?? {});
68
77
  logger.detach(output);
69
78
  if (log.console)
70
79
  logger.attach(output, { output: log.level });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/server",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -1,12 +1,13 @@
1
1
  import { redirect } from '@sveltejs/kit';
2
2
  import { adapter } from '../../dist/auth.js';
3
3
  import type { PageServerLoadEvent } from './$types.js';
4
+ import { web } from '../../dist/config.js';
4
5
 
5
6
  export async function load(event: PageServerLoadEvent) {
6
7
  const session = await event.locals.auth();
7
8
 
8
9
  if (!session) redirect(307, '/auth/signin');
9
- if (!session.user.name) redirect(307, 'name');
10
+ if (!session.user.name) redirect(307, web.prefix + '/name');
10
11
 
11
12
  const user = await adapter.getUserByEmail(session.user.email);
12
13
 
@@ -1,9 +1,19 @@
1
1
  <script lang="ts">
2
2
  import { getUserImage } from '@axium/core';
3
+ import { web } from '../../dist/config.js';
3
4
  import Icon from '../lib/Icon.svelte';
4
5
  import '../lib/styles.css';
6
+ import type { PageData } from './$types.js';
5
7
 
6
- const { data, children = () => {}, prefix = '' } = $props();
8
+ const {
9
+ data,
10
+ children = () => {},
11
+ prefix = web.prefix,
12
+ }: {
13
+ data: PageData;
14
+ children: () => any;
15
+ prefix: string;
16
+ } = $props();
7
17
 
8
18
  const { user } = data;
9
19
 
@@ -2,6 +2,7 @@ import { fail, redirect, type Actions } from '@sveltejs/kit';
2
2
  import * as z from 'zod';
3
3
  import { adapter } from '../../../dist/auth.js';
4
4
  import type { PageServerLoadEvent } from './$types.js';
5
+ import { web } from '../../../dist/config.js';
5
6
 
6
7
  export async function load(event: PageServerLoadEvent) {
7
8
  const session = await event.locals.auth();
@@ -30,6 +31,6 @@ export const actions = {
30
31
  } catch (error: any) {
31
32
  return fail(400, { email, error: typeof error === 'string' ? error : error.message });
32
33
  }
33
- redirect(303, '/');
34
+ redirect(303, web.prefix);
34
35
  },
35
36
  } satisfies Actions;
@@ -1,6 +1,7 @@
1
1
  import { Name } from '@axium/core/schemas';
2
2
  import { fail, redirect, type Actions } from '@sveltejs/kit';
3
3
  import { adapter } from '../../../dist/auth.js';
4
+ import { web } from '../../../dist/config.js';
4
5
  import type { PageServerLoadEvent } from './$types.js';
5
6
 
6
7
  export async function load(event: PageServerLoadEvent) {
@@ -30,6 +31,6 @@ export const actions = {
30
31
  } catch (error: any) {
31
32
  return fail(400, { name, error: typeof error === 'string' ? error : error.message });
32
33
  }
33
- redirect(303, '/');
34
+ redirect(303, web.prefix);
34
35
  },
35
36
  } satisfies Actions;