Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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`.