Coder Social home page Coder Social logo

rivet-gg / opengb Goto Github PK

View Code? Open in Web Editor NEW
45.0 1.0 2.0 5.29 MB

Open Game Backend: Open-source modular backend for all games and tools.

Home Page: https://opengb.dev

License: Apache License 2.0

TypeScript 100.00%
backend backend-as-a-service game game-backend multiplayer game-development

opengb's People

Contributors

abcxff avatar blckbrry-pi avatar masterptato avatar nathanflurry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

urbanonymous

opengb's Issues

Document recommendations for schemas

  • Use UUIDs for indexes (and why)
  • Use camel case for keys
  • Never delete values
  • Manually altering migrations as needed to add constraints
  • Recommended types (dates, uuid, integer, floats, etc)

Research bi-directional streaming

Need to figure out how (and if) this works with OpenAPI

Need to figure out the easiest x-platform solution

Can we support multiple protocols?

Prior art:

  • Rivet uses blocking requests for server side events
  • SSE work, but have limitations on number of concurrent streams
  • WS works, but requires extra libraries that are usually finicky on non-web platforms
  • gRPC requires protobuf and has a weird handler requirement for WebSockets. Raw TCP will not play nice on edge functions & most load balancers.
  • tRPC is a joke

Migrate JSON schema -> zod

This will read the types from the parameters on the run config on the fly

Make sure to validate UUIDs

removes ajv

Type Bindings

ctx.modules.<module_name>.<script_name>({}) should be type safe, awaitable, and not be overloaded by typescript resolve times

Figure out how to cleanly re-export Prisma namespace

We currently export prisma (which holds the types) and Prisma (which holds the utility functions).

To reference a type, you need to use primsa.Prisma.XXXXGetPayload while to use a utility function, you need to use Prisma.xxxx.

Ideally it's just Prisma for both types and utils

Prisma leaks timeout in test

Run a test with deno test --trace-ops and disable sanitizeOps in Runtime.test to see the issue:

    at op_sleep (ext:core/00_infra.js:265:13)
    at runAfterTimeout (ext:deno_web/02_timers.js:234:20)
    at initializeTimer (ext:deno_web/02_timers.js:192:3)
    at setTimeout (ext:deno_web/02_timers.js:336:10)
    at pm (file:///Users/nathan/rivet/ogs/dist/prisma/friends/esm.js:7264:14)
    at <anonymous> (wasm://wasm/00952342:1:2131297)
    at <anonymous> (wasm://wasm/00952342:1:2153871)
    at am (file:///Users/nathan/rivet/ogs/dist/prisma/friends/esm.js:7183:9)
    at n (file:///Users/nathan/rivet/ogs/dist/prisma/friends/esm.js:7252:20)
    at new Promise (<anonymous>)

Sanitize ops is disabled until this can be fixed.

Allow serving scripts with raw HTTP request/response on API endpoint

Required for hosting API endpoints.

The default module calling API is meant to be an easy way to call modules that covers use cases where you control the code that calls the server, not as a complete HTTP req/res interface.

The module.yaml would look something like this:

scripts:
  apiEndpoint:
    api:
      methods: [GET]
      pathRegexp: /api/my-module/webhook

The code would look something like this:

import { HttpRequest, HttpResponse } from "@ogs/runtime"

export interface Request extends HttpRequest {}

export interface Response extends HttpResponse {}

export function handler(ctx, req) {
  let body = JSON.parse(req.body);
  return { body: `hello ${body.foo}`, headers: { "content-type": "application/json" } };
}

Write SQL 101 for games

  • Locking rows (inventory example)
  • Unlogged tables for real time data
  • Access logs & point in time recovery
  • Other extensions?

Add `dependencies` to modules to restrict what it can call

If a module calls other modules, list which dependencies it calls in the module.yaml.

Developers will only be able to call the explicit dependencies from ModuleContext (and its subclasses).

This is intended to just be a name, not a reference to a specific registry + module like NPM.

Eventually: dependencies will be able to be remapped (i.e. if I have a fork of the "users" module).

Fix dependency of OGSE on generated registry.d.ts

This PR includes dependencies on @ogs/helpers/registry.d.ts in the engine itself. This file is generated and cannot be referenced from within the engine. The Registry generic must be passed to the types that use it directly instead of importing it from within the engine.

#51

Explore creating shared Prisma core runtime & WASM

We serve multiple Prisma instances, but they share the same library and WASM. Explore making them all import the same runtime to safe both (a) binary size and (b) memory usage.

This will require some finessing of the imports.

This may become essential if we get close to going over the 10 MB limit for Cloudflare Workers.

Type-safe module calling on ctx

Example: ctx.users.get({ โ€ฆ })

This should only make the listed dependencies available in the given context. If using a context that's not ModuleContext, then all modules are available. Should be easy to do using a Partial.

Any module names that conflict with the core types (e.g. db) will be renamed with an underscore. e.g. calling the db module looks like ctx._db.doSomething({})

This needs to have a type-safe req/res format. This will require generating types in the runtime_config.ts file.

Add module configs

  • Get JSON Schema from config.ts
  • Validate config
  • Pass to module context
  • Pass to runtime entrypoint

Autogenerate script context type

This will include:

  • (Later) all errors for the module
  • (Later) the Drizzle schema
  • (Later) schema for all other modules in the project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.