Skip to content

Commit

Permalink
Merge pull request #7 from SantiagoJavierRubio/presentation
Browse files Browse the repository at this point in the history
Presentation edits
  • Loading branch information
SantiagoJavierRubio committed Dec 1, 2023
2 parents 73bee10 + 6a22289 commit ad4c237
Show file tree
Hide file tree
Showing 9 changed files with 7,284 additions and 7,288 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ports
CLIENT_PORT=
SERVER_PORT=

# Auth
GITHUB_TOKEN=

# Repo data
REPO_OWNER=
REPO_NAME=
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# Git commit history
# Git commit history
### Fullstack webapp to show commit history of a single repo. Built with NestJS and React

Take-Home test made for Fulltimeforce selection process

## Instructions
Start by cloning this repo
```
git clone https://github.com/SantiagoJavierRubio/git-commit-history.git
```
Then access new repo folder
```
cd git-commit-history
```
After that create a .env from [example](.env.example) file
```
copy .env.example .env
```

### Fill out your new .env fields
> *CLIENT_PORT* --> localhost port to run client app
>
> **SERVER_PORT** --> localhost port to run nest app -> **required**
>
> **GITHUB_TOKEN** --> your own github token [(More info)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) -> **required**
>
> *REPO_OWNER* --> leave empty to use this repository's data, else add the owner name of the repo you want to use
>
> *REPO_NAME* --> leave empty to use this repository's data, else add the repository name you want to use
Install packages
```
yarn
# or
npm install
# or
pnpm install
```

Run app
```
yarn dev
# or
npm run dev
# or
pnpm dev
```

And both client and server should be available at http://localhost: \<Your configured ports>

# Techs used

* [Turborepo](https://turbo.build/repo)
* [Typescript](https://www.typescriptlang.org/)
* [Vite](https://vitejs.dev/)
* [React](https://react.dev/)
* [Nest](https://nestjs.com/)
* [Tanstack Query](https://tanstack.com/query/v4/docs/react/overview)
* [Tanstack Table](https://tanstack.com/table/v8)
* [Swagger](https://swagger.io/specification/)
* [TailwindCSS](https://tailwindcss.com/)

# External APIs

* [Github Api](https://docs.github.com/en/rest?apiVersion=2022-11-28)

5 changes: 3 additions & 2 deletions apps/client/src/api/getCommits.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios'
import type {} from 'types'

const serverPort = import.meta.env.SERVER_PORT

export default function getCommits() {
return axios.get('http://localhost:3000/commits').then(res => res.data)
return axios.get(`http://localhost:${serverPort}/commits`).then(res => res.data)
}
2 changes: 1 addition & 1 deletion apps/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"@/*": ["./src/*"]
},
},
"include": ["src"],
"include": ["src", "src/config/config.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
7 changes: 7 additions & 0 deletions apps/client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import 'dotenv/config'

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -8,5 +9,11 @@ export default defineConfig({
alias: {
'@': '/src'
}
},
server: {
port: parseInt(process.env.CLIENT_PORT)
},
define: {
'import.meta.env.SERVER_PORT': JSON.stringify(process.env.SERVER_PORT)
}
})
14 changes: 11 additions & 3 deletions apps/server/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { z } from 'zod'

function validatePossiblyEmptyString(input: string, defaultVal: string) {
const parsed = z.string().min(1).safeParse(input)
return parsed.success ? parsed.data : defaultVal
}

export default () => ({
NODE_ENV: process.env.NODE_ENV || 'development',
githubToken: process.env.GITHUB_TOKEN,
repo: {
owner: process.env.REPO_OWNER ?? 'SantiagoJavierRubio',
name: process.env.REPO_NAME ?? 'git-commit-history'
}
owner: validatePossiblyEmptyString(process.env.REPO_OWNER, 'SantiagoJavierRubio'),
name: validatePossiblyEmptyString(process.env.REPO_NAME, 'git-commit-history')
},
PORT: process.env.SERVER_PORT
})
4 changes: 3 additions & 1 deletion apps/server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger/dist'
import { ConfigService } from '@nestjs/config'

async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true })
const config = app.get(ConfigService)
const swaggerConfig = new DocumentBuilder()
.setTitle('Git commit history API')
.setVersion('1.0')
.addTag('commits')
.build()
const document = SwaggerModule.createDocument(app, swaggerConfig)
SwaggerModule.setup('', app, document)
await app.listen(3000)
await app.listen(config.get('PORT'))
}
bootstrap()
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "turbo build",
"lint": "turbo lint",
"dev": "turbo dev",
"dev": "dotenv -- turbo dev",
"test": "turbo test",
"prepare": "husky install"
},
Expand All @@ -20,10 +20,11 @@
"packages/*"
],
"devDependencies": {
"dotenv-cli": "^7.3.0",
"eslint-config-custom": "*",
"prettier-config-custom": "*",
"husky": "^8.0.0",
"prettier": "^3.1.0",
"turbo": "^1.10.16",
"husky": "^8.0.0"
"prettier-config-custom": "*",
"turbo": "^1.10.16"
}
}
Loading

0 comments on commit ad4c237

Please sign in to comment.