Skip to content

Commit

Permalink
feat: add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrdsilva committed Mar 10, 2024
1 parent 3f685e6 commit bfc39b1
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 63 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Workflow

on:
push:
branches: ['develop', 'main']
pull_request:
branches: ['develop', 'main']

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Build NestJS app
run: npm run build
2 changes: 1 addition & 1 deletion src/config/graphql.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const graphqlAsyncConfig = <ApolloDriverConfig>{
playground: configService.get<boolean>('graphql.playground'),
autoSchemaFile: configService.get<boolean>('graphql.autoSchemaFile'),
}),
inject: [ConfigService]
inject: [ConfigService],
};
4 changes: 2 additions & 2 deletions src/models/dtos/create-response.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { InputType, Int, Field } from '@nestjs/graphql';

@InputType()
export class CreateResponseInput {
@Field(() => Int, { description: 'Example field (placeholder)' })
exampleField: number;
@Field(() => Int, { description: 'Example field (placeholder)' })
exampleField: number;
}
38 changes: 19 additions & 19 deletions src/models/dtos/create-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ import { Column } from 'typeorm';

@InputType()
export class CreateUserInput {
@Field(() => String)
firstName: string;
@Field(() => String)
firstName: string;

@Field(() => String, { nullable: true })
lastName?: string;
@Field(() => String, { nullable: true })
lastName?: string;

@Column()
@Field(() => String)
username: string;
@Column()
@Field(() => String)
username: string;

@Column()
@Field(() => String)
email: string;
@Column()
@Field(() => String)
email: string;

@Column()
@Field(() => String)
password: string;
@Column()
@Field(() => String)
password: string;

@Field(() => String, { nullable: true })
bio?: string;
@Field(() => String, { nullable: true })
bio?: string;

@Field(() => String, { nullable: true })
profilePicture?: string;
@Field(() => String, { nullable: true })
profilePicture?: string;

@Field(() => String, { nullable: true })
coverImage?: string;
@Field(() => String, { nullable: true })
coverImage?: string;
}
8 changes: 4 additions & 4 deletions src/models/dtos/update-bio.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { InputType, Field } from '@nestjs/graphql';

@InputType()
export class UpdateBioInput {
@Field(() => String)
userId: string;
@Field(() => String)
userId: string;

@Field(() => String)
bio: string;
@Field(() => String)
bio: string;
}
8 changes: 4 additions & 4 deletions src/models/dtos/update-cover-image.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { InputType, Field } from '@nestjs/graphql';

@InputType()
export class UpdateCoverImageInput {
@Field(() => String)
id: string;
@Field(() => String)
id: string;

@Field(() => String)
coverImage: string;
@Field(() => String)
coverImage: string;
}
4 changes: 2 additions & 2 deletions src/models/dtos/update-image.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { InputType, Field, Int, PartialType } from '@nestjs/graphql';

@InputType()
export class UpdateImageInput extends PartialType(CreateImageInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
4 changes: 2 additions & 2 deletions src/models/dtos/update-post-comment.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { InputType, Field, Int, PartialType } from '@nestjs/graphql';

@InputType()
export class UpdateCommentInput extends PartialType(CreatePostCommentInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
4 changes: 2 additions & 2 deletions src/models/dtos/update-post.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { InputType, Field, Int, PartialType } from '@nestjs/graphql';

@InputType()
export class UpdatePostInput extends PartialType(CreatePostInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
8 changes: 4 additions & 4 deletions src/models/dtos/update-profile-picture.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { InputType, Field, Int } from '@nestjs/graphql';

@InputType()
export class UpdateProfilePictureInput {
@Field(() => String)
id: string;
@Field(() => String)
id: string;

@Field(() => String)
profilePicture: string;
@Field(() => String)
profilePicture: string;
}
4 changes: 2 additions & 2 deletions src/models/dtos/update-response.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { InputType, Field, Int, PartialType } from '@nestjs/graphql';

@InputType()
export class UpdateResponseInput extends PartialType(CreateResponseInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
4 changes: 2 additions & 2 deletions src/models/dtos/update-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { InputType, Field, Int, PartialType } from '@nestjs/graphql';

@InputType()
export class UpdateUserInput extends PartialType(CreateUserInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
6 changes: 3 additions & 3 deletions src/resolvers/image.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export class ImageResolver {
@UseGuards(JwtAuthGuard)
@Query(() => [Image])
images(
@Args('page', { type: () => Int, nullable: true }) page: number = 1,
@Args('limit', { type: () => Int, nullable: true }) limit: number = 8,
@Args('page', { type: () => Int, nullable: true }) page = 1,
@Args('limit', { type: () => Int, nullable: true }) limit = 8,
) {
// Calculate the number of posts to skip based on the page and limit parameters
const skip = (page - 1) * limit;

return this.imageService.findAll(skip, limit);
}

Expand Down
4 changes: 2 additions & 2 deletions src/resolvers/post.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class PostResolver {
@Query(() => [Post])
findPostsByUser(
@Args('userId', { type: () => String }) userId: string,
@Args('page', { type: () => Int, nullable: true }) page: number = 1,
@Args('limit', { type: () => Int, nullable: true }) limit: number = 5,
@Args('page', { type: () => Int, nullable: true }) page = 1,
@Args('limit', { type: () => Int, nullable: true }) limit = 5,
) {
// Calculate the number of posts to skip based on the page and limit parameters
const skip = (page - 1) * limit;
Expand Down
25 changes: 11 additions & 14 deletions test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ import * as request from 'supertest';
import { AppModule } from './../src/app.module';

describe('AppController (e2e)', () => {
let app: INestApplication;
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});
app = moduleFixture.createNestApplication();
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
it('/ (GET)', () => {
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
});
});

0 comments on commit bfc39b1

Please sign in to comment.