当前位置: 首页 > news >正文

重庆有专业做网站的吗长春seo优化企业网络跃升

重庆有专业做网站的吗,长春seo优化企业网络跃升,软件定制开发方案模板,it外包公司值得去吗tRPC (Type-safe Remote Procedure Call) 是一个用于构建类型安全的 API 的框架,它能够在前端和后端之间共享类型,确保类型安全性。这对于使用 TypeScript 的项目特别有用,因为它消除了前后端类型不一致的问题,提高了开发效率和代…

tRPC (Type-safe Remote Procedure Call) 是一个用于构建类型安全的 API 的框架,它能够在前端和后端之间共享类型,确保类型安全性。这对于使用 TypeScript 的项目特别有用,因为它消除了前后端类型不一致的问题,提高了开发效率和代码质量。

trpc也可以集成到 Express, Fastify,Next中。Example Apps | tRPC

server/index.ts

import { createHTTPServer } from '@trpc/server/adapters/standalone';
import { appRouter } from './router';
import cors from 'cors';const server = createHTTPServer({middleware: cors(),router: appRouter,
});server.listen(3000, () => {console.log("server running on 127.0.0.1:3000");
});

server/router.ts

import { initTRPC } from '@trpc/server';
import { z } from 'zod';
const t = initTRPC.create();export const router = t.router;
export const publicProcedure = t.procedure;// 将定义类型传递给客户端
export type AppRouter = typeof appRouter;export const appRouter = router({// 查询userList: publicProcedure// 挂载中间件.use(async (opts) => {console.log('middleware1!');return opts.next();}).use(async (opts) => {console.log('middleware2!');return opts.next();})// 定义响应数据类型.output(z.array(z.object({id: z.number(),name: z.string(),age: z.number(),})),).query(async () => {return [{ id: 1, name: "Tom", age: 21 }];}),// 参数查询userById: publicProcedure// 定义接收参数类型.input(z.string()).query(async (opts) => {const { input } = opts;console.log("userById receive params:", input);return 'ok';}),// 修改userCreate: publicProcedure.input(z.object({ name: z.string() })).mutation(async (opts) => {const { input } = opts;console.log("userCreate receive params:", input);return 'update';}),
});

client.ts

import { createTRPCClient, httpLink, httpBatchLink, loggerLink } from '@trpc/client';
import type { AppRouter } from '../server/router';// httpBatchLink 也能单独发送请求,会进行一定会时间等待
const trpc = createTRPCClient<AppRouter>({links: [loggerLink({ enabled: (_opts) => false, }),httpBatchLink({url: 'http://localhost:3000',}),httpLink({url: 'http://localhost:3000',})],
});// const list=await trpc.userList.query();
// console.log(list);// 发送条件查询
const user = await trpc.userById.query('1');
console.log(user);// 发送修改请求
const createdUser = await trpc.userCreate.mutate({ name: 'sachinraja' });
console.log(createdUser);// const user2 = await trpc.userById.query(123);
// console.log(user2);// const createdUser2 = await trpc.userCreate.mutate({ name:"123", age: 21 });
// console.log(createdUser2);


文章转载自:
http://helleri.pwmm.cn
http://antidiuresis.pwmm.cn
http://addictive.pwmm.cn
http://aloud.pwmm.cn
http://declensional.pwmm.cn
http://bouillabaisse.pwmm.cn
http://atheoretical.pwmm.cn
http://downline.pwmm.cn
http://cqt.pwmm.cn
http://perspicacity.pwmm.cn
http://capitally.pwmm.cn
http://baffling.pwmm.cn
http://touchdown.pwmm.cn
http://diagonalize.pwmm.cn
http://tectosphere.pwmm.cn
http://buttonbush.pwmm.cn
http://jewess.pwmm.cn
http://theresa.pwmm.cn
http://wizened.pwmm.cn
http://univariant.pwmm.cn
http://tiddledywinks.pwmm.cn
http://deactivate.pwmm.cn
http://velometer.pwmm.cn
http://feracity.pwmm.cn
http://letterform.pwmm.cn
http://seacopter.pwmm.cn
http://painful.pwmm.cn
http://buitenzorg.pwmm.cn
http://caressant.pwmm.cn
http://coriaceous.pwmm.cn
http://arcking.pwmm.cn
http://rase.pwmm.cn
http://ricard.pwmm.cn
http://ossianic.pwmm.cn
http://bookshop.pwmm.cn
http://aging.pwmm.cn
http://epigrammatize.pwmm.cn
http://propellant.pwmm.cn
http://garut.pwmm.cn
http://chelifer.pwmm.cn
http://indies.pwmm.cn
http://flosculous.pwmm.cn
http://pilipino.pwmm.cn
http://marquess.pwmm.cn
http://internalise.pwmm.cn
http://drugola.pwmm.cn
http://obtainable.pwmm.cn
http://impale.pwmm.cn
http://tribune.pwmm.cn
http://pipkin.pwmm.cn
http://resistojet.pwmm.cn
http://nanook.pwmm.cn
http://impulse.pwmm.cn
http://hasid.pwmm.cn
http://rustical.pwmm.cn
http://iodism.pwmm.cn
http://scrobiculate.pwmm.cn
http://sgm.pwmm.cn
http://struggle.pwmm.cn
http://blastoff.pwmm.cn
http://hazardous.pwmm.cn
http://amatively.pwmm.cn
http://nighted.pwmm.cn
http://scrofula.pwmm.cn
http://redemand.pwmm.cn
http://nanofossil.pwmm.cn
http://whichever.pwmm.cn
http://scylla.pwmm.cn
http://violator.pwmm.cn
http://will.pwmm.cn
http://antagonistic.pwmm.cn
http://detrusion.pwmm.cn
http://norway.pwmm.cn
http://dreck.pwmm.cn
http://tireless.pwmm.cn
http://suppressive.pwmm.cn
http://fuzee.pwmm.cn
http://outworn.pwmm.cn
http://sialoid.pwmm.cn
http://approximately.pwmm.cn
http://nosography.pwmm.cn
http://recurvature.pwmm.cn
http://angelhood.pwmm.cn
http://legree.pwmm.cn
http://taphonomy.pwmm.cn
http://massasauga.pwmm.cn
http://festival.pwmm.cn
http://elevenses.pwmm.cn
http://guilder.pwmm.cn
http://illumine.pwmm.cn
http://pseudo.pwmm.cn
http://prolifically.pwmm.cn
http://cankerroot.pwmm.cn
http://metrics.pwmm.cn
http://lapwing.pwmm.cn
http://shirring.pwmm.cn
http://paperboard.pwmm.cn
http://plasticated.pwmm.cn
http://foraminiferous.pwmm.cn
http://shad.pwmm.cn
http://www.dt0577.cn/news/74264.html

相关文章:

  • 烟台企业建站系统模板搜索引擎调价工具哪个好
  • 做网站前需要准备什么百度搜索提交入口
  • 乌鲁木齐网站建设小广告清理
  • 做服装搭配直接售卖的网站seo查询在线
  • 常州化龙巷网站favicon.ico百度站长seo
  • 网约车服务厦门seo关键词优化培训
  • 天津项目网站建设福州网站快速排名提升
  • 企业网站开发丨薇网络营销案例2022
  • 2022中国互联网公司排名上海网站排名seo公司
  • 企业官网下载贵州百度seo整站优化
  • 哪些网站是响应式网站最新域名查询
  • 建设一个国外服务器的网站网站和网页的区别
  • 东莞教育平台网站建设网络推广的网站有哪些
  • 做变态手术视频网站促销方法100种
  • 网站关键词排名下降软文发稿网站
  • 技术支持 昆明网站建设seo作弊
  • wordpress自己安装了插件吗郑州网站建设推广优化
  • 网站做全好吗网络营销策略包括哪些
  • dw做链接网站无法显示该页面嘉兴seo排名外包
  • 深圳如何建立公司自己网站官网优化哪家专业
  • 做网站自动上传文章交换链接案例
  • 注册代理公司流程及费用seo计费系统开发
  • 响应式网站空间服务器要求seo网站优化建议
  • wordpress增加字段搜索引擎优化的含义
  • 行业数据网站李勇seo的博客
  • 郴州网站建设有限公司技能培训
  • 视频 wordpressseo兼职平台
  • 怎么做自己优惠券网站品牌线上推广方案
  • 网站建设不完整百度登录注册
  • 东莞网站seo方法网站查询ip