Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lewis-wow/ptsq-express-example
ptsq simple Express example
https://github.com/lewis-wow/ptsq-express-example
ptsq
Last synced: about 2 months ago
JSON representation
ptsq simple Express example
- Host: GitHub
- URL: https://github.com/lewis-wow/ptsq-express-example
- Owner: lewis-wow
- License: mit
- Created: 2023-10-30T17:39:56.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-19T13:50:20.000Z (about 1 year ago)
- Last Synced: 2024-05-15T15:29:22.114Z (8 months ago)
- Topics: ptsq
- Language: TypeScript
- Homepage: https://ptsq-docs.vercel.app/
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ptsq simple Express example
## ptsq docs
[https://ptsq-docs.vercel.app/](https://ptsq-docs.vercel.app/)
## Commands to run the example
### Start the ptsq server
```bash
npm run start:server
```### Start the proprietary client
```bash
npm run start:client
```### Generate the schema from the server for remote cliet
```bash
npm run schema:generate
```### Start the remote client
```bash
npm run start:remote-client
```## What is interesting
Take a good look at `client.ts` and `remote-client.ts` and compare the codes. They are almost identical.
Try to change the `server.ts` resolver like this.
```ts
const baseRouter = router({
greetings: resolver
.args(
z.object({
name: z.number(),
})
)
.query({
output: z.string(),
resolve: ({ input }) => {
return `Hello, ${input.name}`;
},
}),
});
```And take a good look at `client.ts`, Typescript should display a type error.
You can also then regenerate the schema for `remote-client.ts` to see the same error.
For see changes in runtime, you have to restart the `server.ts`, this example does not use something like `nodemon`.