Socket
Socket
Sign inDemoInstall

remult

Package Overview
Dependencies
Maintainers
2
Versions
588
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remult - npm Package Compare versions

Comparing version 0.27.16 to 0.27.17

3

esm/server/remult-api-server.js

@@ -219,2 +219,3 @@ import { __decorate, __metadata } from "tslib";

}
r.route(this.options.rootPath + '/me').get(this.process(async (remult, req, res) => res.success(remult.user ?? null)));
if (this.options.subscriptionServer instanceof SseSubscriptionServer) {

@@ -336,3 +337,3 @@ const streamPath = this.options.rootPath + '/' + streamUrl;

finally {
remultStatic.asyncContext.setInInitRequest(false);
// remultStatic.asyncContext.setInInitRequest(false)
}

@@ -339,0 +340,0 @@ }

@@ -81,3 +81,3 @@ import { RestDataProviderHttpProviderUsingFetch } from './data-providers/rest-data-provider.js';

x.request &&
x.data)
x.data !== undefined)
//for axios

@@ -84,0 +84,0 @@ return x.data;

@@ -1,2 +0,2 @@

import { RestDataProvider } from './data-providers/rest-data-provider.js';
import { buildFullUrl, RestDataProvider, } from './data-providers/rest-data-provider.js';
import { LiveQueryClient } from './live-query/LiveQueryClient.js';

@@ -19,3 +19,3 @@ import { SseSubscriptionClient } from './live-query/SseSubscriptionClient.js';

else
throw new Error('remult object was requested outside of a valid context, try running it within initApi or a remult request cycle');
throw new Error('remult object was requested outside of a valid request cycle.valid context, try running `withRemult` or run within initApi or a remult request cycle');
};

@@ -80,2 +80,14 @@ }

user;
/**
* Fetches user information from the backend and updates the `remult.user` object.
* Typically used during application initialization and user authentication.
*
* @returns {Promise<UserInfo | undefined>} A promise that resolves to the user's information or `undefined` if unavailable.
*/
async initUser() {
const dp = buildRestDataProvider(this.apiClient.httpClient);
const data = await dp.get(buildFullUrl(this.apiClient.url, 'me'));
this.user = data ?? undefined;
return this.user;
}
/** Checks if a user was authenticated */

@@ -82,0 +94,0 @@ authenticated() {

@@ -13,6 +13,3 @@ import { UrlBuilder } from '../../urlBuilder.js';

return new RestEntityDataProvider(() => {
let url = this.apiProvider()?.url;
if (url === undefined || url === null)
url = '/api';
return url + '/' + entity.key;
return buildFullUrl(this.apiProvider()?.url, entity.key);
}, () => {

@@ -27,2 +24,7 @@ return buildRestDataProvider(this.apiProvider().httpClient);

}
export function buildFullUrl(httpClientUrl, entityKey) {
if (httpClientUrl === undefined || httpClientUrl === null)
httpClientUrl = '/api';
return httpClientUrl + '/' + entityKey;
}
//@internal

@@ -29,0 +31,0 @@ export function findOptionsToJson(options, meta) {

@@ -31,2 +31,5 @@ import { remultStatic } from './remult-static.js';

}
initUser() {
return remultStatic.remultFactory().initUser();
}
call(backendMethod, self, ...args) {

@@ -33,0 +36,0 @@ return remultStatic.remultFactory().call(backendMethod, self, ...args);

@@ -20,2 +20,41 @@ export const GroupByCountMember = '$count';

};
/*p1 - create-remult discussion
p1 - should we add to remult some init code that populates remult based on a built in server route for current user.
- yes, `remult.initUser` - the url will be /api/me
- ask to add a todo example
- admin question
- ask to add a user table + password hash
- changeOrigin false to vite config
- test angular with auth
- check nextauth if the env variable should be called NEXTAUTH_SECRET or just AUTH_SECRET
/** @type {import('next').NextConfig}
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["knex"],
},
};
export default nextConfig;
p1 - Landing page:
- p2 include the selections (react,vite, postgres,auth)
- include server is alive test (remind to run dev-node)
- include the authenticated user with links to sign in & sign out
- include link to admin
- include todo
p1 - README:
- the selections
- how to run dev
- which environment variables to set
- should we add admin? ensureSchema:false etc...
- should we read existing database?
- knex issue with next
*/
//p1 - add aggregate to query

@@ -22,0 +61,0 @@ //p1 - add parameter all to deleteMany, and updateMany

{
"name": "remult",
"version": "0.27.16",
"version": "0.27.17",
"description": "A CRUD framework for full-stack TypeScript",

@@ -5,0 +5,0 @@ "homepage": "https://remult.dev",

@@ -123,3 +123,3 @@ "use strict";

x.request &&
x.data)
x.data !== undefined)
//for axios

@@ -126,0 +126,0 @@ return x.data;

@@ -40,2 +40,9 @@ import type { ClassType } from '../classType.js';

user?: UserInfo;
/**
* Fetches user information from the backend and updates the `remult.user` object.
* Typically used during application initialization and user authentication.
*
* @returns {Promise<UserInfo | undefined>} A promise that resolves to the user's information or `undefined` if unavailable.
*/
initUser(): Promise<UserInfo | undefined>;
/** Checks if a user was authenticated */

@@ -42,0 +49,0 @@ authenticated(): boolean;

@@ -29,3 +29,3 @@ "use strict";

else
throw new Error('remult object was requested outside of a valid context, try running it within initApi or a remult request cycle');
throw new Error('remult object was requested outside of a valid request cycle.valid context, try running `withRemult` or run within initApi or a remult request cycle');
};

@@ -136,2 +136,24 @@ };

}
/**
* Fetches user information from the backend and updates the `remult.user` object.
* Typically used during application initialization and user authentication.
*
* @returns {Promise<UserInfo | undefined>} A promise that resolves to the user's information or `undefined` if unavailable.
*/
Remult.prototype.initUser = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var dp, data;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
dp = (0, buildRestDataProvider_js_1.buildRestDataProvider)(this.apiClient.httpClient);
return [4 /*yield*/, dp.get((0, rest_data_provider_js_1.buildFullUrl)(this.apiClient.url, 'me'))];
case 1:
data = _a.sent();
this.user = data !== null && data !== void 0 ? data : undefined;
return [2 /*return*/, this.user];
}
});
});
};
/** Checks if a user was authenticated */

@@ -138,0 +160,0 @@ Remult.prototype.authenticated = function () {

@@ -13,2 +13,3 @@ import type { DataProvider, EntityDataProvider, EntityDataProviderGroupByOptions, EntityDataProviderFindOptions, ProxyEntityDataProvider, RestDataProviderHttpProvider } from '../data-interfaces.js';

}
export declare function buildFullUrl(httpClientUrl: string | undefined, entityKey: string): string;
export declare class RestEntityDataProvider implements EntityDataProvider, ProxyEntityDataProvider {

@@ -15,0 +16,0 @@ private url;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.liveQueryAction = exports.RestDataProviderHttpProviderUsingFetch = exports.RestEntityDataProvider = exports.RestDataProvider = void 0;
exports.buildFullUrl = buildFullUrl;
exports.findOptionsToJson = findOptionsToJson;

@@ -22,6 +23,3 @@ exports.findOptionsFromJson = findOptionsFromJson;

var _a;
var url = (_a = _this.apiProvider()) === null || _a === void 0 ? void 0 : _a.url;
if (url === undefined || url === null)
url = '/api';
return url + '/' + entity.key;
return buildFullUrl((_a = _this.apiProvider()) === null || _a === void 0 ? void 0 : _a.url, entity.key);
}, function () {

@@ -41,2 +39,7 @@ return (0, buildRestDataProvider_js_1.buildRestDataProvider)(_this.apiProvider().httpClient);

exports.RestDataProvider = RestDataProvider;
function buildFullUrl(httpClientUrl, entityKey) {
if (httpClientUrl === undefined || httpClientUrl === null)
httpClientUrl = '/api';
return httpClientUrl + '/' + entityKey;
}
//@internal

@@ -43,0 +46,0 @@ function findOptionsToJson(options, meta) {

@@ -287,2 +287,5 @@ "use strict";

});
RemultProxy.prototype.initUser = function () {
return remult_static_js_1.remultStatic.remultFactory().initUser();
};
RemultProxy.prototype.call = function (backendMethod, self) {

@@ -289,0 +292,0 @@ var _a;

@@ -23,2 +23,41 @@ "use strict";

};
/*p1 - create-remult discussion
p1 - should we add to remult some init code that populates remult based on a built in server route for current user.
- yes, `remult.initUser` - the url will be /api/me
- ask to add a todo example
- admin question
- ask to add a user table + password hash
- changeOrigin false to vite config
- test angular with auth
- check nextauth if the env variable should be called NEXTAUTH_SECRET or just AUTH_SECRET
/** @type {import('next').NextConfig}
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["knex"],
},
};
export default nextConfig;
p1 - Landing page:
- p2 include the selections (react,vite, postgres,auth)
- include server is alive test (remind to run dev-node)
- include the authenticated user with links to sign in & sign out
- include link to admin
- include todo
p1 - README:
- the selections
- how to run dev
- which environment variables to set
- should we add admin? ensureSchema:false etc...
- should we read existing database?
- knex issue with next
*/
//p1 - add aggregate to query

@@ -25,0 +64,0 @@ //p1 - add parameter all to deleteMany, and updateMany

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc