dn-react-router-toolkit 0.5.6 → 0.5.8

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.
@@ -127,13 +127,10 @@ var createAPIHandler = ({
127
127
  const provider = slug[2];
128
128
  switch (method) {
129
129
  case "POST": {
130
- return (0, import_server.loginWithThirdPartyHandler)(
131
- request,
132
- {
133
- provider,
134
- getThirdPartyAuth
135
- }
136
- );
130
+ return (0, import_server.loginWithThirdPartyHandler)(request, {
131
+ provider,
132
+ getThirdPartyAuth
133
+ });
137
134
  }
138
135
  }
139
136
  }
@@ -172,14 +169,11 @@ var createAPIHandler = ({
172
169
  default: {
173
170
  switch (method) {
174
171
  case "POST": {
175
- return (0, import_server.signUpWithThirdpartyHandler)(
176
- request,
177
- {
178
- authService,
179
- fileService,
180
- signupTokenManager
181
- }
182
- );
172
+ return (0, import_server.signUpWithThirdpartyHandler)(request, {
173
+ authService,
174
+ fileService,
175
+ signupTokenManager
176
+ });
183
177
  }
184
178
  }
185
179
  }
@@ -215,9 +209,7 @@ var createAPIHandler = ({
215
209
  switch (method) {
216
210
  case "POST": {
217
211
  return withAuth(
218
- (auth) => ({ request: request2 }) => (0, import_server2.uploadFileHandler)({ fileService })(
219
- auth
220
- )(request2)
212
+ (auth) => ({ request: request2 }) => (0, import_server2.uploadFileHandler)({ fileService })(auth)(request2)
221
213
  )(args);
222
214
  }
223
215
  }
@@ -117,13 +117,10 @@ var createAPIHandler = ({
117
117
  const provider = slug[2];
118
118
  switch (method) {
119
119
  case "POST": {
120
- return loginWithThirdPartyHandler(
121
- request,
122
- {
123
- provider,
124
- getThirdPartyAuth
125
- }
126
- );
120
+ return loginWithThirdPartyHandler(request, {
121
+ provider,
122
+ getThirdPartyAuth
123
+ });
127
124
  }
128
125
  }
129
126
  }
@@ -162,14 +159,11 @@ var createAPIHandler = ({
162
159
  default: {
163
160
  switch (method) {
164
161
  case "POST": {
165
- return signUpWithThirdpartyHandler(
166
- request,
167
- {
168
- authService,
169
- fileService,
170
- signupTokenManager
171
- }
172
- );
162
+ return signUpWithThirdpartyHandler(request, {
163
+ authService,
164
+ fileService,
165
+ signupTokenManager
166
+ });
173
167
  }
174
168
  }
175
169
  }
@@ -205,9 +199,7 @@ var createAPIHandler = ({
205
199
  switch (method) {
206
200
  case "POST": {
207
201
  return withAuth(
208
- (auth) => ({ request: request2 }) => uploadFileHandler({ fileService })(
209
- auth
210
- )(request2)
202
+ (auth) => ({ request: request2 }) => uploadFileHandler({ fileService })(auth)(request2)
211
203
  )(args);
212
204
  }
213
205
  }
package/dist/api/index.js CHANGED
@@ -129,13 +129,10 @@ var createAPIHandler = ({
129
129
  const provider = slug[2];
130
130
  switch (method) {
131
131
  case "POST": {
132
- return (0, import_server.loginWithThirdPartyHandler)(
133
- request,
134
- {
135
- provider,
136
- getThirdPartyAuth
137
- }
138
- );
132
+ return (0, import_server.loginWithThirdPartyHandler)(request, {
133
+ provider,
134
+ getThirdPartyAuth
135
+ });
139
136
  }
140
137
  }
141
138
  }
@@ -174,14 +171,11 @@ var createAPIHandler = ({
174
171
  default: {
175
172
  switch (method) {
176
173
  case "POST": {
177
- return (0, import_server.signUpWithThirdpartyHandler)(
178
- request,
179
- {
180
- authService,
181
- fileService,
182
- signupTokenManager
183
- }
184
- );
174
+ return (0, import_server.signUpWithThirdpartyHandler)(request, {
175
+ authService,
176
+ fileService,
177
+ signupTokenManager
178
+ });
185
179
  }
186
180
  }
187
181
  }
@@ -217,9 +211,7 @@ var createAPIHandler = ({
217
211
  switch (method) {
218
212
  case "POST": {
219
213
  return withAuth(
220
- (auth) => ({ request: request2 }) => (0, import_server2.uploadFileHandler)({ fileService })(
221
- auth
222
- )(request2)
214
+ (auth) => ({ request: request2 }) => (0, import_server2.uploadFileHandler)({ fileService })(auth)(request2)
223
215
  )(args);
224
216
  }
225
217
  }
@@ -117,13 +117,10 @@ var createAPIHandler = ({
117
117
  const provider = slug[2];
118
118
  switch (method) {
119
119
  case "POST": {
120
- return loginWithThirdPartyHandler(
121
- request,
122
- {
123
- provider,
124
- getThirdPartyAuth
125
- }
126
- );
120
+ return loginWithThirdPartyHandler(request, {
121
+ provider,
122
+ getThirdPartyAuth
123
+ });
127
124
  }
128
125
  }
129
126
  }
@@ -162,14 +159,11 @@ var createAPIHandler = ({
162
159
  default: {
163
160
  switch (method) {
164
161
  case "POST": {
165
- return signUpWithThirdpartyHandler(
166
- request,
167
- {
168
- authService,
169
- fileService,
170
- signupTokenManager
171
- }
172
- );
162
+ return signUpWithThirdpartyHandler(request, {
163
+ authService,
164
+ fileService,
165
+ signupTokenManager
166
+ });
173
167
  }
174
168
  }
175
169
  }
@@ -205,9 +199,7 @@ var createAPIHandler = ({
205
199
  switch (method) {
206
200
  case "POST": {
207
201
  return withAuth(
208
- (auth) => ({ request: request2 }) => uploadFileHandler({ fileService })(
209
- auth
210
- )(request2)
202
+ (auth) => ({ request: request2 }) => uploadFileHandler({ fileService })(auth)(request2)
211
203
  )(args);
212
204
  }
213
205
  }
@@ -0,0 +1,7 @@
1
+ import { ObjectStorage } from 'dn-react-toolkit/file/server';
2
+
3
+ declare const backup: ({ objectStorage }: {
4
+ objectStorage: ObjectStorage;
5
+ }) => () => Promise<void>;
6
+
7
+ export { backup };
@@ -0,0 +1,7 @@
1
+ import { ObjectStorage } from 'dn-react-toolkit/file/server';
2
+
3
+ declare const backup: ({ objectStorage }: {
4
+ objectStorage: ObjectStorage;
5
+ }) => () => Promise<void>;
6
+
7
+ export { backup };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/db/backup/index.ts
31
+ var backup_exports = {};
32
+ __export(backup_exports, {
33
+ backup: () => backup
34
+ });
35
+ module.exports = __toCommonJS(backup_exports);
36
+ var import_util = require("util");
37
+ var fs = __toESM(require("fs"));
38
+ var import_child_process = require("child_process");
39
+ var backup = ({ objectStorage }) => async () => {
40
+ const now = /* @__PURE__ */ new Date();
41
+ console.log(`Running daily database backup at ${now.toISOString()}`);
42
+ const out = "./backup.sql";
43
+ const databaseUrl = `postgresql://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`;
44
+ await (0, import_util.promisify)(import_child_process.exec)(`pg_dump --dbname=${databaseUrl} > ${out}`);
45
+ const buffer = await (0, import_util.promisify)(fs.readFile)(out);
46
+ await objectStorage.put(`backup/${now.toISOString()}.sql`, buffer, {
47
+ contentType: "application/sql"
48
+ });
49
+ await (0, import_util.promisify)(fs.unlink)(out);
50
+ console.log("Database backup completed and uploaded to object storage");
51
+ };
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ backup
55
+ });
@@ -0,0 +1,20 @@
1
+ // src/db/backup/index.ts
2
+ import { promisify } from "util";
3
+ import * as fs from "fs";
4
+ import { exec } from "child_process";
5
+ var backup = ({ objectStorage }) => async () => {
6
+ const now = /* @__PURE__ */ new Date();
7
+ console.log(`Running daily database backup at ${now.toISOString()}`);
8
+ const out = "./backup.sql";
9
+ const databaseUrl = `postgresql://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`;
10
+ await promisify(exec)(`pg_dump --dbname=${databaseUrl} > ${out}`);
11
+ const buffer = await promisify(fs.readFile)(out);
12
+ await objectStorage.put(`backup/${now.toISOString()}.sql`, buffer, {
13
+ contentType: "application/sql"
14
+ });
15
+ await promisify(fs.unlink)(out);
16
+ console.log("Database backup completed and uploaded to object storage");
17
+ };
18
+ export {
19
+ backup
20
+ };
package/dist/seo/index.js CHANGED
@@ -50,7 +50,7 @@ var import_react = __toESM(require("react"));
50
50
  var Schema = __toESM(require_schema());
51
51
  var import_react_router = require("react-router");
52
52
  function configSEO(config) {
53
- function init(props) {
53
+ function create(props) {
54
54
  const canonicalPath = props.canonicalPath;
55
55
  const url = canonicalPath ? `${config.origin}${canonicalPath === "/" ? "" : canonicalPath}` : `${config.origin}${props.path || ""}`;
56
56
  const pageTitle = props.title ? `${props.title} | ${config.siteName}` : config.siteName;
@@ -133,9 +133,7 @@ function configSEO(config) {
133
133
  }
134
134
  ] : [],
135
135
  ...props.images || [],
136
- ...props.collection?.map(
137
- (portfolio) => portfolio.thumbnail
138
- ) || []
136
+ ...props.collection?.map((portfolio) => portfolio.thumbnail) || []
139
137
  ].filter(Boolean);
140
138
  const image = images.filter((file) => file.id).map((file) => ({
141
139
  "@type": "ImageObject",
@@ -151,23 +149,21 @@ function configSEO(config) {
151
149
  const collectionMainEntity = props.collection ? {
152
150
  "@type": "ItemList",
153
151
  numberOfItems: props.collection.length,
154
- itemListElement: props.collection.map(
155
- (item, index) => ({
156
- "@type": "ListItem",
157
- position: index + 1,
152
+ itemListElement: props.collection.map((item, index) => ({
153
+ "@type": "ListItem",
154
+ position: index + 1,
155
+ url: item.url,
156
+ item: {
157
+ "@type": "WebPage",
158
+ "@id": `${item.url}#webpage`,
158
159
  url: item.url,
159
- item: {
160
- "@type": "WebPage",
161
- "@id": `${item.url}#webpage`,
162
- url: item.url,
163
- name: item.title,
164
- thumbnailUrl: item.thumbnail?.url,
165
- dateModified: item.updatedAt?.toISOString(),
166
- dateCreated: item.createdAt?.toISOString(),
167
- datePublished: item.createdAt?.toISOString()
168
- }
169
- })
170
- )
160
+ name: item.title,
161
+ thumbnailUrl: item.thumbnail?.url,
162
+ dateModified: item.updatedAt?.toISOString(),
163
+ dateCreated: item.createdAt?.toISOString(),
164
+ datePublished: item.createdAt?.toISOString()
165
+ }
166
+ }))
171
167
  } : void 0;
172
168
  const structuredData = {
173
169
  "@context": "https://schema.org",
@@ -306,7 +302,7 @@ function configSEO(config) {
306
302
  }
307
303
  return {
308
304
  config,
309
- init,
305
+ create,
310
306
  meta,
311
307
  StructedData
312
308
  };
@@ -37,7 +37,7 @@ var Schema = __toESM(require_schema());
37
37
  import React from "react";
38
38
  import { useLoaderData } from "react-router";
39
39
  function configSEO(config) {
40
- function init(props) {
40
+ function create(props) {
41
41
  const canonicalPath = props.canonicalPath;
42
42
  const url = canonicalPath ? `${config.origin}${canonicalPath === "/" ? "" : canonicalPath}` : `${config.origin}${props.path || ""}`;
43
43
  const pageTitle = props.title ? `${props.title} | ${config.siteName}` : config.siteName;
@@ -120,9 +120,7 @@ function configSEO(config) {
120
120
  }
121
121
  ] : [],
122
122
  ...props.images || [],
123
- ...props.collection?.map(
124
- (portfolio) => portfolio.thumbnail
125
- ) || []
123
+ ...props.collection?.map((portfolio) => portfolio.thumbnail) || []
126
124
  ].filter(Boolean);
127
125
  const image = images.filter((file) => file.id).map((file) => ({
128
126
  "@type": "ImageObject",
@@ -138,23 +136,21 @@ function configSEO(config) {
138
136
  const collectionMainEntity = props.collection ? {
139
137
  "@type": "ItemList",
140
138
  numberOfItems: props.collection.length,
141
- itemListElement: props.collection.map(
142
- (item, index) => ({
143
- "@type": "ListItem",
144
- position: index + 1,
139
+ itemListElement: props.collection.map((item, index) => ({
140
+ "@type": "ListItem",
141
+ position: index + 1,
142
+ url: item.url,
143
+ item: {
144
+ "@type": "WebPage",
145
+ "@id": `${item.url}#webpage`,
145
146
  url: item.url,
146
- item: {
147
- "@type": "WebPage",
148
- "@id": `${item.url}#webpage`,
149
- url: item.url,
150
- name: item.title,
151
- thumbnailUrl: item.thumbnail?.url,
152
- dateModified: item.updatedAt?.toISOString(),
153
- dateCreated: item.createdAt?.toISOString(),
154
- datePublished: item.createdAt?.toISOString()
155
- }
156
- })
157
- )
147
+ name: item.title,
148
+ thumbnailUrl: item.thumbnail?.url,
149
+ dateModified: item.updatedAt?.toISOString(),
150
+ dateCreated: item.createdAt?.toISOString(),
151
+ datePublished: item.createdAt?.toISOString()
152
+ }
153
+ }))
158
154
  } : void 0;
159
155
  const structuredData = {
160
156
  "@context": "https://schema.org",
@@ -293,7 +289,7 @@ function configSEO(config) {
293
289
  }
294
290
  return {
295
291
  config,
296
- init,
292
+ create,
297
293
  meta,
298
294
  StructedData
299
295
  };
@@ -9,7 +9,7 @@ type SEOImage = {
9
9
  width?: number;
10
10
  height?: number;
11
11
  };
12
- type SEO = Awaited<ReturnType<ReturnType<typeof configSEO>["init"]>>;
12
+ type SEO = Awaited<ReturnType<ReturnType<typeof configSEO>["create"]>>;
13
13
  declare function configSEO(config: {
14
14
  origin: string;
15
15
  siteName: string;
@@ -28,7 +28,7 @@ declare function configSEO(config: {
28
28
  structedData?: Schema.Thing[] | (() => Schema.Thing[]);
29
29
  copyright?: string;
30
30
  };
31
- init: (props: {
31
+ create: (props: {
32
32
  title?: string;
33
33
  description?: string;
34
34
  keywords?: string[];
package/dist/seo/seo.d.ts CHANGED
@@ -9,7 +9,7 @@ type SEOImage = {
9
9
  width?: number;
10
10
  height?: number;
11
11
  };
12
- type SEO = Awaited<ReturnType<ReturnType<typeof configSEO>["init"]>>;
12
+ type SEO = Awaited<ReturnType<ReturnType<typeof configSEO>["create"]>>;
13
13
  declare function configSEO(config: {
14
14
  origin: string;
15
15
  siteName: string;
@@ -28,7 +28,7 @@ declare function configSEO(config: {
28
28
  structedData?: Schema.Thing[] | (() => Schema.Thing[]);
29
29
  copyright?: string;
30
30
  };
31
- init: (props: {
31
+ create: (props: {
32
32
  title?: string;
33
33
  description?: string;
34
34
  keywords?: string[];
package/dist/seo/seo.js CHANGED
@@ -48,7 +48,7 @@ var import_react = __toESM(require("react"));
48
48
  var Schema = __toESM(require_schema());
49
49
  var import_react_router = require("react-router");
50
50
  function configSEO(config) {
51
- function init(props) {
51
+ function create(props) {
52
52
  const canonicalPath = props.canonicalPath;
53
53
  const url = canonicalPath ? `${config.origin}${canonicalPath === "/" ? "" : canonicalPath}` : `${config.origin}${props.path || ""}`;
54
54
  const pageTitle = props.title ? `${props.title} | ${config.siteName}` : config.siteName;
@@ -131,9 +131,7 @@ function configSEO(config) {
131
131
  }
132
132
  ] : [],
133
133
  ...props.images || [],
134
- ...props.collection?.map(
135
- (portfolio) => portfolio.thumbnail
136
- ) || []
134
+ ...props.collection?.map((portfolio) => portfolio.thumbnail) || []
137
135
  ].filter(Boolean);
138
136
  const image = images.filter((file) => file.id).map((file) => ({
139
137
  "@type": "ImageObject",
@@ -149,23 +147,21 @@ function configSEO(config) {
149
147
  const collectionMainEntity = props.collection ? {
150
148
  "@type": "ItemList",
151
149
  numberOfItems: props.collection.length,
152
- itemListElement: props.collection.map(
153
- (item, index) => ({
154
- "@type": "ListItem",
155
- position: index + 1,
150
+ itemListElement: props.collection.map((item, index) => ({
151
+ "@type": "ListItem",
152
+ position: index + 1,
153
+ url: item.url,
154
+ item: {
155
+ "@type": "WebPage",
156
+ "@id": `${item.url}#webpage`,
156
157
  url: item.url,
157
- item: {
158
- "@type": "WebPage",
159
- "@id": `${item.url}#webpage`,
160
- url: item.url,
161
- name: item.title,
162
- thumbnailUrl: item.thumbnail?.url,
163
- dateModified: item.updatedAt?.toISOString(),
164
- dateCreated: item.createdAt?.toISOString(),
165
- datePublished: item.createdAt?.toISOString()
166
- }
167
- })
168
- )
158
+ name: item.title,
159
+ thumbnailUrl: item.thumbnail?.url,
160
+ dateModified: item.updatedAt?.toISOString(),
161
+ dateCreated: item.createdAt?.toISOString(),
162
+ datePublished: item.createdAt?.toISOString()
163
+ }
164
+ }))
169
165
  } : void 0;
170
166
  const structuredData = {
171
167
  "@context": "https://schema.org",
@@ -304,7 +300,7 @@ function configSEO(config) {
304
300
  }
305
301
  return {
306
302
  config,
307
- init,
303
+ create,
308
304
  meta,
309
305
  StructedData
310
306
  };
package/dist/seo/seo.mjs CHANGED
@@ -37,7 +37,7 @@ var Schema = __toESM(require_schema());
37
37
  import React from "react";
38
38
  import { useLoaderData } from "react-router";
39
39
  function configSEO(config) {
40
- function init(props) {
40
+ function create(props) {
41
41
  const canonicalPath = props.canonicalPath;
42
42
  const url = canonicalPath ? `${config.origin}${canonicalPath === "/" ? "" : canonicalPath}` : `${config.origin}${props.path || ""}`;
43
43
  const pageTitle = props.title ? `${props.title} | ${config.siteName}` : config.siteName;
@@ -120,9 +120,7 @@ function configSEO(config) {
120
120
  }
121
121
  ] : [],
122
122
  ...props.images || [],
123
- ...props.collection?.map(
124
- (portfolio) => portfolio.thumbnail
125
- ) || []
123
+ ...props.collection?.map((portfolio) => portfolio.thumbnail) || []
126
124
  ].filter(Boolean);
127
125
  const image = images.filter((file) => file.id).map((file) => ({
128
126
  "@type": "ImageObject",
@@ -138,23 +136,21 @@ function configSEO(config) {
138
136
  const collectionMainEntity = props.collection ? {
139
137
  "@type": "ItemList",
140
138
  numberOfItems: props.collection.length,
141
- itemListElement: props.collection.map(
142
- (item, index) => ({
143
- "@type": "ListItem",
144
- position: index + 1,
139
+ itemListElement: props.collection.map((item, index) => ({
140
+ "@type": "ListItem",
141
+ position: index + 1,
142
+ url: item.url,
143
+ item: {
144
+ "@type": "WebPage",
145
+ "@id": `${item.url}#webpage`,
145
146
  url: item.url,
146
- item: {
147
- "@type": "WebPage",
148
- "@id": `${item.url}#webpage`,
149
- url: item.url,
150
- name: item.title,
151
- thumbnailUrl: item.thumbnail?.url,
152
- dateModified: item.updatedAt?.toISOString(),
153
- dateCreated: item.createdAt?.toISOString(),
154
- datePublished: item.createdAt?.toISOString()
155
- }
156
- })
157
- )
147
+ name: item.title,
148
+ thumbnailUrl: item.thumbnail?.url,
149
+ dateModified: item.updatedAt?.toISOString(),
150
+ dateCreated: item.createdAt?.toISOString(),
151
+ datePublished: item.createdAt?.toISOString()
152
+ }
153
+ }))
158
154
  } : void 0;
159
155
  const structuredData = {
160
156
  "@context": "https://schema.org",
@@ -293,7 +289,7 @@ function configSEO(config) {
293
289
  }
294
290
  return {
295
291
  config,
296
- init,
292
+ create,
297
293
  meta,
298
294
  StructedData
299
295
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
@@ -35,6 +35,11 @@
35
35
  "import": "./dist/db/index.mjs",
36
36
  "require": "./dist/db/index.js"
37
37
  },
38
+ "./db/backup": {
39
+ "types": "./dist/db/backup/index.d.ts",
40
+ "import": "./dist/db/backup/index.mjs",
41
+ "require": "./dist/db/backup/index.js"
42
+ },
38
43
  "./table": {
39
44
  "types": "./dist/table/index.d.ts",
40
45
  "import": "./dist/table/index.mjs",