sqlite3 #2

Merged
clement.freville2 merged 15 commits from sqlite3 into main 11 months ago
Owner

Ajout de la base de données en Sqlite3 et des méthodes permettant de faire des actions sur la base de données.

Ajout de la base de données en Sqlite3 et des méthodes permettant de faire des actions sur la base de données.
hugo.pradier2 added 10 commits 11 months ago
continuous-integration/drone/push Build is passing Details
ebdfcb1bff
Integration bd sqlite3
continuous-integration/drone/push Build is passing Details
20d15ce6d6
Creation de la table + ajout user
continuous-integration/drone/push Build is passing Details
9fcc8a806c
api fonctionnelle pour action sur la table user
continuous-integration/drone/push Build is passing Details
4fe64e0601
retour json fonctionnel
continuous-integration/drone/push Build is passing Details
7047c3d4d3
action sur user avec retour promesse complet
continuous-integration/drone/push Build is passing Details
e3ba698b3a
Add the languages table
continuous-integration/drone/push Build is passing Details
7c65066ca9
Add the start of the work table
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details
09842511b8
ajout du champ link a Work + methode supprimer user par login + revu des commentaires
clement.freville2 was assigned by hugo.pradier2 11 months ago
clement.freville2 added 1 commit 11 months ago
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
490c9188f5
Merge branch 'main' into sqlite3
clement.freville2 requested changes 11 months ago
package.json Outdated
"@sinclair/typebox": "^0.32.9",
"fastify": "^4.25.2",
"fastify": "^4.27.0",
"fastify-sqlite-typed": "^0.1.1",

This dependency is not used.

This dependency is not used.
clement.freville2 marked this conversation as resolved
src/database.ts Outdated
}
/* Fonction pour récupérer plusieurs lignes de la base de données */
function allDB(db: sqlite3.Database, query: string): Promise<any[]> {
-function allDB(db: sqlite3.Database, query: string): Promise<any[]> {
+function allDB<T>(db: sqlite3.Database, query: string): Promise<T[]> {
``
```diff -function allDB(db: sqlite3.Database, query: string): Promise<any[]> { +function allDB<T>(db: sqlite3.Database, query: string): Promise<T[]> { ``
clement.freville2 marked this conversation as resolved
db: sqlite3.Database,
query: string,
params: any[],
): Promise<void> {
-function getDB(
+function getDB<T>(
   db: sqlite3.Database,
   query: string,
   params: any[],
-): Promise<void> {
+): Promise<T[]> {
```diff -function getDB( +function getDB<T>( db: sqlite3.Database, query: string, params: any[], -): Promise<void> { +): Promise<T[]> { ```
clement.freville2 marked this conversation as resolved
src/database.ts Outdated
}
/////////////////////////// Export des fonctions ///////////////////////////
export {

You can use the export keywork before each function declaration, instead of grouping them at the end of the file.

You can use the `export` keywork before each function declaration, instead of grouping them at the end of the file.
clement.freville2 marked this conversation as resolved
src/server.ts Outdated
updateUserLogin,
updateUserPassword,
updateUserPermissions,
} from './database';

You may use a wildcard import here, it would reduce the size of the import:

import * as db from './database';
// ...
db.createTables();
You may use a wildcard import here, it would reduce the size of the import: ```ts import * as db from './database'; // ... db.createTables(); ```
clement.freville2 marked this conversation as resolved
src/server.ts Outdated
fastify.put<{
Params: { id: string };
Body: { newPermissions: number };
}>('/users/:id/permissions', async (request, reply) => {
-fastify.put<{
-  Params: { id: string };
-  Body: { newPermissions: number };
-}>('/users/:id/permissions', async (request, reply) => {
+fastify.put('/users/:id/permissions', {
+  schema: {
+    params: Type.Object({
+      id: Type.Number({
+        minimum: 0
+      })
+    }),
+    body: Type.Object({
+      newPermissions: Type.Number(),
+    })
+  },
+}, async (request, reply) => {

Using TypeBox would allow Fastify to check the structure before it even reach your handler (and it will enforce numbers).

```diff -fastify.put<{ - Params: { id: string }; - Body: { newPermissions: number }; -}>('/users/:id/permissions', async (request, reply) => { +fastify.put('/users/:id/permissions', { + schema: { + params: Type.Object({ + id: Type.Number({ + minimum: 0 + }) + }), + body: Type.Object({ + newPermissions: Type.Number(), + }) + }, +}, async (request, reply) => { ``` Using TypeBox would allow Fastify to check the structure before it even reach your handler (and it will enforce numbers).
clement.freville2 marked this conversation as resolved
src/server.ts Outdated
reply.send(user);
});
/* Route pour créer un language */

For now, let's not expose an REST API to manage languages.

For now, let's not expose an REST API to manage languages.
clement.freville2 marked this conversation as resolved
hugo.pradier2 added 2 commits 11 months ago
hugo.pradier2 added 1 commit 11 months ago
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
49cf852117
fail build drone
hugo.pradier2 requested review from clement.freville2 11 months ago
hugo.pradier2 added 1 commit 11 months ago
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
265899ecee
retirer le fichier database.db
clement.freville2 approved these changes 11 months ago
clement.freville2 merged commit b58317ae88 into main 11 months ago
clement.freville2 deleted branch sqlite3 11 months ago

Reviewers

clement.freville2 approved these changes 11 months ago
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
The pull request has been merged as b58317ae88.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: sandkasten/labyrinth#2
Loading…
There is no content yet.