# spark **Repository Path**: node-spark/spark ## Basic Information - **Project Name**: spark - **Description**: 游戏/应用服务器框架 - **Primary Language**: NodeJS - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-13 - **Last Updated**: 2022-06-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NODE-SPARK EN / [中文](https://node-spark.cn/docs/introduction.html) A TypeScript RPC framework with runtime type checking and binary serialization. Official site: https://node-spark.cn (English version is on the way) ## Features - Runtime type checking - Binary serialization - Pure TypeScript, without any decorater or other language - HTTP / WebSocket / and more protocols... - Optional backward-compatibility to JSON - High performance and reliable, verified by services over 100,000,000 users ## Create Full-stack Project ``` npx create-spark-app@latest ``` ## Usage ### Define Protocol (Shared) ```ts export interface ReqHello { name: string; } export interface ResHello { reply: string; } ``` ### Implement API (Server) ```ts import { ApiCall } from "spark"; export async function ApiHello(call: ApiCall) { call.succ({ reply: 'Hello, ' + call.req.name }); } ``` ### Call API (Client) ```ts let ret = await client.callApi('Hello', { name: 'World' }); ``` ## Examples https://github.com/k8w/spark-examples ## Serialization Algorithm The best TypeScript serialization algorithm ever. Without any 3rd-party IDL language (like protobuf), it is fully based on TypeScript source file. Define the protocols directly by your code. This is powered by [TSBuffer](https://github.com/tsbuffer), which is going to be open-source. TypeScript has the best type system, with some unique advanced features like union type, intersection type, mapped type, etc. TSBuffer may be the only serialization algorithm that support them all. ## API Reference See [API Reference](./docs/api/spark.md).