From e52e00ab7fdcd5313c6778cedd27ee3acf9a0836 Mon Sep 17 00:00:00 2001 From: Eman Date: Fri, 9 Feb 2024 12:37:11 +0200 Subject: [PATCH 1/2] feat: register user operation --- apps/api/src/auth/operations/register.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/api/src/auth/operations/register.ts b/apps/api/src/auth/operations/register.ts index e69de29b..c018cc69 100644 --- a/apps/api/src/auth/operations/register.ts +++ b/apps/api/src/auth/operations/register.ts @@ -0,0 +1,11 @@ +import { z } from "zod"; + +const userSchema = z.object({ + name: z.string() +}); + +type UserAttr = z.infer; + +export const registerUser = (user: UserAttr) => { + return user; +} \ No newline at end of file From b524a0de061aec3c9f5edb17c85be2ed14c0e214 Mon Sep 17 00:00:00 2001 From: Eman Date: Thu, 15 Feb 2024 21:06:26 +0200 Subject: [PATCH 2/2] feat: temp typescript fixes --- apps/pay/src/index.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/pay/src/index.ts b/apps/pay/src/index.ts index 1f145b9b..e11660d9 100644 --- a/apps/pay/src/index.ts +++ b/apps/pay/src/index.ts @@ -135,7 +135,7 @@ type Mutation { class MomoAuthAPI extends RESTDataSource { override baseURL = "https://sandbox.momodeveloper.mtn.com/"; - private token: string; + private token!: string; constructor(options: { token?: string; @@ -147,7 +147,7 @@ class MomoAuthAPI extends RESTDataSource { override willSendRequest(_path: string, request: AugmentedRequest) { request.headers["Authorisation"] = `Basic ${this.token}`; - request.headers["Ocp-Apim-Subscription-Key"] = subscriptionKey; + request.headers["Ocp-Apim-Subscription-Key"] = subscriptionKey!; } async createAcccessToken() { @@ -159,7 +159,7 @@ class MomoAPI extends RESTDataSource { override baseURL = "https://sandbox.momodeveloper.mtn.com/"; private token: string; - constructor(options) { + constructor(options: any) { super(options); const { token, cache, key } = options; this.token = token; @@ -167,11 +167,11 @@ class MomoAPI extends RESTDataSource { override willSendRequest(_path: string, request: AugmentedRequest) { request.headers["Authorization"] = `Bearer ${this.token}`; - request.headers["Ocp-Apim-Subscription-Key"] = subscriptionKey; + request.headers["Ocp-Apim-Subscription-Key"] = subscriptionKey!; request.headers["X-Target-Environment"] = "sandbox"; } - async requestToPay(body) { + async requestToPay(body: any) { try { const resp = await this.post(`collection/v1_0/requesttopay`, { body: { ...body?.object }, @@ -294,8 +294,7 @@ const server = new ApolloServer({ await server.start(); -async function validateAccessToken(req, res, next) { - console.log("yerrr"); +async function validateAccessToken(req: any, res: any, next: any) { const authHeader = req.headers.authorization; if (authHeader) { @@ -316,9 +315,7 @@ async function validateAccessToken(req, res, next) { } ); req.headers.access_token = response.data.access_token; - //console.log(response.headers); } - // req.locals.access_tokn = "yerrrrr"; // No token in the request, generate a new access token // const newToken = dataSources.momoAPI.createAcccessToken();