🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

xray-zod

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xray-zod

xray configuration with zod schema

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
16
-30.43%
Maintainers
1
Weekly downloads
 
Created
Source

xray-zod

xray-zod is a TypeScript library designed to validate and parse XRAY configuration using the zod library. It provides type definitions and validation schemas based on the official ProjectX documentation.

Installation

To install xray-zod, run:

npm install zod xray-zod

Usage

Parsing and Validating XRAY Config

To parse and validate your XRAY configuration, use the ConfigObject:

import { ConfigObject } from 'xray-zod';

try {
    const config = {};
    ConfigObject.parse(config);
} catch (err) {
    // handle error
}

Type Definitions

You can also use the types defined in xray-zod for type safety:

import type * as Xray from 'xray-zod';

const log_config: Xray.LogObject = {
    loglevel: 'info',
    access: './access.log',
};

const api_config: Xray.ApiObject = {
    services: ['LoggerService', 'StatsService'],
    tag: 'api',
};

// Example configuration object
const config: Xray.ConfigObject = {
    log: log_config,
    api: api_config,
    inbounds: [
        {
            listen: '127.0.0.1',
            port: 62789,
            protocol: 'dokodemo-door',
            settings: {
                address: '127.0.0.1',
            },
            tag: 'api',
        },
    ],
    outbounds: [
        {
            protocol: 'freedom',
            settings: {},
            tag: 'direct',
        },
        {
            protocol: 'blackhole',
            settings: {},
            tag: 'blocked',
        },
    ],
    routing: {
        rules: [
            {
                inboundTag: ['api'],
                outboundTag: 'api',
                type: 'field',
            },
        ],
    },
    stats: {},
};

For more information, refer to the official ProjectX documentation:
ProjectX Documentation

FAQs

Package last updated on 08 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts