@@ -5,10 +5,11 @@ import {
5
5
ErrorResponses ,
6
6
} from "@/server/api/error" ;
7
7
import type { PublicAPI } from "@/server/api/hono" ;
8
- import { OptionSchema , type TCreateOptionSchema } from "../../../schema/option" ;
9
- import type { TOptionSchema } from "./../../../schema/option" ;
10
-
11
8
import { CreateOptionSchema } from "@/server/api/schema/option" ;
9
+ import {
10
+ OptionSchema ,
11
+ type TCreateOptionSchema ,
12
+ } from "@/server/api/schema/option" ;
12
13
import { getHonoUserAgent , getIp } from "@/server/api/utils" ;
13
14
import { addOption } from "@/server/services/stock-option/add-option" ;
14
15
import { createRoute , z } from "@hono/zod-openapi" ;
@@ -37,7 +38,7 @@ const ResponseSchema = z.object({
37
38
const route = createRoute ( {
38
39
method : "post" ,
39
40
path : "/v1/companies/{id}/options" ,
40
- summary : "Issue option" ,
41
+ summary : "Issue a new stock option" ,
41
42
description : "Issue stock option to a stakeholder in a company." ,
42
43
tags : [ "Options" ] ,
43
44
request : {
@@ -69,7 +70,7 @@ const create = (app: PublicAPI) => {
69
70
const body = await c . req . json ( ) ;
70
71
71
72
const { success, message, data, code } = await addOption ( {
72
- requestIP : getIp ( c . req ) ,
73
+ requestIp : getIp ( c . req ) ,
73
74
userAgent : getHonoUserAgent ( c . req ) ,
74
75
data : body as TCreateOptionSchema ,
75
76
companyId : company . id ,
@@ -80,7 +81,7 @@ const create = (app: PublicAPI) => {
80
81
} ,
81
82
} ) ;
82
83
83
- if ( ! success ) {
84
+ if ( ! success || ! data ) {
84
85
throw new ApiError ( {
85
86
code : code as ErrorCodeType ,
86
87
message,
@@ -89,8 +90,8 @@ const create = (app: PublicAPI) => {
89
90
90
91
return c . json (
91
92
{
92
- message : "Stock option added successfully." ,
93
- data : data as unknown as TOptionSchema ,
93
+ message,
94
+ data,
94
95
} ,
95
96
200 ,
96
97
) ;
0 commit comments