Skip to content
プロジェクト

概要

好きな言語で独自のLoguxサーバーを構築したり、WebSocketとHTTPバックエンドの間にプロキシを作成したりできます。

Web・アプリ開発

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Logux Server

Logux is a new way to connect client and server. Instead of sending HTTP requests (e.g., AJAX and GraphQL) it synchronizes log of operations between client, server, and other clients.

This repository contains Logux server with:

  • Framework to write own server.
  • Proxy between WebSocket and HTTP server on any other language.

  Logux Server is built by Evil Martians, an American design and engineering consultancy for developer tools, AI, and cybersecurity startups.


Logux Server as Framework

import { isFirstOlder } from '@logux/core'
import { dirname } from 'path'
import { Server } from '@logux/server'

const server = new Server(
  Server.loadOptions(process, {
    subprotocol: 1,
    minSubprotocol: 1,
    root: import.meta.dirname
  })
)

server.auth(async ({ userId, token }) => {
  const user = await findUserByToken(token)
  return !!user && userId === user.id
})

server.channel('user/:id', {
  access(ctx, action, meta) {
    return ctx.params.id === ctx.userId
  },
  async load(ctx, action, meta) {
    const user = await db.loadUser(ctx.params.id)
    return { type: 'USER_NAME', name: user.name }
  }
})

server.type('CHANGE_NAME', {
  access(ctx, action, meta) {
    return action.user === ctx.userId
  },
  resend(ctx, action, meta) {
    return { channel: `user/${ctx.userId}` }
  },
  async process(ctx, action, meta) {
    if (isFirstOlder(lastNameChange(action.user), meta)) {
      await db.changeUserName({ id: action.user, name: action.name })
    }
  }
})

server.listen()

関連プロジェクトを探す

読み込み中…