Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Nikitin committed Apr 16, 2024
1 parent 5e03a89 commit c11d3e3
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { SubscriptionController } from './controllers/admin/subscriptions.js';
import { PriceController } from './controllers/admin/prices.js';
import { WebhookController } from './controllers/admin/webhook.js';
import { APIKeyController } from './controllers/admin/api-key.js';
import { OrganisationController } from './controllers/admin/organisation.js';
import { OrganizationController } from './controllers/admin/organization.js';

let swaggerOptions = {};
if (process.env.ENABLE_AUTHENTICATION === 'true') {
Expand Down Expand Up @@ -281,8 +281,8 @@ class App {
app.post('/admin/webhook', new WebhookController().handleWebhook);

// Customer
app.post('/admin/organisation/update', OrganisationController.organisationUpdatevalidator, new OrganisationController().update);
app.get('/admin/organisation/get', new OrganisationController().get);
app.post('/admin/organization/update', OrganizationController.organizationUpdatevalidator, new OrganizationController().update);
app.get('/admin/organization/get', new OrganizationController().get);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { check } from 'express-validator';
import { validate } from '../validator/decorator.js';
import { CustomerService } from '../../services/api/customer.js';
import { StatusCodes } from 'http-status-codes';
import type { AdminCustomerGetUnsuccessfulResponseBody, AdminCustomerUpdateResponseBody, AdminCustomerUpdateUnsuccessfulResponseBody } from '../../types/admin.js';
import type { AdminOrganizationGetUnsuccessfulResponseBody, AdminOrganizationUpdateResponseBody, AdminOrganizationUpdateUnsuccessfulResponseBody } from '../../types/admin.js';
import { PaymentAccountService } from '../../services/api/payment-account.js';

dotenv.config();

export class OrganisationController {
static organisationUpdatevalidator = [
export class OrganizationController {
static organizationUpdatevalidator = [
check('name').
optional().
isString().
Expand All @@ -29,11 +29,11 @@ export class OrganisationController {
/**
* @openapi
*
* /admin/organisation/update:
* /admin/organization/update:
* post:
* summary: Update an organisation
* description: Update an organisation
* tags: [Organisation]
* summary: Update an organization
* description: Update an organization
* tags: [Organization]
* requestBody:
* required: true
* content:
Expand All @@ -50,14 +50,14 @@ export class OrganisationController {
* format: email
* description:
* type: string
* example: Cheqd organisation
* example: Cheqd organization
* responses:
* 200:
* description: A successful response
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/OrganisationResponseBody'
* $ref: '#/components/schemas/OrganizationResponseBody'
* 400:
* $ref: '#/components/schemas/InvalidRequest'
* 401:
Expand All @@ -77,37 +77,37 @@ export class OrganisationController {
if (!customer || !paymentAccount) {
response.status(StatusCodes.NOT_FOUND).json({
error: 'Customer for updating not found',
} satisfies AdminCustomerUpdateUnsuccessfulResponseBody);
} satisfies AdminOrganizationUpdateUnsuccessfulResponseBody);
}

return response.status(StatusCodes.OK).json({
name: customer.name,
email: customer.email,
description: customer.description,
cosmosAddress: paymentAccount[0].address as string
} satisfies AdminCustomerUpdateResponseBody);
} satisfies AdminOrganizationUpdateResponseBody);
} catch (error) {
return response.status(500).json({
error: `Internal error: ${(error as Error)?.message || error}`,
} satisfies AdminCustomerUpdateUnsuccessfulResponseBody);
} satisfies AdminOrganizationUpdateUnsuccessfulResponseBody);
}
}

/**
* @openapi
*
* /admin/organisation/get:
* /admin/organization/get:
* get:
* summary: Get an organisation
* description: Get an organisation
* tags: [Organisation]
* summary: Get an organization
* description: Get an organization
* tags: [Organization]
* responses:
* 200:
* description: A successful response
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/OrganisationResponseBody'
* $ref: '#/components/schemas/OrganizationResponseBody'
* 400:
* $ref: '#/components/schemas/InvalidRequest'
* 401:
Expand All @@ -125,7 +125,7 @@ export class OrganisationController {
if (!customer || !paymentAccount) {
response.status(StatusCodes.NOT_FOUND).json({
error: 'Customer for current user was not found or did not setup properly. Please contact administrator.',
} satisfies AdminCustomerGetUnsuccessfulResponseBody);
} satisfies AdminOrganizationGetUnsuccessfulResponseBody);
}
return response.status(StatusCodes.OK).json({
name: customer.name,
Expand All @@ -136,7 +136,7 @@ export class OrganisationController {
} catch (error) {
return response.status(500).json({
error: `Internal error: ${(error as Error)?.message || error}`,
} satisfies AdminCustomerGetUnsuccessfulResponseBody);
} satisfies AdminOrganizationGetUnsuccessfulResponseBody);
}
}
}
4 changes: 2 additions & 2 deletions src/middleware/auth/routes/admin/admin-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class AdminAuthRuleProvider extends AuthRuleProvider {
this.registerRule('/admin/api-key/get', 'GET', 'admin:api-key:get', { skipNamespace: true });
this.registerRule('/admin/api-key/list', 'GET', 'admin:api-key:list', { skipNamespace: true });
// Customer
this.registerRule('/admin/organisation/update', 'POST', 'admin:organisation:update', { skipNamespace: true });
this.registerRule('/admin/organisation/get', 'GET', 'admin:organisation:get', { skipNamespace: true });
this.registerRule('/admin/organization/update', 'POST', 'admin:organization:update', { skipNamespace: true });
this.registerRule('/admin/organization/get', 'GET', 'admin:organization:get', { skipNamespace: true });

}
}
2 changes: 1 addition & 1 deletion src/static/swagger-admin-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"name": "API Key"
},
{
"name": "Organisation"
"name": "Organization"
}
]
}
38 changes: 19 additions & 19 deletions src/static/swagger-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"name": "API Key"
},
{
"name": "Organisation"
"name": "Organization"
}
],
"paths": {
Expand Down Expand Up @@ -225,12 +225,12 @@
}
}
},
"/admin/organisation/update": {
"/admin/organization/update": {
"post": {
"summary": "Update an organisation",
"description": "Update an organisation",
"summary": "Update an organization",
"description": "Update an organization",
"tags": [
"Organisation"
"Organization"
],
"requestBody": {
"required": true,
Expand All @@ -250,7 +250,7 @@
},
"description": {
"type": "string",
"example": "Cheqd organisation"
"example": "Cheqd organization"
}
}
}
Expand All @@ -263,7 +263,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrganisationResponseBody"
"$ref": "#/components/schemas/OrganizationResponseBody"
}
}
}
Expand All @@ -283,20 +283,20 @@
}
}
},
"/admin/organisation/get": {
"/admin/organization/get": {
"get": {
"summary": "Get an organisation",
"description": "Get an organisation",
"summary": "Get an organization",
"description": "Get an organization",
"tags": [
"Organisation"
"Organization"
],
"responses": {
"200": {
"description": "A successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrganisationResponseBody"
"$ref": "#/components/schemas/OrganizationResponseBody"
}
}
}
Expand Down Expand Up @@ -1128,33 +1128,33 @@
"ref": "#/components/schemas/APIKeyResponse"
}
},
"OrganisationResponseBody": {
"description": "The response body for an organisation",
"OrganizationResponseBody": {
"description": "The response body for an organization",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the organisation",
"description": "The name of the organization",
"example": "Cheqd"
},
"email": {
"type": "string",
"description": "The email of the organisation",
"description": "The email of the organization",
"example": "cheqd@example.com",
"format": "email",
"nullable": true,
"default": null
},
"description": {
"type": "string",
"description": "The description of the organisation",
"example": "Cheqd organisation",
"description": "The description of the organization",
"example": "Cheqd organization",
"nullable": true,
"default": null
},
"cosmosAddress": {
"type": "string",
"description": "The cosmos address of the organisation",
"description": "The cosmos address of the organization",
"example": "cheqd1hwzvac94udsk8x4mf6htt544lev4jltkwgxp7u"
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/types/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,24 @@ export type APIKeyGetRequestBody = APIKeyResponseBody;
export type APIKeyGetResponseBody = APIKeyCreateResponseBody;
export type APIKeyGetUnsuccessfulResponseBody = UnsuccessfulResponseBody;

// Organisation
export type AdminCustomerResponseBody = {
// Organization
export type AdminOrganizationResponseBody = {
name: string;
email?: string;
description?: string;
cosmosAddress?: string;
};

export type AdminCustomerGetResponseBody = AdminCustomerResponseBody;
export type AdminCustomerGetUnsuccessfulResponseBody = UnsuccessfulResponseBody;
export type AdminOrganizationGetResponseBody = AdminOrganizationResponseBody;
export type AdminOrganizationGetUnsuccessfulResponseBody = UnsuccessfulResponseBody;

export type AdminCustomerUpdateRequestBody = {
export type AdminOrganizationUpdateRequestBody = {
name?: string;
email?: string;
description?: string;
};
export type AdminCustomerUpdateResponseBody = AdminCustomerGetResponseBody;
export type AdminCustomerUpdateUnsuccessfulResponseBody = UnsuccessfulResponseBody;
export type AdminOrganizationUpdateResponseBody = AdminOrganizationGetResponseBody;
export type AdminOrganizationUpdateUnsuccessfulResponseBody = UnsuccessfulResponseBody;


// Utils
Expand Down
14 changes: 7 additions & 7 deletions src/types/swagger-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,30 +316,30 @@
* type: object
* schema:
* ref: '#/components/schemas/APIKeyResponse'
* OrganisationResponseBody:
* description: The response body for an organisation
* OrganizationResponseBody:
* description: The response body for an organization
* type: object
* properties:
* name:
* type: string
* description: The name of the organisation
* description: The name of the organization
* example: Cheqd
* email:
* type: string
* description: The email of the organisation
* description: The email of the organization
* example: cheqd@example.com
* format: email
* nullable: true
* default: null
* description:
* type: string
* description: The description of the organisation
* example: Cheqd organisation
* description: The description of the organization
* example: Cheqd organization
* nullable: true
* default: null
* cosmosAddress:
* type: string
* description: The cosmos address of the organisation
* description: The cosmos address of the organization
* example: cheqd1hwzvac94udsk8x4mf6htt544lev4jltkwgxp7u
* NotFoundError:
* description: The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.
Expand Down

0 comments on commit c11d3e3

Please sign in to comment.