Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get users route #6

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ jobs:

deploy-frontend:
needs: pre-deploy
if: (contains(github.event.inputs.manual-deploy, 'scaffolding-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
# For "simplicity", deployment settings are configured in the AWS Amplify Console
# This just posts to a webhook telling Amplify to redeploy the main branch
steps:
- name: Tell Amplify to rebuild
run: curl -X POST -d {} ${SCAFFOLDING_WEBHOOK_DEPLOY} -H "Content-Type:application/json"
run: curl -X POST -d {} ${C4C_OPS_WEBHOOK_DEPLOY} -H "Content-Type:application/json"
env:
SCAFFOLDING_WEBHOOK_DEPLOY: ${{ secrets.SCAFFOLDING_WEBHOOK_DEPLOY }}
C4C_OPS_WEBHOOK_DEPLOY: ${{ secrets.C4C_OPS_WEBHOOK_DEPLOY }}

# deploy-backend:
# needs: pre-deploy
# if: (contains(github.event.inputs.manual-deploy, 'scaffolding-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
# if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
Expand All @@ -102,12 +102,12 @@ jobs:
# - name: Install Dependencies
# run: yarn install

# - run: npx nx build scaffolding-backend --configuration production
# - run: npx nx build c4c-ops-backend --configuration production
# - name: default deploy
# uses: appleboy/lambda-action@master
# with:
# aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws_region: ${{ secrets.AWS_REGION }}
# function_name: scaffolding-monolith-lambda
# source: dist/apps/scaffolding/scaffolding-backend/main.js
# function_name: c4c-ops-monolith-lambda
# source: dist/apps/c4c-ops/c4c-ops-backend/main.js
4 changes: 3 additions & 1 deletion apps/backend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from '../users/users.module';
import { PluralNamingStrategy } from '../strategies/plural-naming.strategy';

@Module({
Expand All @@ -11,7 +12,7 @@ import { PluralNamingStrategy } from '../strategies/plural-naming.strategy';
type: 'mongodb',
host: 'localhost',
port: 27017,
database: 'scaffoldingTest',
database: 'c4cOpsTest',
// username: 'root',
// password: 'root',
autoLoadEntities: true,
Expand All @@ -20,6 +21,7 @@ import { PluralNamingStrategy } from '../strategies/plural-naming.strategy';
synchronize: true,
namingStrategy: new PluralNamingStrategy(),
}),
UsersModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
16 changes: 16 additions & 0 deletions apps/backend/src/users/user.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;

@Column()
firstName: string;

@Column()
lastName: string;

@Column()
email: string;
}
13 changes: 13 additions & 0 deletions apps/backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';

import { UsersService } from './users.service';

@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) {}

@Get()
getAllUsers() {
return this.usersService.findAll();
}
}
13 changes: 13 additions & 0 deletions apps/backend/src/users/users.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { UsersService } from './users.service';
import { UsersController } from './users.controller';
import { User } from './user.entity';

@Module({
imports: [TypeOrmModule.forFeature([User])],
providers: [UsersService],
controllers: [UsersController],
})
export class UsersModule {}
17 changes: 17 additions & 0 deletions apps/backend/src/users/users.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

import { User } from './user.entity';

@Injectable()
export class UsersService {
constructor(
@InjectRepository(User)
private usersRepository: Repository<User>,
) {}

findAll(): Promise<User[]> {
return this.usersRepository.find();
}
}
Loading