Skip to content

Commit

Permalink
feat(panel-api): user exists
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Jun 16, 2024
1 parent 84147c4 commit 08a24b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions packages/panel-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
"files": [
"**/*.{js,mjs,cjs,map,d.ts,html,md,css}"
],
"exports": {
"./*": "./src/*"
},
"devDependencies": {
"@gecut/kartbook-db-connector": "workspace:^",
"@gecut/kartbook-types": "workspace:^",
"@gecut/logger": "^1.4.2",
"@gecut/utilities": "^5.2.1",
"@gecut/logger": "^1.4.3",
"@gecut/utilities": "^5.3.0",
"@types/cors": "^2.8.17",
"@types/node": "^20.13.0",
"cors": "^2.8.5",
"esbuild": "^0.21.4",
"mongoose": "^8.4.1",
"nodemon": "^3.1.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/panel-api/src/panel-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {createHTTPServer} from '@trpc/server/adapters/standalone';
import cors from 'cors';

import config from './config.js';
import {db, logger, publicProcedure, router} from './core.js';
Expand All @@ -13,6 +14,7 @@ const appRouter = router({
export type AppRouter = typeof appRouter;

const server = createHTTPServer({
middleware: cors(),
router: appRouter,
});

Expand Down
6 changes: 2 additions & 4 deletions packages/panel-api/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import z from 'zod';

import {db, microSMS, publicProcedure, router} from '../core.js';

import type {UserInterface, StringifyEntity} from '@gecut/kartbook-types';

const user = router({
has: publicProcedure
.input(
z.object({
phoneNumber: z.string(),
}),
)
.query((opts) => {
.query(async (opts) => {
const {phoneNumber} = opts.input;

return db.$User.findOne({phoneNumber: phoneNumber}) as unknown as StringifyEntity<UserInterface> | null;
return (await db.$User.exists({phoneNumber: phoneNumber}))?._id;
}),
create: publicProcedure
.input(
Expand Down

0 comments on commit 08a24b2

Please sign in to comment.