@sqrzro/server 2.0.0-bz.12 → 2.0.0-bz.13

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/forms.js CHANGED
@@ -1,302 +1,10 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/forms/index.ts
30
- var forms_exports = {};
31
- __export(forms_exports, {
32
- createSchema: () => createSchema,
33
- extendSchema: () => extendSchema,
34
- submitForm: () => submitForm,
35
- validate: () => validate,
36
- validateImage: () => validateImage,
37
- validateSchema: () => validateSchema
38
- });
39
- module.exports = __toCommonJS(forms_exports);
40
-
41
- // src/forms/ValidationError.ts
42
- var ValidationError = class extends Error {
43
- constructor(messages2) {
44
- super(JSON.stringify(messages2));
45
- this.name = "ValidationError";
46
- }
47
- };
48
- var ValidationError_default = ValidationError;
49
-
50
- // src/forms/ValidationService.ts
51
- var import_joi = __toESM(require("joi"));
52
-
53
- // src/forms/lang.ts
54
- var messages = {
55
- "alternatives.all": "",
56
- "alternatives.any": "",
57
- "alternatives.match": "",
58
- "alternatives.one": "",
59
- "alternatives.types": "",
60
- "any.custom": "",
61
- "any.default": "",
62
- "any.failover": "",
63
- "any.invalid": "",
64
- "any.only": "",
65
- "any.ref": "",
66
- "any.required": "{{#label}} is required",
67
- "any.unknown": "",
68
- "array.base": "",
69
- "array.excludes": "",
70
- "array.includesRequiredBoth": "",
71
- "array.includesRequiredKnowns": "",
72
- "array.includesRequiredUnknowns": "",
73
- "array.includes": "",
74
- "array.length": "",
75
- "array.max": "",
76
- "array.min": "",
77
- "array.orderedLength": "",
78
- "array.sort": "",
79
- "array.sort.mismatching": "",
80
- "array.sort.unsupported": "",
81
- "array.sparse": "",
82
- "array.unique": "",
83
- "array.hasKnown": "",
84
- "array.hasUnknown": "",
85
- "binary.base": "",
86
- "binary.length": "",
87
- "binary.max": "",
88
- "binary.min": "",
89
- "boolean.base": "",
90
- "date.base": "",
91
- "date.format": "",
92
- "date.greater": "",
93
- "date.less": "",
94
- "date.max": "",
95
- "date.min": "",
96
- "date.strict": "",
97
- "function.arity": "",
98
- "function.class": "",
99
- "function.maxArity": "",
100
- "function.minArity": "",
101
- "number.base": "{{#label}} should be a number",
102
- "number.greater": "",
103
- "number.infinity": "",
104
- "number.integer": "",
105
- "number.less": "",
106
- "number.max": "",
107
- "number.min": "{{#label}} should be greater than or equal to {{#limit}}",
108
- "number.multiple": "",
109
- "number.negative": "",
110
- "number.port": "",
111
- "number.positive": "",
112
- "number.precision": "",
113
- "number.unsafe": "",
114
- "object.unknown": "",
115
- "object.and": "",
116
- "object.assert": "",
117
- "object.base": "",
118
- "object.length": "",
119
- "object.max": "",
120
- "object.min": "",
121
- "object.missing": "",
122
- "object.nand": "",
123
- "object.pattern.match": "",
124
- "object.refType": "",
125
- "object.regex": "",
126
- "object.rename.multiple": "",
127
- "object.rename.override": "",
128
- "object.schema": "",
129
- "object.instance": "",
130
- "object.with": "",
131
- "object.without": "",
132
- "object.xor": "",
133
- "object.oxor": "",
134
- "string.alphanum": "",
135
- "string.base64": "",
136
- "string.base": "",
137
- "string.creditCard": "",
138
- "string.dataUri": "",
139
- "string.domain": "",
140
- "string.email": "",
141
- "string.empty": "{{#label}} is required",
142
- "string.guid": "",
143
- "string.hexAlign": "",
144
- "string.hex": "",
145
- "string.hostname": "",
146
- "string.ipVersion": "",
147
- "string.ip": "",
148
- "string.isoDate": "",
149
- "string.isoDuration": "",
150
- "string.length": "",
151
- "string.lowercase": "",
152
- "string.max": "",
153
- "string.min": "",
154
- "string.normalize": "",
155
- "string.pattern.base": "",
156
- "string.pattern.name": "",
157
- "string.pattern.invert.base": "",
158
- "string.pattern.invert.name": "",
159
- "string.token": "",
160
- "string.trim": "",
161
- "string.uppercase": "",
162
- "string.uri": "",
163
- "string.uriCustomScheme": "",
164
- "string.uriRelativeOnly": "",
165
- "symbol.base": "",
166
- "symbol.map": ""
167
- };
168
- var lang_default = messages;
169
-
170
- // src/forms/ValidationService.ts
171
- function validate() {
172
- return import_joi.default;
173
- }
174
- function getErrorMessages() {
175
- return Object.entries(lang_default).reduce((acc, [key, value]) => {
176
- if (!value) {
177
- return acc;
178
- }
179
- return {
180
- ...acc,
181
- [key]: value
182
- };
183
- }, {});
184
- }
185
- function transformErrors(error) {
186
- const messages2 = error.details.reduce(
187
- (acc, cur) => ({
188
- ...acc,
189
- [cur.path.join(".")]: cur.message.replace(/"/gu, "")
190
- }),
191
- {}
192
- );
193
- return new ValidationError_default(messages2);
194
- }
195
- async function validateSchema(formData, validation) {
196
- try {
197
- const validated = await validation.validateAsync(formData, {
198
- abortEarly: false,
199
- messages: getErrorMessages()
200
- });
201
- return [validated, null];
202
- } catch (err) {
203
- if (err instanceof import_joi.default.ValidationError) {
204
- return [null, transformErrors(err)];
205
- }
206
- if (err instanceof Error) {
207
- return [null, err];
208
- }
209
- return [null, new Error("Unknown validation error occured")];
210
- }
211
- }
212
- function createSchema(schema) {
213
- return import_joi.default.object(schema);
214
- }
215
- function extendSchema(schema, appends) {
216
- return schema.append(appends);
217
- }
218
-
219
- // src/forms/FormService.ts
220
- function serializeError(err) {
221
- return {
222
- cause: err.cause,
223
- message: err.message,
224
- name: err.name,
225
- stack: err.stack
226
- };
227
- }
228
- function hasFn(args) {
229
- return Boolean(Object.prototype.hasOwnProperty.call(args, "fn"));
230
- }
231
- async function submitForm(args) {
232
- let data = { ...args.formData };
233
- if (args.request) {
234
- const [validated, validationError] = await validateSchema(args.formData, args.request);
235
- if (validationError !== null) {
236
- if (validationError instanceof ValidationError_default) {
237
- args.onValidationError?.(validationError);
238
- }
239
- return [null, serializeError(validationError)];
240
- }
241
- data = validated;
242
- }
243
- if (!hasFn(args)) {
244
- try {
245
- await args.onSuccess?.(data);
246
- } catch (err) {
247
- if (err instanceof Error) {
248
- return [null, serializeError(err)];
249
- }
250
- return [
251
- null,
252
- serializeError(
253
- new Error("The submitForm onSuccess function encountered an unknown error")
254
- )
255
- ];
256
- }
257
- return [data, null];
258
- }
259
- let model = null;
260
- try {
261
- model = await args.fn(data);
262
- } catch (err) {
263
- if (err instanceof ValidationError_default) {
264
- args.onValidationError?.(err);
265
- return [null, serializeError(err)];
266
- }
267
- if (err instanceof Error) {
268
- return [null, serializeError(err)];
269
- }
270
- return [
271
- null,
272
- serializeError(
273
- new Error("The function supplied to submitForm encountered an unknown error")
274
- )
275
- ];
276
- }
277
- if (!model) {
278
- return [
279
- null,
280
- serializeError(
281
- new Error("No model has been returned from the function supplied to submitForm")
282
- )
283
- ];
284
- }
285
- try {
286
- await args.onSuccess?.(model);
287
- } catch (err) {
288
- if (err instanceof Error) {
289
- return [null, serializeError(err)];
290
- }
291
- return [
292
- null,
293
- serializeError(
294
- new Error("The submitForm onSuccess function encountered an unknown error")
295
- )
296
- ];
297
- }
298
- return [model, null];
299
- }
1
+ import {
2
+ createSchema,
3
+ extendSchema,
4
+ submitForm,
5
+ validate,
6
+ validateSchema
7
+ } from "./chunk-7XG6NQUS.js";
300
8
 
301
9
  // src/forms/ImageService.ts
302
10
  var DEFAULT_TYPES = ["image/png", "image/jpeg", "image/jpg"];
@@ -316,12 +24,11 @@ async function validateImage(image, config) {
316
24
  }
317
25
  return Promise.resolve([image, null]);
318
26
  }
319
- // Annotate the CommonJS export names for ESM import in node:
320
- 0 && (module.exports = {
27
+ export {
321
28
  createSchema,
322
29
  extendSchema,
323
30
  submitForm,
324
31
  validate,
325
32
  validateImage,
326
33
  validateSchema
327
- });
34
+ };
package/dist/lists.js CHANGED
@@ -1,30 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lists/index.ts
20
- var lists_exports = {};
21
- __export(lists_exports, {
22
- getList: () => getList
23
- });
24
- module.exports = __toCommonJS(lists_exports);
25
-
26
1
  // src/lists/ListService.ts
27
- var import_utility = require("@sqrzro/utility");
2
+ import { getFromObject } from "@sqrzro/utility";
28
3
  var DEFAULT_SORT = "id";
29
4
  var DEFAULT_DIR = "asc";
30
5
  var DEFAULT_PAGE = 1;
@@ -37,7 +12,7 @@ function createFindManyArgs(searchParams, allowedFilters = []) {
37
12
  return {
38
13
  ...createPaginationArgs(page ? parseInt(page, 10) : DEFAULT_PAGE),
39
14
  orderBy: { [sort || DEFAULT_SORT]: dir || DEFAULT_DIR },
40
- where: (0, import_utility.getFromObject)(filters, allowedFilters)
15
+ where: getFromObject(filters, allowedFilters)
41
16
  };
42
17
  }
43
18
  async function getList({
@@ -55,7 +30,6 @@ async function getList({
55
30
  return [null, new Error("[getList] An unknown error occurred")];
56
31
  }
57
32
  }
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
33
+ export {
60
34
  getList
61
- });
35
+ };
package/dist/mail.js CHANGED
@@ -1,40 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/mail/index.ts
30
- var mail_exports = {};
31
- __export(mail_exports, {
32
- createMail: () => createMail,
33
- getMail: () => getMail,
34
- sendMail: () => sendMail
35
- });
36
- module.exports = __toCommonJS(mail_exports);
37
-
38
1
  // src/mail/MailService.ts
39
2
  async function createMail(subject, template) {
40
3
  return Promise.resolve(async () => Promise.resolve({ subject, template }));
@@ -89,9 +52,8 @@ async function sendMail(mail, data, to) {
89
52
  return false;
90
53
  }
91
54
  }
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
55
+ export {
94
56
  createMail,
95
57
  getMail,
96
58
  sendMail
97
- });
59
+ };
@@ -1,28 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
1
  // src/middleware.ts
20
- var middleware_exports = {};
21
- __export(middleware_exports, {
22
- handleMiddleware: () => handleMiddleware
23
- });
24
- module.exports = __toCommonJS(middleware_exports);
25
- var import_server = require("next/server");
2
+ import { NextResponse } from "next/server";
26
3
  var DEFAULT_REDIRECT = "/auth/login";
27
4
  function applyHeaders(request, response) {
28
5
  response.headers.set("x-origin", request.nextUrl.origin);
@@ -34,11 +11,11 @@ function getRelativeUrl(url) {
34
11
  }
35
12
  function redirect(request, pathname = DEFAULT_REDIRECT) {
36
13
  if (request.nextUrl.pathname === pathname) {
37
- return applyHeaders(request, import_server.NextResponse.next());
14
+ return applyHeaders(request, NextResponse.next());
38
15
  }
39
16
  return applyHeaders(
40
17
  request,
41
- import_server.NextResponse.redirect(
18
+ NextResponse.redirect(
42
19
  `${request.nextUrl.origin}${pathname}?r=${encodeURIComponent(
43
20
  getRelativeUrl(request.nextUrl)
44
21
  )}`
@@ -53,14 +30,13 @@ async function handleMiddleware(request, nextFn) {
53
30
  );
54
31
  const json = await session.json();
55
32
  if (json.redirect === null) {
56
- return applyHeaders(request, nextFn ? nextFn() : import_server.NextResponse.next());
33
+ return applyHeaders(request, nextFn ? nextFn() : NextResponse.next());
57
34
  }
58
35
  return redirect(request, json.redirect);
59
36
  } catch (err) {
60
37
  return redirect(request);
61
38
  }
62
39
  }
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
40
+ export {
65
41
  handleMiddleware
66
- });
42
+ };
package/dist/schema.js CHANGED
@@ -1,71 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/database/schema.ts
20
- var schema_exports = {};
21
- __export(schema_exports, {
22
- authClientTable: () => authClientTable,
23
- authMFATable: () => authMFATable,
24
- authResetTable: () => authResetTable,
25
- authSchema: () => authSchema,
26
- authSessionTable: () => authSessionTable,
27
- authUserTable: () => authUserTable,
28
- mfaType: () => mfaType,
29
- scope: () => scope
30
- });
31
- module.exports = __toCommonJS(schema_exports);
32
- var import_pg_core = require("drizzle-orm/pg-core");
33
- var DEFAULT_ROLE = 10;
34
- var mfaType = (0, import_pg_core.pgEnum)("mfaType", ["TOTP", "HARDWARE"]);
35
- var scope = (0, import_pg_core.pgEnum)("scope", ["ANON", "MFA", "AUTHED"]);
36
- var authSchema = (0, import_pg_core.pgSchema)("auth");
37
- var authUserTable = authSchema.table("user_credentials", {
38
- id: (0, import_pg_core.text)("id").primaryKey(),
39
- email: (0, import_pg_core.text)("email").notNull().unique(),
40
- password: (0, import_pg_core.text)("password"),
41
- role: (0, import_pg_core.integer)("role").notNull().default(DEFAULT_ROLE)
42
- });
43
- var authSessionTable = authSchema.table("sessions", {
44
- id: (0, import_pg_core.text)("id").primaryKey(),
45
- userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
46
- scope: scope("scope").notNull().default("ANON"),
47
- expiresAt: (0, import_pg_core.timestamp)("expiresAt").notNull()
48
- });
49
- var authResetTable = authSchema.table("resets", {
50
- id: (0, import_pg_core.text)("id").primaryKey(),
51
- userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
52
- expiresAt: (0, import_pg_core.timestamp)("expiresAt").notNull()
53
- });
54
- var authMFATable = authSchema.table("mfas", {
55
- id: (0, import_pg_core.text)("id").primaryKey(),
56
- name: (0, import_pg_core.text)("name").notNull(),
57
- userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
58
- type: mfaType("type").notNull().default("TOTP"),
59
- secret: (0, import_pg_core.text)("secret").notNull(),
60
- verifiedAt: (0, import_pg_core.timestamp)("verifiedAt")
61
- });
62
- var authClientTable = authSchema.table("client_credentials", {
63
- id: (0, import_pg_core.text)("id").primaryKey(),
64
- alias: (0, import_pg_core.text)("alias").notNull().unique(),
65
- secret: (0, import_pg_core.text)("secret").notNull().unique()
66
- });
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
1
+ import {
69
2
  authClientTable,
70
3
  authMFATable,
71
4
  authResetTable,
@@ -74,4 +7,14 @@ var authClientTable = authSchema.table("client_credentials", {
74
7
  authUserTable,
75
8
  mfaType,
76
9
  scope
77
- });
10
+ } from "./chunk-G4EG2ECB.js";
11
+ export {
12
+ authClientTable,
13
+ authMFATable,
14
+ authResetTable,
15
+ authSchema,
16
+ authSessionTable,
17
+ authUserTable,
18
+ mfaType,
19
+ scope
20
+ };
package/dist/url.js CHANGED
@@ -1,56 +1,8 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/url/index.ts
20
- var url_exports = {};
21
- __export(url_exports, {
22
- getOrigin: () => getOrigin,
23
- getURL: () => getURL
24
- });
25
- module.exports = __toCommonJS(url_exports);
26
-
27
- // src/url/URLService.ts
28
- var import_headers = require("next/headers");
29
- function getOrigin() {
30
- const origin = (0, import_headers.headers)().get("x-origin");
31
- if (origin) {
32
- return origin;
33
- }
34
- const proto = (0, import_headers.headers)().get("x-forwarded-proto");
35
- const host = (0, import_headers.headers)().get("x-forwarded-host");
36
- if (proto && host) {
37
- return `${proto}://${host}`;
38
- }
39
- throw new Error("No origin could be determined");
40
- }
41
- function getURL(pathname) {
42
- const origin = getOrigin();
43
- if (!pathname) {
44
- return origin;
45
- }
46
- const isSecure = origin.startsWith("https://");
47
- const protocol = isSecure ? "https://" : "http://";
48
- const originWithoutProtocol = origin.replace(/^https?:\/\//u, "");
49
- const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\/+/gu, "/");
50
- return `${protocol}${cleanURL}`;
51
- }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
1
+ import {
54
2
  getOrigin,
55
3
  getURL
56
- });
4
+ } from "./chunk-ALBKLI2J.js";
5
+ export {
6
+ getOrigin,
7
+ getURL
8
+ };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/server",
3
- "version": "2.0.0-bz.12",
3
+ "version": "2.0.0-bz.13",
4
+ "type": "module",
4
5
  "main": "dist/index.js",
5
6
  "types": "dist/index.d.ts",
6
7
  "license": "ISC",
@@ -57,7 +58,7 @@
57
58
  "typescript": "^5.4.2"
58
59
  },
59
60
  "scripts": {
60
- "build": "pnpm clean && tsup --entry.auth src/auth/index.ts --entry.cache src/cache/index.ts --entry.forms src/forms/index.ts --entry.lists src/lists/index.ts --entry.mail src/mail/index.ts --entry.middleware src/middleware.ts --entry.schema src/database/schema.ts --entry.url src/url/index.ts --dts",
61
+ "build": "pnpm clean && tsup --entry.auth src/auth/index.ts --entry.cache src/cache/index.ts --entry.forms src/forms/index.ts --entry.lists src/lists/index.ts --entry.mail src/mail/index.ts --entry.middleware src/middleware.ts --entry.schema src/database/schema.ts --entry.url src/url/index.ts --dts --format esm",
61
62
  "clean": "rimraf ./dist",
62
63
  "dev": "tsc -p tsconfig.build.json -w",
63
64
  "lint": "tsc --noEmit && eslint \"./src/**/*.ts\"",