@remindr/backend 1.0.2 → 1.0.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/dist/index.cjs +8 -13
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,14 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
33
|
+
createRemindrApi: () => createRemindrApi
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/createApp.ts
|
|
38
38
|
var import_express3 = __toESM(require("express"), 1);
|
|
39
39
|
var import_cors = __toESM(require("cors"), 1);
|
|
40
|
-
var import_node_path =
|
|
40
|
+
var import_node_path = require("path");
|
|
41
41
|
|
|
42
42
|
// src/routes/items.ts
|
|
43
43
|
var import_express = require("express");
|
|
@@ -156,7 +156,7 @@ authRouter.post("/", async (req, res) => {
|
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
// src/createApp.ts
|
|
159
|
-
function
|
|
159
|
+
function createRemindrApi(options) {
|
|
160
160
|
const app = (0, import_express3.default)();
|
|
161
161
|
app.use(import_express3.default.json());
|
|
162
162
|
app.use((0, import_cors.default)({
|
|
@@ -168,19 +168,14 @@ function createRemindrApp(options) {
|
|
|
168
168
|
app.get("/api/health", (_req, res) => {
|
|
169
169
|
res.json({ ok: true });
|
|
170
170
|
});
|
|
171
|
-
app.use("/api/items", createItemsRouter(
|
|
171
|
+
app.use("/api/items", createItemsRouter(
|
|
172
|
+
options.mapItemToRow,
|
|
173
|
+
options.matchKey ?? "id"
|
|
174
|
+
));
|
|
172
175
|
app.use("/api/auth", authRouter);
|
|
173
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
174
|
-
if (isProduction) {
|
|
175
|
-
const frontendDistPath = import_node_path.default.resolve(process.cwd(), options.clientPath);
|
|
176
|
-
app.use(import_express3.default.static(frontendDistPath));
|
|
177
|
-
app.get("*", (_req, res) => {
|
|
178
|
-
res.sendFile(import_node_path.default.join(frontendDistPath, "index.html"));
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
176
|
return app;
|
|
182
177
|
}
|
|
183
178
|
// Annotate the CommonJS export names for ESM import in node:
|
|
184
179
|
0 && (module.exports = {
|
|
185
|
-
|
|
180
|
+
createRemindrApi
|
|
186
181
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
4
|
-
clientPath: string;
|
|
3
|
+
declare function createRemindrApi<T>(options: {
|
|
5
4
|
matchKey?: string;
|
|
6
5
|
mapItemToRow: (item: {
|
|
7
6
|
id: string;
|
|
@@ -10,4 +9,4 @@ declare function createRemindrApp<T>(options: {
|
|
|
10
9
|
}) => Partial<T>;
|
|
11
10
|
}): express_serve_static_core.Express;
|
|
12
11
|
|
|
13
|
-
export {
|
|
12
|
+
export { createRemindrApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
4
|
-
clientPath: string;
|
|
3
|
+
declare function createRemindrApi<T>(options: {
|
|
5
4
|
matchKey?: string;
|
|
6
5
|
mapItemToRow: (item: {
|
|
7
6
|
id: string;
|
|
@@ -10,4 +9,4 @@ declare function createRemindrApp<T>(options: {
|
|
|
10
9
|
}) => Partial<T>;
|
|
11
10
|
}): express_serve_static_core.Express;
|
|
12
11
|
|
|
13
|
-
export {
|
|
12
|
+
export { createRemindrApi };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/createApp.ts
|
|
2
2
|
import express from "express";
|
|
3
3
|
import cors from "cors";
|
|
4
|
-
import
|
|
4
|
+
import "path";
|
|
5
5
|
|
|
6
6
|
// src/routes/items.ts
|
|
7
7
|
import { Router } from "express";
|
|
@@ -120,7 +120,7 @@ authRouter.post("/", async (req, res) => {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
// src/createApp.ts
|
|
123
|
-
function
|
|
123
|
+
function createRemindrApi(options) {
|
|
124
124
|
const app = express();
|
|
125
125
|
app.use(express.json());
|
|
126
126
|
app.use(cors({
|
|
@@ -132,18 +132,13 @@ function createRemindrApp(options) {
|
|
|
132
132
|
app.get("/api/health", (_req, res) => {
|
|
133
133
|
res.json({ ok: true });
|
|
134
134
|
});
|
|
135
|
-
app.use("/api/items", createItemsRouter(
|
|
135
|
+
app.use("/api/items", createItemsRouter(
|
|
136
|
+
options.mapItemToRow,
|
|
137
|
+
options.matchKey ?? "id"
|
|
138
|
+
));
|
|
136
139
|
app.use("/api/auth", authRouter);
|
|
137
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
138
|
-
if (isProduction) {
|
|
139
|
-
const frontendDistPath = path.resolve(process.cwd(), options.clientPath);
|
|
140
|
-
app.use(express.static(frontendDistPath));
|
|
141
|
-
app.get("*", (_req, res) => {
|
|
142
|
-
res.sendFile(path.join(frontendDistPath, "index.html"));
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
140
|
return app;
|
|
146
141
|
}
|
|
147
142
|
export {
|
|
148
|
-
|
|
143
|
+
createRemindrApi
|
|
149
144
|
};
|