remult 0.14.35 → 0.15.2

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/README.md CHANGED
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
  <hr/>
29
29
 
30
- [Getting Started](#getting-started) | [Documentation](#documentation) | [Example App](#example-app)
30
+ [Getting Started](#getting-started) | [Documentation](#documentation) | [Example Apps](#example-apps)
31
31
 
32
32
  ## What is Remult?
33
33
 
@@ -222,9 +222,11 @@ The best way to learn Remult is by following a tutorial of a simple Todo web app
222
222
  ## Documentation
223
223
  The [documentation](https://remult.dev/docs) covers the main features of Remult. However, it is still a work-in-progress.
224
224
 
225
- ## Example App
225
+ ## Example Apps
226
226
 
227
- [CRM demo](https://github.com/remult/crm-demo) with a React + [MUI](https://mui.com) front-end and Postgres database.
227
+ * Fullstack TodoMVC example with React and Express. ([Source code](https://github.com/remult/TodoMVC-eample) | [CodeSandbox](https://codesandbox.io/s/github/remult/TodoMVC-example?file=/src/frontend/App.tsx))
228
+
229
+ * [CRM demo](https://github.com/remult/crm-demo) with a React + [MUI](https://mui.com) front-end and Postgres database.
228
230
 
229
231
  ## Contributing
230
232
  Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -1,6 +1,6 @@
1
1
  import * as express from 'express';
2
2
  import { RemultServer, RemultServerOptions } from './server/expressBridge';
3
- export declare function remultExpress(options?: RemultServerOptions & {
3
+ export declare function remultExpress(options?: RemultServerOptions<express.Request> & {
4
4
  bodyParser?: boolean;
5
5
  bodySizeLimit?: string;
6
6
  }): express.RequestHandler & RemultServer;
@@ -1,3 +1,3 @@
1
- import type { FastifyPluginCallback } from 'fastify';
1
+ import type { FastifyPluginCallback, FastifyRequest } from 'fastify';
2
2
  import { RemultServer, RemultServerOptions } from './server/expressBridge';
3
- export declare function remultFastify(options: RemultServerOptions): FastifyPluginCallback & RemultServer;
3
+ export declare function remultFastify(options: RemultServerOptions<FastifyRequest>): FastifyPluginCallback & RemultServer;
@@ -1,6 +1,6 @@
1
1
  import { RemultServerOptions, GenericRequest } from "./server/expressBridge";
2
2
  import { Remult } from "./src/context";
3
- export declare function remultFresh(options: RemultServerOptions, response: FreshResponse): RemultFresh;
3
+ export declare function remultFresh<RequestType extends GenericRequest>(options: RemultServerOptions<RequestType>, response: FreshResponse): RemultFresh;
4
4
  export interface RemultFresh {
5
5
  getRemult(req: GenericRequest): Promise<Remult>;
6
6
  openApiDoc(options: {
@@ -4,23 +4,23 @@ import { Remult, UserInfo } from '../src/context';
4
4
  import { ClassType } from '../classType';
5
5
  import { Repository } from '../src/remult3';
6
6
  import { IdEntity } from '../src/id-entity';
7
- export declare type RemultServerOptions = {
7
+ export interface RemultServerOptions<RequestType extends GenericRequest> {
8
8
  /** Sets a database connection for Remult.
9
9
  *
10
10
  * @see [Connecting to a Database](https://remult.dev/docs/databases.html).
11
11
  */
12
12
  dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>);
13
13
  queueStorage?: QueueStorage;
14
- initRequest?: (remult: Remult, origReq: GenericRequest) => Promise<void>;
15
- getUser?: (request: GenericRequest) => Promise<UserInfo>;
14
+ initRequest?: (remult: Remult, origReq: RequestType) => Promise<void>;
15
+ getUser?: (request: RequestType) => Promise<UserInfo>;
16
16
  initApi?: (remult: Remult) => void | Promise<void>;
17
17
  logApiEndPoints?: boolean;
18
18
  defaultGetLimit?: number;
19
19
  entities?: ClassType<any>[];
20
20
  controllers?: ClassType<any>[];
21
21
  rootPath?: string;
22
- };
23
- export declare function createRemultServer(options: RemultServerOptions): RemultServer;
22
+ }
23
+ export declare function createRemultServer<RequestType extends GenericRequest = GenericRequest>(options?: RemultServerOptions<RequestType>): RemultServer;
24
24
  export declare type GenericRequestHandler = (req: GenericRequest, res: GenericResponse, next: VoidFunction) => void;
25
25
  export interface ServerHandleResponse {
26
26
  data?: any;
@@ -4,10 +4,13 @@ import { DataApi, serializeError } from '../src/data-api';
4
4
  import { allEntities, Remult } from '../src/context';
5
5
  import { Entity, Fields, getEntityKey } from '../src/remult3';
6
6
  import { IdEntity } from '../src/id-entity';
7
+ ;
7
8
  export function createRemultServer(options) {
8
9
  if (!options) {
9
10
  options = {};
10
11
  }
12
+ if (options.logApiEndPoints === undefined)
13
+ options.logApiEndPoints = true;
11
14
  actionInfo.runningOnServer = true;
12
15
  if (options.defaultGetLimit) {
13
16
  DataApi.defaultGetLimit = options.defaultGetLimit;
@@ -112,7 +115,7 @@ class RemultServerImplementation {
112
115
  add(key, dataApiFactory, r) {
113
116
  let myRoute = this.options.rootPath + '/' + key;
114
117
  if (this.options.logApiEndPoints)
115
- console.log(myRoute);
118
+ console.log("[remult] " + myRoute);
116
119
  r.route(myRoute)
117
120
  .get(this.process((c, req, res) => dataApiFactory(c).httpGet(res, req))).put(this.process(async (c, req, res, orig) => dataApiFactory(c).put(res, '', orig.body)))
118
121
  .delete(this.process(async (c, req, res, orig) => dataApiFactory(c).delete(res, '')))
@@ -169,7 +172,7 @@ class RemultServerImplementation {
169
172
  })();
170
173
  this.backendMethodsOpenApi.push({ path: myUrl, allowed, tag });
171
174
  if (this.options.logApiEndPoints)
172
- console.log(myUrl);
175
+ console.log("[remult] " + myUrl);
173
176
  if (queue) {
174
177
  this.hasQueue = true;
175
178
  this.queue.mapQueuedAction(myUrl, what);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.14.35",
3
+ "version": "0.15.2",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "homepage": "https://remult.dev/",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/remult/remult"
11
+ "url": "https://github.com/remult/remult.git",
12
+ "directory": "projects/core"
12
13
  },
13
14
  "license": "MIT",
14
15
  "author": {
@@ -1,6 +1,6 @@
1
1
  import * as express from 'express';
2
2
  import { RemultServer, RemultServerOptions } from './server/expressBridge';
3
- export declare function remultExpress(options?: RemultServerOptions & {
3
+ export declare function remultExpress(options?: RemultServerOptions<express.Request> & {
4
4
  bodyParser?: boolean;
5
5
  bodySizeLimit?: string;
6
6
  }): express.RequestHandler & RemultServer;
@@ -1,3 +1,3 @@
1
- import type { FastifyPluginCallback } from 'fastify';
1
+ import type { FastifyPluginCallback, FastifyRequest } from 'fastify';
2
2
  import { RemultServer, RemultServerOptions } from './server/expressBridge';
3
- export declare function remultFastify(options: RemultServerOptions): FastifyPluginCallback & RemultServer;
3
+ export declare function remultFastify(options: RemultServerOptions<FastifyRequest>): FastifyPluginCallback & RemultServer;
package/remult-fresh.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RemultServerOptions, GenericRequest } from "./server/expressBridge";
2
2
  import { Remult } from "./src/context";
3
- export declare function remultFresh(options: RemultServerOptions, response: FreshResponse): RemultFresh;
3
+ export declare function remultFresh<RequestType extends GenericRequest>(options: RemultServerOptions<RequestType>, response: FreshResponse): RemultFresh;
4
4
  export interface RemultFresh {
5
5
  getRemult(req: GenericRequest): Promise<Remult>;
6
6
  openApiDoc(options: {
@@ -4,23 +4,23 @@ import { Remult, UserInfo } from '../src/context';
4
4
  import { ClassType } from '../classType';
5
5
  import { Repository } from '../src/remult3';
6
6
  import { IdEntity } from '../src/id-entity';
7
- export declare type RemultServerOptions = {
7
+ export interface RemultServerOptions<RequestType extends GenericRequest> {
8
8
  /** Sets a database connection for Remult.
9
9
  *
10
10
  * @see [Connecting to a Database](https://remult.dev/docs/databases.html).
11
11
  */
12
12
  dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>);
13
13
  queueStorage?: QueueStorage;
14
- initRequest?: (remult: Remult, origReq: GenericRequest) => Promise<void>;
15
- getUser?: (request: GenericRequest) => Promise<UserInfo>;
14
+ initRequest?: (remult: Remult, origReq: RequestType) => Promise<void>;
15
+ getUser?: (request: RequestType) => Promise<UserInfo>;
16
16
  initApi?: (remult: Remult) => void | Promise<void>;
17
17
  logApiEndPoints?: boolean;
18
18
  defaultGetLimit?: number;
19
19
  entities?: ClassType<any>[];
20
20
  controllers?: ClassType<any>[];
21
21
  rootPath?: string;
22
- };
23
- export declare function createRemultServer(options: RemultServerOptions): RemultServer;
22
+ }
23
+ export declare function createRemultServer<RequestType extends GenericRequest = GenericRequest>(options?: RemultServerOptions<RequestType>): RemultServer;
24
24
  export declare type GenericRequestHandler = (req: GenericRequest, res: GenericResponse, next: VoidFunction) => void;
25
25
  export interface ServerHandleResponse {
26
26
  data?: any;
@@ -7,11 +7,14 @@ var data_api_1 = require("../src/data-api");
7
7
  var context_1 = require("../src/context");
8
8
  var remult3_1 = require("../src/remult3");
9
9
  var id_entity_1 = require("../src/id-entity");
10
+ ;
10
11
  function createRemultServer(options) {
11
12
  var _this = this;
12
13
  if (!options) {
13
14
  options = {};
14
15
  }
16
+ if (options.logApiEndPoints === undefined)
17
+ options.logApiEndPoints = true;
15
18
  server_action_1.actionInfo.runningOnServer = true;
16
19
  if (options.defaultGetLimit) {
17
20
  data_api_1.DataApi.defaultGetLimit = options.defaultGetLimit;
@@ -162,7 +165,7 @@ var RemultServerImplementation = /** @class */ (function () {
162
165
  var _this = this;
163
166
  var myRoute = this.options.rootPath + '/' + key;
164
167
  if (this.options.logApiEndPoints)
165
- console.log(myRoute);
168
+ console.log("[remult] " + myRoute);
166
169
  r.route(myRoute)
167
170
  .get(this.process(function (c, req, res) {
168
171
  return dataApiFactory(c).httpGet(res, req);
@@ -265,7 +268,7 @@ var RemultServerImplementation = /** @class */ (function () {
265
268
  })();
266
269
  _this.backendMethodsOpenApi.push({ path: myUrl, allowed: allowed, tag: tag });
267
270
  if (_this.options.logApiEndPoints)
268
- console.log(myUrl);
271
+ console.log("[remult] " + myUrl);
269
272
  if (queue) {
270
273
  _this.hasQueue = true;
271
274
  _this.queue.mapQueuedAction(myUrl, what);