-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
200 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { AppModule } from './app.module'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; | ||
|
||
async function bootstrap() { | ||
const app: INestApplication = await NestFactory.create(AppModule); | ||
|
||
const options: any = new DocumentBuilder() | ||
.setTitle('Muscular API') | ||
.setDescription('Muscular API Document') | ||
.setVersion('1.0') | ||
.addTag('Muscular') | ||
.build(); | ||
const document: any = SwaggerModule.createDocument(app, options); | ||
SwaggerModule.setup('api', app, document); | ||
|
||
await app.listen(3000); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Controller } from '@nestjs/common'; | ||
|
||
@Controller('exercises') | ||
export class ExerciseController {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
AllowNull, | ||
AutoIncrement, | ||
Column, | ||
ForeignKey, | ||
Model, | ||
PrimaryKey, | ||
Table, | ||
} from 'sequelize-typescript'; | ||
import { Muscle } from '../muscle/muscle.entity'; | ||
|
||
@Table | ||
export class Exercise extends Model { | ||
@PrimaryKey | ||
@AutoIncrement | ||
@Column | ||
id: number; | ||
|
||
@AllowNull(false) | ||
@Column | ||
@ForeignKey(() => Muscle) | ||
muscleId: number; | ||
|
||
@AllowNull(false) | ||
@Column | ||
name: string; | ||
|
||
@Column | ||
machine?: string; | ||
|
||
@AllowNull(false) | ||
@Column | ||
round: number; | ||
|
||
@AllowNull(false) | ||
@Column | ||
reps: number; | ||
|
||
@Column | ||
@AllowNull(false) | ||
@Column | ||
createdAt: Date; | ||
|
||
@AllowNull(false) | ||
@Column | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({}) | ||
export class ExerciseModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Model } from 'sequelize-typescript'; | ||
import { Exercise } from './exercise.entity'; | ||
|
||
export const exerciseProviders: { useValue: typeof Model; provide: string }[] = [ | ||
{ | ||
provide: 'EXERCISE_REPOSITORY', | ||
useValue: Exercise, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Exercise } from './exercise.entity'; | ||
|
||
import { Sequelize } from 'sequelize-typescript'; | ||
|
||
@Injectable() | ||
export class ExerciseService { | ||
constructor( | ||
@Inject('EXERCISE_REPOSITORY') | ||
private readonly exerciseRepository: typeof Exercise, | ||
@Inject('SEQUELIZE') private readonly sequelizeProvider: Sequelize, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class MuscleCreateInput { | ||
readonly parts: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Body, Controller, Post } from '@nestjs/common'; | ||
import { MuscleService } from './muscle.service'; | ||
import { MuscleCreateInput } from './dto/muscle.dto'; | ||
|
||
@Controller('muscles') | ||
export class MuscleController { | ||
constructor(private readonly muscleService: MuscleService) {} | ||
|
||
@Post() | ||
async create(@Body() muscleCreateInput: MuscleCreateInput) { | ||
return this.muscleService.create(muscleCreateInput); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AllowNull, AutoIncrement, Column, Model, PrimaryKey, Table } from 'sequelize-typescript'; | ||
|
||
@Table | ||
export class Muscle extends Model { | ||
@PrimaryKey | ||
@AutoIncrement | ||
@Column | ||
id: number; | ||
|
||
@AllowNull(false) | ||
@Column | ||
parts: string; | ||
|
||
@AllowNull(false) | ||
@Column | ||
createdAt: Date; | ||
|
||
@AllowNull(false) | ||
@Column | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { MuscleService } from './muscle.service'; | ||
import { MuscleController } from './muscle.controller'; | ||
import { muscleProviders } from './muscle.provider'; | ||
|
||
@Module({ | ||
providers: [MuscleService, ...muscleProviders], | ||
controllers: [MuscleController], | ||
}) | ||
export class MuscleModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Model } from 'sequelize-typescript'; | ||
import { Muscle } from './muscle.entity'; | ||
|
||
export const muscleProviders: { useValue: typeof Model; provide: string }[] = [ | ||
{ | ||
provide: 'MUSCLE_REPOSITORY', | ||
useValue: Muscle, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Sequelize } from 'sequelize-typescript'; | ||
import { Muscle } from './muscle.entity'; | ||
import { MuscleCreateInput } from './dto/muscle.dto'; | ||
|
||
@Injectable() | ||
export class MuscleService { | ||
constructor( | ||
@Inject('MUSCLE_REPOSITORY') | ||
private readonly muscleRepository: typeof Muscle, | ||
@Inject('SEQUELIZE') private readonly sequelizeProvider: Sequelize, | ||
) {} | ||
|
||
async getPage(): Promise<Muscle[]> { | ||
return this.muscleRepository.findAll(); | ||
} | ||
|
||
async create(input: MuscleCreateInput): Promise<Muscle> { | ||
return this.muscleRepository.create(input); | ||
} | ||
} |