Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@based/server

Package Overview
Dependencies
Maintainers
7
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/server - npm Package Compare versions

Comparing version 7.0.2 to 7.1.0-alpha

2

dist/authorize.js
import { sendError } from './sendError.js';
import { BasedErrorCode } from './error/index.js';
import { BasedErrorCode } from '@based/errors';
import { isBasedRoute, } from '@based/functions';

@@ -4,0 +4,0 @@ import { installFn } from './installFn.js';

import { valueToBuffer, encodeChannelMessage, encodeErrorResponse, } from '../protocol.js';
import { BasedErrorCode, createError } from '../error/index.js';
import { createError } from '../error/index.js';
import { isBasedFunctionConfig } from '@based/functions';
import { BasedErrorCode } from '@based/errors';
const updateChannelListener = (server, channel, msg) => {

@@ -5,0 +6,0 @@ if (channel.clients.size) {

import { BasedServer } from '../server.js';
import { Context } from '@based/functions';
import { BasedErrorCode, ErrorPayload, BasedErrorData } from './types.js';
export * from './types.js';
export declare function createErrorData<T extends BasedErrorCode>(code: T, payload: ErrorPayload[T]): {
code: T;
statusCode: number;
statusMessage: string;
message: string;
route: {
name: string;
path: string;
type: "function" | "channel" | "query" | "stream" | "app" | "job";
};
};
import { BasedErrorCode, ErrorPayload, BasedErrorData } from '@based/errors';
export declare function createError<T extends BasedErrorCode>(server: BasedServer, context: Context, code: T, payload: ErrorPayload[T]): BasedErrorData<T>;

@@ -1,26 +0,3 @@

import { isAnyBasedRoute } from '@based/functions';
import { EMPTY_ROUTE, } from './types.js';
import { errorTypeHandlers } from './errorTypeHandlers.js';
export * from './types.js';
export function createErrorData(code, payload) {
const type = errorTypeHandlers[code];
const route = !payload
? EMPTY_ROUTE
: isAnyBasedRoute(payload)
? payload
: 'route' in payload
? payload.route
: EMPTY_ROUTE;
return {
code,
statusCode: type.statusCode,
statusMessage: type.statusMessage,
message: type.message(payload),
route: {
name: route.name,
path: route.path,
type: route.type,
},
};
}
import { createErrorData, } from '@based/errors';
// export * from './types.js'
export function createError(server, context, code, payload) {

@@ -27,0 +4,0 @@ const errorData = createErrorData(code, payload);

@@ -1,4 +0,5 @@

import { BasedErrorCode, createError } from '../error/index.js';
import { createError } from '../error/index.js';
import { verifyRoute } from '../verifyRoute.js';
import { installFn } from '../installFn.js';
import { BasedErrorCode } from '@based/errors';
export const callFunction = async (server, name, ctx, payload) => {

@@ -5,0 +6,0 @@ const route = verifyRoute(server, server.client.ctx, 'function', server.functions.route(name), name);

import { verifyRoute } from '../verifyRoute.js';
import { unsubscribeFunction, subscribeChannelFunction, hasChannel, createChannel, } from '../channel/index.js';
import { installFn } from '../installFn.js';
import { createError, BasedErrorCode } from '../error/index.js';
import { createError, } from '../error/index.js';
import { BasedErrorCode } from '@based/errors';
export const subscribeChannel = (server, name, id, payload, update) => {

@@ -6,0 +7,0 @@ const route = verifyRoute(server, server.client.ctx, 'channel', server.functions.route(name), name, id);

@@ -1,5 +0,6 @@

import { BasedErrorCode, createError } from '../error/index.js';
import { createError, } from '../error/index.js';
import { genObservableId, hasObs, createObs, subscribeNext, getObsAndStopRemove, destroyObs, start, } from '../query/index.js';
import { verifyRoute } from '../verifyRoute.js';
import { installFn } from '../installFn.js';
import { BasedErrorCode } from '@based/errors';
const getObsData = (resolve, reject, server, id, ctx, route) => {

@@ -6,0 +7,0 @@ const obs = getObsAndStopRemove(server, id);

@@ -1,5 +0,6 @@

import { BasedErrorCode, createError } from '../error/index.js';
import { createError } from '../error/index.js';
import { verifyRoute } from '../verifyRoute.js';
import { genObservableId, hasObs, createObs, subscribeFunction, unsubscribeFunction, } from '../query/index.js';
import { installFn } from '../installFn.js';
import { BasedErrorCode } from '@based/errors';
export const observe = (server, name, ctx, payload, update, error) => {

@@ -6,0 +7,0 @@ const id = genObservableId(name, payload);

import { verifyRoute } from '../verifyRoute.js';
import { installFn } from '../installFn.js';
import { BasedErrorCode, createError } from '../error/index.js';
import { createError } from '../error/index.js';
import { BasedErrorCode } from '@based/errors';
export const publish = (server, name, ctx, id, payload, msg) => {

@@ -5,0 +6,0 @@ const route = verifyRoute(server, server.client.ctx, 'channel', server.functions.route(name), name);

@@ -1,5 +0,6 @@

import { BasedErrorCode, createError } from '../error/index.js';
import { createError } from '../error/index.js';
import { BasedDataStream, isStreamFunctionOpts, } from '@based/functions';
import { verifyRoute } from '../verifyRoute.js';
import { installFn } from '../installFn.js';
import { BasedErrorCode } from '@based/errors';
const wrapStream = (stream, size) => {

@@ -6,0 +7,0 @@ if (stream instanceof BasedDataStream) {

@@ -46,3 +46,3 @@ import { isBasedFunctionConfig, } from '@based/functions';

this.config.closeAfterIdleTime = {
query: 3e3,
query: 3e3, // 3 seconds - get it higher e.g 20 seconds / and cache size
channel: 60e3, // 3 1 Min

@@ -49,0 +49,0 @@ };

import { sendHttpResponse } from '../../sendHttpResponse.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -4,0 +4,0 @@ export const httpFunction = async (route, spec, server, ctx, payload) => {

@@ -5,3 +5,3 @@ import { isBasedRoute } from '@based/functions';

import { httpGet } from './query.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -8,0 +8,0 @@ import { blockIncomingRequest, rateLimitRequest, endRateLimitHttp, } from '../../security.js';

import { sendHttpResponse } from '../../sendHttpResponse.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -4,0 +4,0 @@ import { installFn } from '../../installFn.js';

@@ -5,3 +5,3 @@ import { end, sendHeaders } from '../../sendHttpResponse.js';

import zlib from 'node:zlib';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -8,0 +8,0 @@ import { promisify } from 'node:util';

import zlib from 'node:zlib';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';
import querystring from 'node:querystring';
const decoder = new TextDecoder('utf-8');

@@ -29,3 +30,14 @@ const MAX_CHUNK_SIZE = 1024 * 1024;

return decoder.decode(data);
// } else if (contentType === 'multipart/form-data') {
}
else if (contentType === 'application/x-www-form-urlencoded') {
const str = decoder.decode(data);
try {
const parsedData = { ...querystring.parse(str) };
return parsedData;
}
catch (error) {
return str;
}
}
else {

@@ -32,0 +44,0 @@ return data;

import { sendError } from '../../../sendError.js';
import { BasedErrorCode } from '../../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { multiPart } from './multiPart/index.js';

@@ -4,0 +4,0 @@ import { singleStream } from './stream/index.js';

import { installFn } from '../../../../installFn.js';
import readFormData from './readFormData.js';
import { BasedErrorCode, createErrorData, } from '../../../../error/index.js';
import { BasedErrorCode, createErrorData, } from '@based/errors';
import { sendHttpResponse } from '../../../../sendHttpResponse.js';

@@ -5,0 +5,0 @@ const handleFile = async (server, ctx, installedFn, file, route) => {

import { BasedDataStream, } from '@based/functions';
import { BasedErrorCode } from '../../../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../../../sendError.js';

@@ -4,0 +4,0 @@ import getExtension from '../getExtension.js';

import { BasedDataStream, } from '@based/functions';
import { sendError } from '../../../../sendError.js';
import zlib from 'node:zlib';
import { BasedErrorCode } from '../../../../error/index.js';
import { BasedErrorCode } from '@based/errors';
const MAX_CHUNK_SIZE = 1024 * 1024 * 5;

@@ -6,0 +6,0 @@ const UNCOMPRESS_OPTS = {

import createDataStream from './createStream.js';
import { sendError } from '../../../../sendError.js';
import getExtension from '../getExtension.js';
import { BasedErrorCode } from '../../../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendHttpResponse } from '../../../../sendHttpResponse.js';

@@ -6,0 +6,0 @@ import mimeTypes from 'mime-types';

@@ -30,3 +30,3 @@ import uws from '@based/uws';

app.ws('/*', {
maxPayloadLength: 1024 * 1024 * 30,
maxPayloadLength: 1024 * 1024 * 30, // 20 mb max payload
idleTimeout: 100,

@@ -33,0 +33,0 @@ maxBackpressure: wsOptions.maxBackpressureSize,

@@ -7,3 +7,3 @@ import { readUint8, decodePayload, parsePayload } from '../../protocol.js';

import { sendError } from '../../sendError.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
const publish = (route, spec, server, ctx, payload, id) => {

@@ -10,0 +10,0 @@ const channel = server.activeChannelsById.get(id);

import { readUint8, decodeName, decodePayload, parsePayload, } from '../../protocol.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -4,0 +4,0 @@ import { rateLimitRequest } from '../../security.js';

import { readUint8, decodeName, decodePayload, encodeFunctionResponse, valueToBuffer, parsePayload, } from '../../protocol.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -4,0 +4,0 @@ import { rateLimitRequest } from '../../security.js';

import { decodePayload, decodeName, readUint8, encodeGetResponse, parsePayload, } from '../../protocol.js';
import { createObs, destroyObs, subscribeNext, getObsAndStopRemove, hasObs, start, sendObsWs, sendObsGetError, } from '../../query/index.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -5,0 +5,0 @@ import { rateLimitRequest } from '../../security.js';

@@ -6,5 +6,6 @@ import { decodeHeader, readUint8 } from '../../protocol.js';

import { getMessage } from './get.js';
import { BasedErrorCode, createError } from '../../error/index.js';
import { createError } from '../../error/index.js';
import { channelSubscribeMessage, unsubscribeChannelMessage, } from './channelSubscribe.js';
import { channelPublishMessage } from './channelPublish.js';
import { BasedErrorCode } from '@based/errors';
const reader = (server, ctx, arr, start) => {

@@ -11,0 +12,0 @@ const { len, isDeflate, type } = decodeHeader(readUint8(arr, start, 4));

import { decodePayload, decodeName, readUint8, parsePayload, } from '../../protocol.js';
import { createObs, unsubscribeWs, subscribeWs, hasObs, } from '../../query/index.js';
import { BasedErrorCode } from '../../error/index.js';
import { BasedErrorCode } from '@based/errors';
import { sendError } from '../../sendError.js';

@@ -5,0 +5,0 @@ import { rateLimitRequest } from '../../security.js';

import { isClientContext, isBasedFunctionConfig, } from '@based/functions';
import { sendSimpleError } from './sendError.js';
import { BasedErrorCode } from './error/index.js';
import { BasedErrorCode } from '@based/errors';
const functionNotFound = (server, ctx, route, _type, id) => {

@@ -5,0 +5,0 @@ if (!isClientContext(ctx)) {

@@ -1,3 +0,4 @@

import { createError, BasedErrorCode } from '../../error/index.js';
import { createError } from '../../error/index.js';
import { encodeErrorResponse, valueToBuffer } from '../../protocol.js';
import { BasedErrorCode } from '@based/errors';
export const errorListener = (server, obs, err) => {

@@ -4,0 +5,0 @@ delete obs.cache;

import { BasedServer } from '../server.js';
import { ActiveObservable, ObservableUpdateFunction } from './types.js';
import { BasedErrorCode, BasedErrorData } from '../error/index.js';
import { BasedErrorCode, BasedErrorData } from '@based/errors';
import { WebSocketSession, Context } from '@based/functions';

@@ -5,0 +5,0 @@ export declare const subscribeWs: (server: BasedServer, id: number, checksum: number, ctx: Context<WebSocketSession>) => void;

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

import { BasedErrorCode, BasedErrorData } from '../error/index.js';
import { BasedErrorCode, BasedErrorData } from '@based/errors';
export type ObservableError = BasedErrorData<BasedErrorCode.FunctionError> | BasedErrorData<BasedErrorCode.FunctionIsWrongType> | BasedErrorData<BasedErrorCode.FunctionNotFound>;

@@ -3,0 +3,0 @@ export type ObservableUpdateFunction = (data: any, checksum?: number, err?: null | ObservableError, cache?: Uint8Array, diff?: any, fromChecksum?: number, isDeflate?: boolean) => void;

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

import { BasedErrorCode } from './error/index.js';
import { BasedErrorCode } from '@based/errors';
var IsBlocked;

@@ -3,0 +3,0 @@ (function (IsBlocked) {

import { BasedServer } from './server.js';
import { HttpSession, WebSocketSession, Context, BasedRoute } from '@based/functions';
import { BasedErrorCode, ErrorPayload, BasedErrorData } from './error/index.js';
import { BasedErrorCode, BasedErrorData, ErrorPayload } from '@based/errors';
export declare function sendHttpError<T extends BasedErrorCode>(server: BasedServer, ctx: Context<HttpSession>, basedCode: T, payload: ErrorPayload[T]): void;

@@ -5,0 +5,0 @@ export declare function sendErrorData(ctx: Context<WebSocketSession | HttpSession>, errorData: BasedErrorData): void;

@@ -8,3 +8,3 @@ /// <reference types="node" resolution-mode="require"/>

import { BasedAuth, AuthConfig } from './auth/index.js';
import { BasedErrorCode, BasedErrorData } from './error/index.js';
import { BasedErrorCode, BasedErrorData } from '@based/errors';
import { BasedFunctionClient as BasedServerFunctionClient } from './functionApi/index.js';

@@ -11,0 +11,0 @@ import { ActiveChannel } from './channel/index.js';

import { isClientContext, isBasedRoute, } from '@based/functions';
import { sendSimpleError } from './sendError.js';
import { BasedErrorCode, createError } from './error/index.js';
import { createError } from './error/index.js';
import { BasedErrorCode } from '@based/errors';
export const verifyRoute = (server, ctx = server.client.ctx, type, route, name, id) => {

@@ -5,0 +6,0 @@ if (!ctx.session) {

{
"name": "@based/server",
"version": "7.0.2",
"version": "7.1.0-alpha",
"license": "MIT",

@@ -27,8 +27,7 @@ "main": "./dist/index.js",

"mime-types": "^2.1.31",
"@based/functions": "^3.0.0"
"@based/functions": "^3.0.0",
"@based/errors": "^1.0.0"
},
"devDependencies": {
"@types/mime-types": "2.1.1",
"@saulx/tsconfig": "^1.0.5",
"@saulx/prettier-config": "^1.0.0",
"typescript": "^5.2.2",

@@ -35,0 +34,0 @@ "rimraf": "^3.0.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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