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

Refacto/wild 017 paginer urls #41

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b511cb4
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 5, 2024
0ad401d
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 5, 2024
33cfd39
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 9, 2024
d53167a
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 9, 2024
a9ccbfc
WILD-008 : Feat - Ajout User et Mutation Enregistrement
Jul 10, 2024
9c2edc2
WILD-008 : Feat - Ajout User et Mutation enregistrement
Jul 10, 2024
681f770
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 10, 2024
75a1945
Merge pull request #23 from WildCodeSchool/feat/WILD-008_Enregistreme…
LightQv Jul 10, 2024
1b35512
WILD_001: Refacto - Gestion message erreur
JTissot-Dev Jul 10, 2024
06b356d
Merge branch 'refacto/WILD_001_Gestion-retour-erreur' into develop
JTissot-Dev Jul 10, 2024
7eb3230
WILD_001: Resolve merge conflict
JTissot-Dev Jul 10, 2024
7da3d66
WILD-009: Feat - Formulaire de connexion
Jul 10, 2024
d563fe5
Merge pull request #25 from WildCodeSchool/feat/WILD-009_Formulaire-c…
LightQv Jul 10, 2024
8dffa5f
WILD-000: Init - migrations
JTissot-Dev Jul 10, 2024
82a0ab4
WILD-010 : Feat - Login fonctionnel
Jul 10, 2024
48d1fae
WILD_004: refacto - ajout de tests sur la pagination et le tri
Ellana33 Jul 10, 2024
542f689
Merge branch 'develop' into refacto/WILD_004_plus_de_tests
Ellana33 Jul 10, 2024
d25855a
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 10, 2024
55a3bb4
Merge pull request #26 from WildCodeSchool/refacto/WILD_004_plus_de_t…
Ellana33 Jul 10, 2024
9e33e9b
Merge pull request #27 from WildCodeSchool/feat/WILD-010_Connexion-ut…
LightQv Jul 10, 2024
ae14f78
Add : Theming, Logo, soft refacto design
Jul 10, 2024
47a0566
WILD-010 : Feat - Cookies header et donnée basique utilisateur
Jul 10, 2024
eea77b9
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 10, 2024
88f891a
WILD-012: feat - mise à jour Url Resolver, config codegen/docker
JTissot-Dev Jul 10, 2024
298be94
WILD-013: feat - Filtrer les URL
JTissot-Dev Jul 11, 2024
4bbfc80
Merge branch 'feat/WILD-013_Filtrer-les-urls' into develop
JTissot-Dev Jul 11, 2024
7c4b807
WILD-011 : Feat - Cookie dans le header
Jul 11, 2024
ae69122
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 11, 2024
10a3c84
Merge branch 'main' of https://github.com/WildCodeSchool/2024-02-wns-…
JTissot-Dev Jul 11, 2024
4db0816
Add : Populate Script for FakeDatas
Jul 11, 2024
16bae17
WILD-011 : Feat - Cookies dans le header & /me
Jul 11, 2024
540115d
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 11, 2024
ccdd41e
Merge pull request #28 from WildCodeSchool/feat/WILD-011_Cookie-header
LightQv Jul 11, 2024
81b30e1
WILD-012 : Feat - Login auto au register + lint
Jul 11, 2024
722e733
Merge pull request #29 from WildCodeSchool/feat/WILD-012_Register-aut…
LightQv Jul 11, 2024
b3ef639
WILD-014: - feat - trier les urls
JTissot-Dev Jul 11, 2024
d5dfce7
Merge branch 'develop' of https://github.com/WildCodeSchool/2024-02-w…
JTissot-Dev Jul 11, 2024
8f401d4
Merge branch 'WILD-014/trier_urls' into develop
JTissot-Dev Jul 11, 2024
0c0277c
WILD_004: refacto - ajout de pointillés pagination et de line break
Ellana33 Jul 11, 2024
62b0a36
WILD_004: tests - reparation des tests a l'exception de la barre de r…
Ellana33 Jul 11, 2024
5692bb1
WILD-017 : Feat - Ajout URL privé
Jul 12, 2024
92fa7c1
Merge pull request #30 from WildCodeSchool/refacto/WILD_004_style
Ellana33 Jul 12, 2024
1f1b751
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 12, 2024
8448968
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 12, 2024
e4dc196
WILD-017 : Feat - Ajout URL public ou privé en tant qu'utilisateur
Jul 12, 2024
7e8ce88
Merge pull request #31 from WildCodeSchool/feat/WILD-017_User-url
LightQv Jul 12, 2024
1345964
Refacto : Design de la page history d'une url
Jul 12, 2024
b235f86
WILD-017: Feat - Paginer les urls
JTissot-Dev Jul 12, 2024
d2ef255
WILD-018 : Feat - Historique privé récent
Jul 12, 2024
01433df
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
Jul 12, 2024
3169f09
WILD-018 : Feat - Historique privé récent
Jul 12, 2024
2dd7028
WILD-018 : Feat - Historique URL privée récent
Jul 12, 2024
4475778
Merge pull request #32 from WildCodeSchool/feat/WILD-018_Aperçu-histo…
LightQv Jul 12, 2024
ccaf083
Merge branch 'feat/WILD-017_Paginer-urls' into develop
JTissot-Dev Jul 12, 2024
d210a91
Refacto - ajout de tests pour la liste des historiques
LucasRatouit Jul 12, 2024
dac33b4
Merge pull request #33 from WildCodeSchool/feat/WILD_005_Pouvoir_cons…
LucasRatouit Jul 12, 2024
bd9851f
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 12, 2024
dde5432
Merge branch 'develop' of https://github.com/WildCodeSchool/2024-02-w…
JTissot-Dev Jul 12, 2024
62ee438
Merge branch 'develop' of https://github.com/WildCodeSchool/2024-02-w…
JTissot-Dev Jul 12, 2024
03e9622
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 12, 2024
940ee9f
CI : Format & Lint pass
Jul 12, 2024
dab5fa3
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 12, 2024
08d8cee
WILD_005 : Refacto - fix des tests
LucasRatouit Jul 12, 2024
bd5ebb4
Merge pull request #34 from WildCodeSchool/feat/WILD_005_Pouvoir_cons…
LucasRatouit Jul 12, 2024
d5a3342
Merge branch 'develop' of github.com:WildCodeSchool/2024-02-wns-jaune…
LucasRatouit Jul 12, 2024
7fe4ccc
feat : navigation inter-pages (urlHistory, logo)
LucasRatouit Jul 12, 2024
643282d
Commit before pull develop
JTissot-Dev Aug 20, 2024
5547715
Merge branch 'develop' of https://github.com/WildCodeSchool/2024-02-w…
JTissot-Dev Aug 20, 2024
a48bac8
Init: Initialize CI Test
JTissot-Dev Aug 20, 2024
0125b78
Merge pull request #35 from WildCodeSchool/init/WILD_000_CI-Test
JTissot-Dev Aug 20, 2024
02246ab
Add : CI for static testing (Formatting and Lint)
Aug 20, 2024
567701b
Init: Update CI Test
JTissot-Dev Aug 20, 2024
e829b56
CI : Formatting debug and applied
Aug 20, 2024
200d26c
Merge pull request #36 from WildCodeSchool/feat/CI-static
Aug 20, 2024
ca8c14b
Bugfix : Mistake on folder name
Aug 20, 2024
6d86a36
Merge pull request #38 from WildCodeSchool/feat/CI-static
Aug 20, 2024
fbbc2b6
CI : Formatting files
Aug 20, 2024
54a7f52
Merge branch 'develop' of https://github.com/WildCodeSchool/2024-02-w…
Aug 20, 2024
5f20fcd
CI back : Formatting and test CI
Aug 20, 2024
d1af822
Remove : CI test comment
Aug 20, 2024
0d5ae01
Essai: test-ci
JTissot-Dev Aug 20, 2024
7a40fa9
Essai: test-ci v2
JTissot-Dev Aug 20, 2024
9b36421
Essai test-ci v3, maj env
JTissot-Dev Aug 20, 2024
1605f7e
Essai: test-ci V4 maj sortie conteneur après test
JTissot-Dev Aug 20, 2024
53323d2
Merge pull request #40 from WildCodeSchool/try/WILD-000_Essai-test-ci
JTissot-Dev Aug 20, 2024
965be6d
WILD-017: Refacto - Paginer urls
JTissot-Dev Aug 21, 2024
8d2a7c3
refacto/WILD_017_Paginer-urls v2
JTissot-Dev Aug 21, 2024
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
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ POSTGRES_HOST=
POSTGRES_PORT=
POSTGRES_USER=
POSTGRES_DB=
POSTGRES_PASSWORD=
POSTGRES_PASSWORD=

JWT_SECRET_KEY=

COOKIE_TTL=
46 changes: 46 additions & 0 deletions .github/workflows/Backend-Static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Backend CI

on:
push:
paths:
- 'back/**'

jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm install
working-directory: back

- name: Check formatting
run: npx prettier .
working-directory: back

lint:
needs: format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm install
working-directory: back

- name: Lint
run: npm run lint
working-directory: back
46 changes: 46 additions & 0 deletions .github/workflows/Frontend-Static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Frontend CI

on:
push:
paths:
- 'front/**'

jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm install
working-directory: front

- name: Check formatting
run: npx prettier .
working-directory: front

lint:
needs: format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm install
working-directory: front

- name: Lint
run: npm run lint
working-directory: front
28 changes: 28 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test-ci


on:
pull_request:
paths-ignore:
- 'data/**'
- 'front/src/generated/**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Build and test
run: docker compose -f docker-compose.test.yaml up --abort-on-container-exit
env:
APP_ENV: ${{ secrets.APP_ENV }}
VITE_API_URL: ${{ secrets.VITE_API_URL }}
BACKEND_PORT: ${{ secrets.BACKEND_PORT }}
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
COOKIE_TTL: ${{ secrets.COOKIE_TTL }}
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
OS := $(shell uname -s)

ifeq ($(OS), Linux)
RM = sudo rm -rf
else ifeq ($(OS), Darwin) # macOS
RM = sudo rm -rf
else ifeq ($(OS), Windows_NT)
RM = rmdir /s /q
else
RM = echo "Unsupported OS"
endif

build-dev:
docker compose -f docker-compose.dev.yaml up --build

Expand All @@ -11,4 +23,18 @@ build-prod:
docker compose -f docker-compose.yaml up --build

run-prod:
docker compose -f docker-compose.yaml up
docker compose -f docker-compose.yaml up

# Après la commande, ajouter name=(NomDeLaMigration)
generate-migration:
docker exec -it backend npm run migration:generate -- src/database/migrations/$(name)

populate-db:
docker exec -it backend npm run populate-db

clean-dev:
docker compose -f docker-compose.dev.yaml down
docker rm -f $(shell docker ps -a -q) 2> /dev/null || true
docker volume rm $(shell docker volume ls -q) 2> /dev/null || true
$(RM) data
docker system prune -f
5 changes: 5 additions & 0 deletions back/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ module.exports = {
rules: {
// Vous pouvez ajouter ou modifier des règles spécifiques ici
},
overrides: [
{
files: ["*.ts"],
},
],
};
30 changes: 18 additions & 12 deletions back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,48 @@
"main": "src/index.ts",
"scripts": {
"test": "jest",
"lint": "npx eslint --ext .ts src",
"lint": "npx eslint src",
"dev": "ts-node-dev --poll src/index.ts",
"seed": "ts-node-dev src/database/seeder/fixtures.ts"
"seed": "ts-node-dev src/database/seeder/fixtures.ts",
"populate-db": "ts-node src/database/scripts/PopulateDB.ts",
"migration:create": "typeorm-ts-node-commonjs migration:create",
"migration:generate": "typeorm-ts-node-commonjs migration:generate -d src/database/dataSource.ts",
"migration:up": "typeorm-ts-node-commonjs migration:run -d src/database/dataSource.ts",
"migration:down": "typeorm-ts-node-commonjs migration:revert -d src/database/dataSource.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@apollo/server": "4.10.4",
"argon2": "0.40.3",
"axios": "^1.7.2",
"class-validator": "^0.14.1",
"axios": "1.7.2",
"class-validator": "0.14.1",
"cors": "2.8.5",
"dotenv": "16.4.5",
"express": "4.19.2",
"graphql": "16.8.2",
"graphql-scalars": "1.23.0",
"jsonwebtoken": "9.0.2",
"pg": "^8.12.0",
"pg": "8.12.0",
"reflect-metadata": "0.2.2",
"type-graphql": "2.0.0-rc.1",
"typeorm": "0.3.20"
},
"devDependencies": {
"@types/cors": "2.8.17",
"@types/express": "4.17.21",
"@types/jest": "^29.5.12",
"@types/jest": "29.5.12",
"@types/jsonwebtoken": "9.0.6",
"@types/node": "20.14.9",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"eslint": "8.56.0",
"@types/supertest": "6.0.2",
"@typescript-eslint/eslint-plugin": "7.15.0",
"eslint": "8.57.0",
"globals": "15.8.0",
"jest": "^29.7.0",
"supertest": "^7.0.0",
"ts-jest": "^29.2.0",
"jest": "29.7.0",
"prettier": "3.3.2",
"supertest": "7.0.0",
"ts-jest": "29.2.0",
"ts-node-dev": "2.0.0"
}
}
20 changes: 19 additions & 1 deletion back/src/__tests__/Url.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dataSource from "../database/dataSource";
import { Url } from "../entities/Url";
import { ILike } from "typeorm";

describe("Integration Test Url Entity", () => {
beforeAll(async () => {
Expand All @@ -10,7 +11,24 @@ describe("Integration Test Url Entity", () => {
});

it("find method should return a list of Url", async () => {
const urls = await Url.find();
const urls = await Url.find({
order: { createdAt: "DESC" },
});

// Check if the result is an array
expect(Array.isArray(urls)).toBeTruthy();

// Check if values are instances of Url
urls.forEach((url) => {
expect(url).toBeInstanceOf(Url);
});
});

it("find with where method and order should return a list of Url in clause", async () => {
const urls = await Url.find({
where: [{ name: ILike(`%Fa%`) }, { path: ILike(`%Fa%`) }],
order: { createdAt: "DESC" },
});

// Check if the result is an array
expect(Array.isArray(urls)).toBeTruthy();
Expand Down
9 changes: 7 additions & 2 deletions back/src/database/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { DataSource } from "typeorm";
import { Url } from "../entities/Url";
import { History } from "../entities/History";
import { UrlSubscriber } from "../subscribers/UrlSubscribers";
import { User } from "../entities/User";
import { InitDbUrlHistoryUser1720618090787 } from "./migrations/1720618090787-Init_db_Url_History_User";
import { AddUserUrl1720710308167 } from "./migrations/1720710308167-Add-UserUrl";
import { UserUrl } from "../entities/UserUrl";

const dataSource = new DataSource({
type: "postgres",
Expand All @@ -10,10 +14,11 @@ const dataSource = new DataSource({
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
synchronize: true,
synchronize: process.env.APP_ENV === "test",
logging: process.env.APP_ENV === "dev",
entities: [Url, History],
entities: [Url, History, User, UserUrl],
subscribers: [UrlSubscriber],
migrations: [InitDbUrlHistoryUser1720618090787, AddUserUrl1720710308167],
});

export default dataSource;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class InitDbUrlHistoryUser1720618090787 implements MigrationInterface {
name = "InitDbUrlHistoryUser1720618090787";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "status_code" integer NOT NULL, "response" text NOT NULL, "urlId" uuid, CONSTRAINT "PK_9384942edf4804b38ca0ee51416" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "url" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(55) NOT NULL, "path" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_7421088122ee64b55556dfc3a91" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "user" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "username" character varying NOT NULL, "email" character varying NOT NULL, "hashedPassword" character varying NOT NULL, CONSTRAINT "UQ_78a916df40e02a9deb1c4b75edb" UNIQUE ("username"), CONSTRAINT "UQ_e12875dfb3b1d92d7d7c5377e22" UNIQUE ("email"), CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "history" ADD CONSTRAINT "FK_9b8293dadd944e8ad0dc4e8ecaa" FOREIGN KEY ("urlId") REFERENCES "url"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "history" DROP CONSTRAINT "FK_9b8293dadd944e8ad0dc4e8ecaa"`,
);
await queryRunner.query(`DROP TABLE "user"`);
await queryRunner.query(`DROP TABLE "url"`);
await queryRunner.query(`DROP TABLE "history"`);
}
}
27 changes: 27 additions & 0 deletions back/src/database/migrations/1720710308167-Add-UserUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class AddUserUrl1720710308167 implements MigrationInterface {
name = "AddUserUrl1720710308167";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "user_url" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "userId" uuid NOT NULL, "urlId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "REL_2d3c4059016f20361da982c5d9" UNIQUE ("urlId"), CONSTRAINT "PK_8644584d3620c8fd95111270b75" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "user_url" ADD CONSTRAINT "FK_44c91da328f0e8292edb2c7ed73" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "user_url" ADD CONSTRAINT "FK_2d3c4059016f20361da982c5d9d" FOREIGN KEY ("urlId") REFERENCES "url"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user_url" DROP CONSTRAINT "FK_2d3c4059016f20361da982c5d9d"`,
);
await queryRunner.query(
`ALTER TABLE "user_url" DROP CONSTRAINT "FK_44c91da328f0e8292edb2c7ed73"`,
);
await queryRunner.query(`DROP TABLE "user_url"`);
}
}
Loading
Loading