Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added remaining Http Error codes #87

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
2894086
allow httpz feature to enable integration
oscartbeaumont Oct 2, 2022
18c44db
httpz endpoint_with_prefix + pull it from Git
oscartbeaumont Oct 2, 2022
3c3eae3
fix lambda feature
oscartbeaumont Oct 2, 2022
df5ac82
Cloudflare workers support
oscartbeaumont Oct 2, 2022
43adf14
make rspc wasm compatible when workers flag
oscartbeaumont Oct 2, 2022
0d343d5
enable httpz support for workers
oscartbeaumont Oct 2, 2022
e49ae97
allow no arg ctx function for workers
oscartbeaumont Oct 2, 2022
573f7d6
refactor layer futures and results
Brendonovich Oct 2, 2022
98e8ac0
remove StreamFuture enum
Brendonovich Oct 2, 2022
7cb60df
add arg to RequestResolver
Brendonovich Oct 3, 2022
06818c7
enforce closure in unbuilt builder
Brendonovich Oct 3, 2022
c6f4a9f
typed request future + builder wrapper
Brendonovich Oct 3, 2022
1660d83
procedure builder map
Brendonovich Oct 3, 2022
69598b3
added normi
oscartbeaumont Oct 3, 2022
86f5297
move specta crate
oscartbeaumont Oct 3, 2022
f64fd74
rspc global store + normi check for duplicate types
oscartbeaumont Oct 3, 2022
dbc0f37
normi: normalising subtypes
oscartbeaumont Oct 3, 2022
dcbeea6
rspc: move more API's into internal crate
oscartbeaumont Oct 4, 2022
1f6f8ce
docs: fix typos
oscartbeaumont Oct 6, 2022
08c19f5
more normi work + ResponseAndChannel for SD RN bridge
oscartbeaumont Oct 6, 2022
446c492
feat: completed create-rspc-app
VarunPotti Oct 7, 2022
7c3e145
fix: remove logs
VarunPotti Oct 7, 2022
52ead32
fix: error handling
VarunPotti Oct 7, 2022
06ab1da
fix: rename {{name}} in Cargo.toml for tauri projects
VarunPotti Oct 7, 2022
5e673a3
feat: check rust msrv
VarunPotti Oct 7, 2022
ad24566
general improvements to create-rspc-app
oscartbeaumont Oct 8, 2022
0a042ba
feat: remove styles from react templates
VarunPotti Oct 8, 2022
96827f6
upgrades and basic unit tests for create-rspc-app
oscartbeaumont Oct 9, 2022
b368ebf
move rspc frontend code into a `utils/rspc.ts` file
oscartbeaumont Oct 9, 2022
af4d54f
cra: update alerts
oscartbeaumont Oct 9, 2022
d26d0e9
cra: update cargo.toml + v0.0.1 release
oscartbeaumont Oct 9, 2022
b27bfd6
feat: setup ctrl+c handler and post_gen steps
VarunPotti Oct 10, 2022
a861145
feat: setup try_main and configure this_error
VarunPotti Oct 10, 2022
780d1db
fix: use user specified command for cargo post gen instead of fs ops
VarunPotti Oct 10, 2022
49b62f0
docs: update domain
oscartbeaumont Oct 10, 2022
3dbff82
[WIP] Fork tRPC into new rspc client
oscartbeaumont Oct 10, 2022
6e17bb7
[WIP] move tRPC client into main folder and enable all transports
oscartbeaumont Oct 10, 2022
ad9cca8
make `GlobalData` work with `t(...)` syntax
oscartbeaumont Oct 10, 2022
e11e19d
httpz upgrades & move extractor code into new file
oscartbeaumont Oct 11, 2022
13a6d56
Monkey patch minimal required functionality into client
oscartbeaumont Oct 13, 2022
4363c8f
commit disgusting code & populate normi cache
oscartbeaumont Oct 13, 2022
b41e4d7
hotfix for Spacedrive
oscartbeaumont Oct 13, 2022
1a0a568
Primitive OpenAPI plugin
oscartbeaumont Oct 15, 2022
0057f9e
[WIP] Specta support for OpenAPI
oscartbeaumont Oct 16, 2022
0fb3f7d
React hook factory + Normi rename __id to $id
oscartbeaumont Oct 17, 2022
c9e7161
GH Sponsors + GH Actions release to npm on each commit
oscartbeaumont Oct 17, 2022
3831938
Merge remote-tracking branch 'origin/main' into separate-layer-result
oscartbeaumont Oct 17, 2022
6460d59
Merge pull request #64 from oscartbeaumont/separate-layer-result
oscartbeaumont Oct 17, 2022
27fda75
fix typo + add crate feature docs
oscartbeaumont Oct 17, 2022
6b3a267
pass Typecheck
oscartbeaumont Oct 17, 2022
d6335ff
generate bindings in CI + fix types
oscartbeaumont Oct 17, 2022
f98ce02
upgrade workspace deps + use proper npm auth token
oscartbeaumont Oct 17, 2022
bf83bea
fix solid build
oscartbeaumont Oct 17, 2022
c811373
fix solid build config?
oscartbeaumont Oct 17, 2022
b3b88d6
fix npm publishing in CI?
oscartbeaumont Oct 17, 2022
2e02ebc
allow manually triggering CI
oscartbeaumont Oct 17, 2022
7080de7
npm cringe
oscartbeaumont Oct 17, 2022
7c0a67c
plz log me in
oscartbeaumont Oct 17, 2022
6210ab5
uhlc support
Brendonovich Oct 18, 2022
e716e01
add uhlc feature and docs
Brendonovich Oct 18, 2022
59327f2
fix specta uhlc feature
Brendonovich Oct 18, 2022
73d60f9
Merge pull request #74 from oscartbeaumont/uhlc
Brendonovich Oct 20, 2022
af7a451
fix: not being able to publish do to Cargo.tomls in templates
VarunPotti Nov 1, 2022
a7305f2
fix: call check_version()
VarunPotti Nov 1, 2022
80901a1
fix: tests
VarunPotti Nov 1, 2022
f8d5280
feat: add docs to create-rspc-app
VarunPotti Nov 2, 2022
6243b5b
process Tauri requests in their own tasks
oscartbeaumont Nov 4, 2022
8278e6f
significantly improve impl_tuple macro
oscartbeaumont Nov 7, 2022
418ef05
add ToDataType macro
Brendonovich Nov 8, 2022
33a5e50
checked enum flattening
Brendonovich Nov 9, 2022
377b5f0
Add rename_all support for enum named variants
Nov 9, 2022
24a6490
add bytesize + basic typed functions
oscartbeaumont Nov 9, 2022
1c3c2be
upgrade workspace deps
oscartbeaumont Nov 9, 2022
c46c500
ignore unflattenable enum variants when flattening
Brendonovich Nov 9, 2022
72f0ba8
update for ToDataType branch
Brendonovich Nov 10, 2022
67de2a1
fix enum tests
Brendonovich Nov 10, 2022
1a78f20
Merge pull request #80 from RadoslavK/features/add_rename_all_support…
Brendonovich Nov 10, 2022
25d947f
normi: server side normalisation
oscartbeaumont Nov 16, 2022
1441708
fix Tauri plugin + minor changes
oscartbeaumont Nov 16, 2022
ff2a445
Downgrade svgo to fix docs site
oscartbeaumont Nov 16, 2022
9b5b68d
skipLibCheck for docs site
oscartbeaumont Nov 16, 2022
d8f7ae9
Merge pull request #84 from oscartbeaumont/ToDataType
oscartbeaumont Nov 16, 2022
064e3ff
fix unix support + include version of cra cli in project
oscartbeaumont Nov 16, 2022
58fe9ed
Merge remote-tracking branch 'upstream/main'
oscartbeaumont Nov 16, 2022
cf35a48
specta: Remove collate_types
oscartbeaumont Nov 16, 2022
ab4ec20
specta: fix missing import for serde feature
oscartbeaumont Nov 16, 2022
6331b01
ToDataType container attribute rename + impl ToDataType for CommandDa…
oscartbeaumont Nov 16, 2022
0a257f6
fix specta import + throw error on nameless export
oscartbeaumont Nov 16, 2022
e1f1491
organise & document specta
oscartbeaumont Nov 17, 2022
3c007b3
add Cloudflare Workers error
oscartbeaumont Nov 17, 2022
cbd98e5
Errod codes
JK2Kgit Nov 21, 2022
76a7510
doc
JK2Kgit Nov 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [oscartbeaumont]
custom: ["https://paypal.me/oscartbeaumont"]
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
71 changes: 71 additions & 0 deletions .github/scripts/setPackageVersions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Updates the package.json files with a version to release to npm under
* the main tag.
*
* Based on https://github.com/facebook/relay/blob/main/gulpfile.js
*/

const fs = require("fs/promises");
const path = require("path");

const RELEASE_COMMIT_SHA = process.env.RELEASE_COMMIT_SHA;

if (RELEASE_COMMIT_SHA && RELEASE_COMMIT_SHA.length !== 40) {
throw new Error(
"If the RELEASE_COMMIT_SHA env variable is set, it should be set to the " +
"40 character git commit hash."
);
}

const VERSION = RELEASE_COMMIT_SHA
? `0.0.0-main-${RELEASE_COMMIT_SHA.substring(0, 8)}`
: process.env.npm_package_version;

console.log(RELEASE_COMMIT_SHA);

async function main() {
const packages = await (
await fs.readdir(path.join(__dirname, "../../packages"))
).filter((pkg) => pkg !== ".DS_Store" && pkg !== "tsconfig.json");
const pkgJsons = {};
const pkgJsonPaths = {};

for (pkg of packages) {
const pkgJsonPath = path.join(
__dirname,
"../../packages",
pkg,
"package.json"
);
pkgJsonPaths[pkg] = pkgJsonPath;
const packageJson = JSON.parse(await fs.readFile(pkgJsonPath, "utf8"));

pkgJsons[pkg] = packageJson;
}

const packageNames = Object.values(pkgJsons).map((pkg) => pkg.name);

for (const pkg of packages) {
let packageJson = pkgJsons[pkg];
packageJson.version = VERSION;
for (const depKind of [
"dependencies",
"devDependencies",
"peerDependencies",
]) {
const deps = packageJson[depKind];
for (const dep in deps) {
if (packageNames.includes(dep)) {
deps[dep] = VERSION;
}
}
}
await fs.writeFile(
pkgJsonPaths[pkg],
JSON.stringify(packageJson, null, 2) + "\n",
"utf8"
);
}
}

main();
72 changes: 72 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: [main]
paths:
- 'packages/**'
# tags:
# - '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [main]
paths:
- 'packages/**'
workflow_dispatch:

jobs:
build-publish:
name: Build and Publish to NPM
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'oscartbeaumont/rspc'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: pnpm/[email protected]
with:
version: latest

- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'pnpm'

- name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Generate test bindings
run: cargo test -p example tests::test_rspc_router -- --exact

- name: Typecheck
run: pnpm typecheck

- name: Build
run: pnpm build

- name: Configure main version
if: github.ref == 'refs/heads/main'
run: pnpm set-package-versions
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}

- name: Publish main to npm
if: github.ref == 'refs/heads/main'
run: pnpm publish -r ${TAG} --no-git-checks --filter "@rspc/*" --access public
env:
TAG: ${{ (github.ref == 'refs/heads/main' && '--tag=main') || '' }}
# NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Configure release version
# if: github.ref_type == 'tag'
# run: pnpm set-package-versions

# - name: Publish release to npm
# if: github.ref_type == 'tag'
# run: pnpm publish -r ${TAG} --no-git-checks --filter "@rspc/*" --access public
# env:
# TAG: ${{ (contains(github.ref_name, '-beta.') && '--tag=beta') || ''}}
# NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
target/
test-target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand All @@ -22,4 +23,7 @@ node_modules
/packages/*/dist

# Compiled vscode extension
*.vsix
*.vsix

# Trybuild
crates/*/wip
2 changes: 2 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[formatting]
column_width = 150
51 changes: 30 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rspc"
description = "A blazing fast and easy to use TRPC server for Rust."
description = "A blazingly fast and easy to use TRPC server for Rust."
version = "0.1.2"
authors = ["Oscar Beaumont <[email protected]>"]
edition = "2021"
Expand All @@ -15,16 +15,18 @@ categories = ["web-programming", "asynchronous"]
default = []
tauri = ["dep:tauri"]
tracing = ["dep:tracing"]
httpz = ["dep:httpz", "httpz/tokio-ws"]
# openapi = ["dep:openapiv3"]
httpz = ["dep:httpz", "httpz/cookies"]
openapi = ["dep:openapiv3", "dep:httpz", "dep:include_dir", "dep:mime_guess", "specta/openapi"]
# playground = []

# Webservers
axum = ["httpz/axum"]
# actix-web = ["httpz/actix-web"]
# Webservers # Axum feature basically always enabled because we use the extractors regardless of webserver
axum = ["httpz/axum", "httpz/tokio-ws", "httpz/axum"]
actix-web = ["httpz/actix-web", "httpz/tokio-ws", "httpz/axum"]
# poem = ["httpz/poem"]
# rocket = ["httpz/rocket"]
rocket = ["httpz/rocket", "httpz/tokio-ws", "httpz/axum"]
# warp = ["httpz/warp"]
lambda = ["httpz/lambda", "httpz/ws", "httpz/axum"]
workers = ["httpz/workers", "httpz/ws"]

# Specta
uuid = ["specta/uuid"]
Expand All @@ -37,27 +39,34 @@ ipnetwork = ["specta/ipnetwork"]
mac_address = ["specta/mac_address"]
bit-vec = ["specta/bit-vec"]
bson = ["specta/bson"]
uhlc = ["specta/uhlc"]

[dependencies]
specta = { version = "0.0.4", path = "./specta", features = ["serde"] }
httpz = { version = "0.0.3", optional = true }
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.85"
thiserror = "1.0.36"
futures = "0.3.24"
tokio = { version = "1.21.1", features = ["sync", "rt", "macros"] }
tauri = { version = "1.1.1", optional = true }
tracing = { version = "0.1.36", optional = true }
specta = { version = "0.0.4", path = "./crates/specta", features = ["serde"] }
httpz = { git = "https://github.com/oscartbeaumont/httpz.git", rev = "1ddbd9ad594ac7ee3e5b167afe689d1ce1228519", optional = true } # TODO: Move back to crates.io release
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.87"
thiserror = "1.0.37"
futures = "0.3.25"
tokio = { version = "1.21.2", features = ["sync", "rt", "macros"] }
tauri = { version = "1.2.0", optional = true }
tracing = { version = "0.1.37", optional = true }
async-stream = "0.3.3"
openapiv3 = { version = "1.0.1", optional = true }
include_dir = { version = "0.7.3", optional = true, features = ["metadata"] }
mime_guess = { version = "2.0.4", optional = true }
worker = { version = "0.0.11", optional = true }

[dev-dependencies]
async-stream = "0.3.3"

[workspace]
members = [
"./create-rspc-app",
"./examples",
"./examples/axum",
"./specta",
"./specta/macros"
"./crates/normi",
"./crates/normi/macros",
"./crates/specta",
"./crates/specta/macros",
"./create-rspc-app",
"./examples",
"./examples/axum",
]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<p align="center">🚧 Work in progress 🚧</p>
<div align="center">
<strong>
A blazing fast and easy to use TRPC-like server for Rust.
A blazingly fast and easy to use TRPC-like server for Rust.
</strong>
</div>
<a align="center" href="https://rspc.otbeaumont.me">
<a align="center" href="https://rspc.dev">
<p>Website</p>
</a>

Expand Down
26 changes: 26 additions & 0 deletions crates/normi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "normi"
description = "A normalised caching layer for rspc."
version = "0.0.1"
edition = "2021"

[features]
default = ["rspc"]
rspc = ["dep:rspc"]

[dependencies]
rspc = { path = "../../", optional = true }
normi-macros = { path = "./macros" }
serde = "1.0.147"
serde_json = "1.0.87"
specta = { version = "0.0.4", path = "../specta" }

[dev-dependencies]
rspc = { path = "../../", features = ["axum"] }
axum = "0.5.17"
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
tower-http = { version = "0.3.4", default-features = false, features = [
"cors",
] }
trybuild = "1.0.71"
assert-json-diff = "2.0.2"
Loading