Skip to content

Commit

Permalink
refactor: Update PostgresDatabase.ts and UserService.ts to use explic…
Browse files Browse the repository at this point in the history
…it type annotations
  • Loading branch information
simlarsen committed Aug 14, 2024
1 parent 7e54fc3 commit 2e850ed
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion App/FeatureSet/Home/Views/Blog/List.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="relative isolate overflow-hidden bg-white">
<div class="py-24 sm:py-32">

<%- include('./Partials/BlogTitleAndDescription', { title: 'Engineering Uptime - Blog by OneUptime', description: 'Latest posts on Observability, Monitoring, Reliability and more.' }) -%>
<%- include('./Partials/BlogTitleAndDescription', { title: 'Engineering Uptime', smallTitle: '- Blog by OneUptime', description: 'Latest posts on Observability, Monitoring, Reliability and more.' }) -%>

<div class="mx-auto max-w-7xl px-6 lg:px-8">

Expand Down
2 changes: 1 addition & 1 deletion App/FeatureSet/Home/Views/Blog/ListByTag.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="relative isolate overflow-hidden bg-white">
<div class="py-24 sm:py-32">

<%- include('./Partials/BlogTitleAndDescription', { title: 'Latest posts on '+tagName, description: 'Here are some of the latest posts on '+tagName }) -%>
<%- include('./Partials/BlogTitleAndDescription', { title: 'Latest posts on '+tagName, smallTitle: "", description: 'Here are some of the latest posts on '+tagName }) -%>

<div class="mx-auto max-w-7xl px-6 lg:px-8">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
<h1 class="max-w-5xl text-center text-6xl font-bold text-gray-900 leading-tight">
<%= title %>
</h1>
</div>
<div class="mx-auto flex justify-center text-center ">
<% if(smallTitle){ %>
<h3 class="max-w-5xl mt-5 text-center text-2xl font-medium text-gray-900 leading-tight">
<%= smallTitle %>
</h3>
<% } %>
</div>
<p class="text-2xl text-center leading-8 text-gray-600 mt-8 leading-normal">
<%= description %>
Expand Down
2 changes: 1 addition & 1 deletion App/FeatureSet/Home/Views/Blog/Post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<div class="py-24 sm:py-32">
<div class="mx-auto max-w-7xl px-6 lg:px-8">

<%- include('./Partials/BlogTitleAndDescription', { title: blogPost.title , description:
<%- include('./Partials/BlogTitleAndDescription', { title: blogPost.title , smallTitle: "", description:
blogPost.description }) -%>


Expand Down
2 changes: 1 addition & 1 deletion Common/Server/Infrastructure/PostgresDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Database {
public async connect(): Promise<DataSource> {
let retry: number = 0;

const dataSourceOptions = this.getDatasourceOptions();
const dataSourceOptions: DataSourceOptions = this.getDatasourceOptions();

try {
type ConnectToDatabaseFunction = () => Promise<DataSource>;
Expand Down
4 changes: 2 additions & 2 deletions Common/Server/Services/TeamService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LIMIT_MAX from "Common/Types/Database/LimitMax";
import BadDataException from "Common/Types/Exception/BadDataException";
import Model from "Common/Models/DatabaseModels/Team";

export class TeamService extends DatabaseService<Model> {
export class Service extends DatabaseService<Model> {
public constructor() {
super(Model);
}
Expand Down Expand Up @@ -69,4 +69,4 @@ export class TeamService extends DatabaseService<Model> {
return { deleteBy, carryForward: null };
}
}
export default new TeamService();
export default new Service();
4 changes: 2 additions & 2 deletions Common/Server/Services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import UserTwoFactorAuth from "Common/Models/DatabaseModels/UserTwoFactorAuth";
import UserTwoFactorAuthService from "./UserTwoFactorAuthService";
import BadDataException from "Common/Types/Exception/BadDataException";

export class UserService extends DatabaseService<Model> {
export class Service extends DatabaseService<Model> {
public constructor() {
super(Model);
}
Expand Down Expand Up @@ -318,4 +318,4 @@ export class UserService extends DatabaseService<Model> {
}
}

export default new UserService();
export default new Service();
8 changes: 4 additions & 4 deletions Common/Tests/Server/Services/TeamMemberService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@ describe("TeamMemberService", () => {
const SUBSCRIPTION_ID: string = "subscriptionId";

it("should update subscription seats based on unique team members", async () => {
const user1 = await UserService.create({
const user1: User = await UserService.create({
data: UserServiceHelper.generateRandomUser(),
props: { isRoot: true },
});

const project = await ProjectService.create({
const project: Project = await ProjectService.create({
data: ProjectServiceHelper.generateRandomProject(),
props: { isRoot: true, userId: user1.id! },
});
Expand All @@ -847,14 +847,14 @@ describe("TeamMemberService", () => {

// now add users.

const user2 = await UserService.create({
const user2: User = await UserService.create({
data: UserServiceHelper.generateRandomUser(),
props: { isRoot: true },
});

// add team

const team = await TeamService.create({
const team: Team = await TeamService.create({
data: TeamServiceHelper.generateRandomTeam({
projectId: new ObjectID(project._id!),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import Project from "Common/Models/DatabaseModels/Project";
import { PlanType } from "../../../../Types/Billing/SubscriptionPlan";

export default class ProjectTestService {
public static generateRandomProject(data?: { seatLimit?: number } | undefined): Project {
public static generateRandomProject(
data?: { seatLimit?: number } | undefined,
): Project {
const project: Project = new Project();

// required fields
Expand All @@ -12,7 +14,7 @@ export default class ProjectTestService {
project.isBlocked = false;
project.requireSsoForLogin = false;

if(data && data.seatLimit){
if (data && data.seatLimit) {
project.seatLimit = data.seatLimit;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import getTestDataSourceOptions from "../Postgres/TestDataSourceOptions";
import { PostgresAppInstance } from "../../../../Server/Infrastructure/PostgresDatabase";
import {
DatabaseSourceOptions,
PostgresAppInstance,
} from "../../../../Server/Infrastructure/PostgresDatabase";
import Redis from "../../../../Server/Infrastructure/Redis";
import getTestRedisConnectionOptions from "../Redis/TestRedisOptions";

export class TestDatabaseMock {
public static async connectDbMock(): Promise<void> {
const testDataSourceOptions = getTestDataSourceOptions();
const testDataSourceOptions: DatabaseSourceOptions =
getTestDataSourceOptions();

PostgresAppInstance.getDatasourceOptions = () => {
return testDataSourceOptions;
Expand Down

0 comments on commit 2e850ed

Please sign in to comment.