14 | {
15 | import.meta.env.MODE === "development" &&
16 |
17 |
test user:
18 |
email: user@example.com
19 |
password: password
20 |
21 |
22 | }
23 |
24 |
25 |
26 |
27 | )
28 | }
--------------------------------------------------------------------------------
/apps/mint-api/src/auth/strategies/jwt-refresh.strategy.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from "@nestjs/common";
2 | import { PassportStrategy } from "@nestjs/passport";
3 | import { Request } from "express";
4 | import { ExtractJwt, Strategy } from "passport-jwt";
5 | import TokenPayload from "../TokenPayload.interface";
6 | import { AuthService } from "../auth.service";
7 |
8 | @Injectable()
9 | export class JwtRefreshStrategy extends PassportStrategy(Strategy, 'jwt-refresh') {
10 |
11 | constructor(
12 | private authService: AuthService
13 | ) {
14 | super({
15 | jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
16 | ignoreExpiration: false,
17 | secretOrKey: process.env.JWT_REFRESH_TOKEN_SECRET as string,
18 | passReqToCallback: true
19 | });
20 | }
21 |
22 | validate(req: Request, payload: TokenPayload): unknown {
23 | const refreshToken = req.headers.authorization!.replace("Bearer ", '')
24 | return this.authService.verifyUserRefreshToken(refreshToken, payload.sub)
25 | }
26 | }
--------------------------------------------------------------------------------
/apps/mint-admin/src/CanvasLayer.ts:
--------------------------------------------------------------------------------
1 | import * as L from "leaflet";
2 |
3 | interface CanvasLayerOptions extends L.LayerOptions {
4 | renderer: L.Canvas;
5 | }
6 |
7 | export class CanvasLayer extends L.Layer {
8 | declare options: CanvasLayerOptions;
9 | declare _renderer: L.Canvas;
10 | declare _map: L.Map;
11 |
12 | constructor(options: CanvasLayerOptions) {
13 | super(options);
14 | }
15 |
16 | onAdd(map: L.Map) {
17 | this._map = map;
18 | this._renderer = this.options.renderer;
19 | (this._renderer as any)._layers[L.stamp(this)] = this;
20 | this.redraw();
21 | return this;
22 | }
23 |
24 | onRemove() {
25 | delete (this._renderer as any)._layers[L.stamp(this)];
26 | (this._renderer as any)._redraw();
27 | return this;
28 | }
29 |
30 | redraw() {
31 | (this._renderer as any)._redraw();
32 | }
33 |
34 | _update() {
35 | const ctx = (this._renderer as any)._ctx as CanvasRenderingContext2D;
36 |
37 | ctx.fillStyle = "red";
38 | ctx.fillRect(10, 10, 50, 50);
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/apps/mint-api/README.md:
--------------------------------------------------------------------------------
1 |
2 | Adminer credentials
3 |
4 | |key|value|
5 | |----|----|
6 | |System|PostgreSQL|
7 | |Server|db|
8 | |Username|postgres|
9 | |Password|example|
10 | |Database|postgres|
11 |
12 | ## Setup
13 |
14 | 1. Dupe .env.example and rename it to .env (update the environment variables)
15 |
16 | 2. Install npm dependancies
17 |
18 | ```
19 | npm i
20 | ```
21 |
22 | 3. Start docker services
23 |
24 | ```
25 | docker compose up -d
26 | ```
27 |
28 | 3. Push database schema
29 |
30 | ```
31 | npx drizzle-kit push
32 | ```
33 |
34 | 4. Init database
35 |
36 | ```
37 | npm run db:init
38 | ```
39 |
40 | ## Usefull commands
41 |
42 | Reset & restart database
43 |
44 | ```
45 | docker compose down -v && docker compose up -d
46 | ```
47 |
48 | ## Todo
49 |
50 | Rechecker les notnull dans les différents champs de la db
51 | faire des clés composites sur les tables de liaison plutot que id autoincrement
52 | ajouter des tables pour rentrer son équipement
53 | Ajouter des la localisation de la ville
54 | dans le seeder relier les standard_distances
--------------------------------------------------------------------------------
/packages/db/src/relations/organizations.relations.ts:
--------------------------------------------------------------------------------
1 | import { relations } from "drizzle-orm";
2 | import { event_campaigns_table, events_table, organizations_table } from "../tables/organizations";
3 | import { medias_table } from "../tables/medias";
4 |
5 | export const organizationsRelations = relations(organizations_table, ({ one, many }) => ({
6 | avatar: one(medias_table, {
7 | fields: [organizations_table.media_avatar_id],
8 | references: [medias_table.id],
9 | }),
10 |
11 | banner: one(medias_table, {
12 | fields: [organizations_table.media_avatar_id],
13 | references: [medias_table.id],
14 | }),
15 |
16 | events: many(events_table)
17 | }));
18 |
19 | export const eventsRelations = relations(events_table, ({ one }) => ({
20 | campaign: one(event_campaigns_table, {
21 | fields: [events_table.event_campaign_id],
22 | references: [event_campaigns_table.id],
23 | }),
24 |
25 | organization: one(organizations_table, {
26 | fields: [events_table.organization_id],
27 | references: [organizations_table.id],
28 | }),
29 | }));
--------------------------------------------------------------------------------
/apps/mint-admin/src/components/ui/input.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6 | return (
7 |