Skip to content

Commit

Permalink
add starter-trpc
Browse files Browse the repository at this point in the history
  • Loading branch information
leovigna committed Nov 24, 2024
1 parent 27b16db commit 2a73229
Show file tree
Hide file tree
Showing 35 changed files with 1,234 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ ignores: [
"eslint-plugin-react-refresh",
"glob",
"dotenv",
"npm-run-all"
"npm-run-all",
"husky"
]
2 changes: 1 addition & 1 deletion .syncpackrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"prod",
"dev"
],
"pinVersion": "workspace:*"
"pinVersion": "^3.0.0"
}
],
"dependencyTypes": [
Expand Down
4 changes: 4 additions & 0 deletions packages/starter-trpc/.depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignores: [
"@types/node",
"vite"
]
11 changes: 11 additions & 0 deletions packages/starter-trpc/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yaml,yml,json}]
indent_size = 2
1 change: 1 addition & 0 deletions packages/starter-trpc/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/*
4 changes: 4 additions & 0 deletions packages/starter-trpc/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["@owlprotocol/eslint-config"],
};
10 changes: 10 additions & 0 deletions packages/starter-trpc/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"projects": {
"default": "demo-owlprotocol",
"staging": "owl-protocol-staging",
"production": "owl-protocol"
},
"targets": {},
"etags": {},
"dataconnectEmulatorConfig": {}
}
59 changes: 59 additions & 0 deletions packages/starter-trpc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.firebase

cache/

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# build outputs
.next/
out/
build
.build
.esbuild
dist
dist-ssr
lib
.serverless

# local deployments
packages/contracts/packages/owlprotocol-contracts/deployments/ganache/*

# misc
.DS_Store
*.pem
.idea

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
logs
*.log

# local env files
.env.local
.env.development
.env.test
.env.production
.env

# turbo
.turbo

# local
*.local

# ipfs
.ipfs
.datastore
.datastore_fs
.datastore_level
.datastore_s3
5 changes: 5 additions & 0 deletions packages/starter-trpc/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.+(js|jsx)": ["eslint --fix", "git add"],
"*.+(ts|tsx)": ["eslint --fix", "git add"],
"*.+(json|css|md)": ["prettier --write", "git add"]
}
3 changes: 3 additions & 0 deletions packages/starter-trpc/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require("@owlprotocol/prettier-config"),
};
7 changes: 7 additions & 0 deletions packages/starter-trpc/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Owl Protocol

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, libribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions packages/starter-trpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# TRPC Starter

## Start

Example requests

```bash
npm run dev #Start server

# Query Procedure
curl localhost:3000/api/hello #OpenAPI Call
curl localhost:3000/api/trpc/hello #TRPC Call

# Mutation Procedure
curl localhost:3000/api/auth -d "" -H "x-api-key: test" #OpenAPI Call
curl localhost:3000/api/trpc/auth -d "" -H "Content-Type: application/json" -H "x-api-key: test" #TRPC Call
```
9 changes: 9 additions & 0 deletions packages/starter-trpc/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { buildLibESM, cjsBundleConfig, buildDistCJS } from "@owlprotocol/esbuild-config";

cjsBundleConfig.entryPoints = ["src/runtimes/firebase.ts"];
cjsBundleConfig.outfile = "dist/index.js";
cjsBundleConfig.plugins = [];
cjsBundleConfig.platform = "node";
cjsBundleConfig.external = [...cjsBundleConfig.external, "firebase-admin", "firebase-functions"];

await Promise.all([buildLibESM(), buildDistCJS()]);
48 changes: 48 additions & 0 deletions packages/starter-trpc/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"functions": [
{
"source": "dist",
"codebase": "default",
"ignore": ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"]
}
],
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"function": {
"functionId": "base",
"region": "europe-west3"
}
}
]
},
"emulators": {
"auth": {
"enabled": false,
"port": 9099
},
"firestore": {
"enabled": false,
"port": 18080
},
"storage": {
"enabled": false,
"port": 9199
},
"functions": {
"enabled": true,
"port": 5001
},
"hosting": {
"enabled": true,
"port": 5000
},
"ui": {
"enabled": true,
"port": 4000
},
"singleProjectMode": true
}
}
33 changes: 33 additions & 0 deletions packages/starter-trpc/package.firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@owlprotocol/starter-trpc",
"version": "0.0.0",
"keywords": ["firebase"],
"private": true,
"type": "commonjs",
"homepage": "https://github.com/owlprotocol/workspace-public",
"repository": {
"type": "git",
"url": "https://github.com/owlprotocol/workspace-public.git"
},
"copyright": "Copyright 2024 Leo Vigna",
"license": "MIT",
"author": {
"name": "Leo Vigna",
"email": "[email protected]",
"url": "https://github.com/leovigna"
},
"files": ["dist/*", "lib/*", "src/*", "LICENSE", "README.md"],
"main": "./index.js",
"dependencies": {
"firebase-admin": "^12.1.0",
"firebase-functions": "^5.0.0"
},
"bugs": {
"url": "https://github.com/leovigna/owlprotocol/issues",
"email": "[email protected]"
},
"funding": "https://github.com/leovigna/owlprotocol",
"engines": {
"node": "18"
}
}
120 changes: 120 additions & 0 deletions packages/starter-trpc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"name": "@owlprotocol/starter-trpc",
"version": "3.0.0",
"keywords": [
"web3",
"solidity",
"trpc",
"react-query"
],
"private": true,
"type": "module",
"homepage": "https://github.com/owlprotocol/workspace-public",
"repository": {
"type": "git",
"url": "https://github.com/owlprotocol/workspace-public.git"
},
"copyright": "Copyright 2024 Owl Protocol",
"license": "MIT",
"author": {
"name": "Leo Vigna",
"email": "[email protected]",
"url": "https://github.com/leovigna"
},
"files": [
"dist/*",
"lib/*",
"src/*",
"LICENSE",
"README.md"
],
"main": "./lib/cjs/index.cjs",
"module": "./lib/esm/index.mjs",
"types": "./lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js"
},
"./client": {
"types": "./lib/types/client/client.d.ts",
"require": "./lib/cjs/client/client.js",
"import": "./lib/esm/client/client.js"
},
"./react-query": {
"types": "./lib/types/client/react.d.ts",
"require": "./lib/cjs/client/react.js",
"import": "./lib/esm/client/react.js"
}
},
"scripts": {
"build": "npm-run-all -p tsc esbuild build:files",
"build:watch": "npm run build:files && npm-run-all -p tsc:watch esbuild:watch",
"build:files": "mkdir -p dist && cp package.firebase.json dist/package.json && cp .gitignore dist/",
"clean": "rimraf lib dist",
"depcheck": "depcheck",
"dev": "npm run dev:express",
"dev:express": "tsx watch src/runtimes/express.ts",
"dev:firebase": "npm-run-all -p build:watch firebase-emulator",
"deploy:firebase": "npm run build && firebase deploy --only functions,hosting",
"esbuild": "node esbuild.config.mjs",
"esbuild:watch": "ESBUILD_WATCH=true node esbuild.config.mjs",
"firebase-emulator": "firebase emulators:start --project demo-owlprotocol --debug",
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "eslint --fix 'src/**/*.ts'",
"lint:staged": "lint-staged",
"madge": "madge src/index.ts -c",
"start": "node lib/esm/runtimes/express.js",
"test": "pnpm run test:ci",
"test:ci": "vitest --run",
"test:watch": "vitest",
"tsc": "tsc",
"tsc:trace": "tsc --generateTrace lib/trace && analyze-trace lib/trace",
"tsc:watch": "tsc -w"
},
"dependencies": {
"@trpc/client": "11.0.0-next-beta.308",
"@trpc/server": "11.0.0-next-beta.308",
"firebase-admin": "^12.1.0",
"firebase-functions": "^5.0.0",
"express": "^4.18.2",
"trpc-openapi": "^1.2.0",
"zod": "3.22.4"
},
"peerDependencies": {
"@tanstack/react-query": "5.24.8",
"@trpc/react-query": "11.0.0-next-beta.308",
"cross-fetch": "^4.0.0"
},
"devDependencies": {
"@owlprotocol/esbuild-config": "^3.0.0",
"@owlprotocol/eslint-config": "^3.0.0",
"@owlprotocol/prettier-config": "^3.0.0",
"@owlprotocol/tsconfig": "^3.0.0",
"@tanstack/react-query": "5.24.8",
"@trpc/react-query": "11.0.0-next-beta.308",
"@types/express": "^4.17.16",
"@types/node": "^20.11.10",
"@typescript/analyze-trace": "^0.10.1",
"firebase-tools": "^13.16.0",
"lint-staged": "^11.2.6",
"madge": "^5.0.2",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"tsx": "^4.11.0",
"typescript": "5.4.5",
"vite": "^5.1.6",
"vitest": "^1.4.0",
"cross-fetch": "^4.0.0",
"depcheck": "^1.4.7"
},
"bugs": {
"url": "https://github.com/owlprotocol/workspace-public/issues",
"email": "[email protected]"
},
"funding": "https://owlprotocol.xyz",
"engines": {
"node": "^18.0.0"
}
}
1 change: 1 addition & 0 deletions packages/starter-trpc/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please go to /api/hello
Loading

0 comments on commit 2a73229

Please sign in to comment.