Compare commits

..

No commits in common. "server" and "main" have entirely different histories.
server ... main

57 changed files with 2 additions and 1263 deletions

6
.gitignore vendored
View file

@ -1,4 +1,2 @@
client/robots.txt
client/sitemap.xml
server/node_modules
.obsidian
robots.txt
sitemap.xml

View file

@ -1,4 +1,2 @@
# saoulbonmonsieur
Le site web officiel de l'avocat sur loi de le miament.
Lien vers l'explication du dossier [server](server/README.md)

View file

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

View file

Before

Width:  |  Height:  |  Size: 370 KiB

After

Width:  |  Height:  |  Size: 370 KiB

View file

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View file

Before

Width:  |  Height:  |  Size: 7.9 MiB

After

Width:  |  Height:  |  Size: 7.9 MiB

View file

Before

Width:  |  Height:  |  Size: 436 KiB

After

Width:  |  Height:  |  Size: 436 KiB

View file

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

View file

Before

Width:  |  Height:  |  Size: 418 KiB

After

Width:  |  Height:  |  Size: 418 KiB

View file

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

Before

Width:  |  Height:  |  Size: 357 KiB

After

Width:  |  Height:  |  Size: 357 KiB

View file

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 183 KiB

View file

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 145 KiB

View file

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 322 KiB

View file

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 513 KiB

View file

Before

Width:  |  Height:  |  Size: 521 KiB

After

Width:  |  Height:  |  Size: 521 KiB

View file

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 536 KiB

View file

Before

Width:  |  Height:  |  Size: 580 KiB

After

Width:  |  Height:  |  Size: 580 KiB

View file

Before

Width:  |  Height:  |  Size: 535 KiB

After

Width:  |  Height:  |  Size: 535 KiB

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 6.5 MiB

After

Width:  |  Height:  |  Size: 6.5 MiB

View file

Before

Width:  |  Height:  |  Size: 777 KiB

After

Width:  |  Height:  |  Size: 777 KiB

View file

Before

Width:  |  Height:  |  Size: 5.3 MiB

After

Width:  |  Height:  |  Size: 5.3 MiB

View file

@ -1,18 +0,0 @@
# Server API for Saoul Bonmonsieur
Because each website need to fetch some data from a database I needed to make an API. In fact, I don't really like Frameworks, they are too complex for the simpliest ideas. However I really familiarized with the PERN stack. Postgresql being easy to install, use, and being one of the fastest Database, the choice was rather obvious.
## Launch the server
You first need to install the required modules with npm.
```bash
npm i express pg cors
```
Then we launch the server with nodemon if there is a change. Or simply with node if it's a release build.
```bash
nodemon index
```
```
node index
```

View file

@ -1,6 +0,0 @@
CREATE DATABASE saoulbonmonsieur;
CREATE TABLE todo(
todo_id SERIAL PRIMARY KEY,
description VARCHAR(255)
);

View file

@ -1,11 +0,0 @@
const Pool = require("pg").Pool;
const pool = new Pool({
user: "postgres",
password: "postgres",
host: "localhost",
database: "saoulbonmonsieur",
port: 5432
})
module.exports = pool;

View file

@ -1,36 +0,0 @@
const express = require("express");
const app = express();
const cors = require("cors");
const pool = require("./db");
// Middleware
app.use(cors());
// Allows tp access the req.body
app.use(express.json());
//ROUTES//
//get all todos
//get a todo
//create a todo
app.post("/todos", async (req, res) => {
try {
const { description } = req.body;
const newTodo = await pool.query("INSERT INTO todo (description) VALUES ($1) RETURNING *", [description]);
res.json(newTodo);
} catch (error) {
console.error(error.message);
}
})
//update a todo
//delete a todo
//Creating the api
app.listen(5000, () => {
console.log("Server is starting on port 5000");
})

1166
server/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,20 +0,0 @@
{
"name": "saulbonmonsieur_api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon server.js"
},
"keywords": [],
"author": "Yohan Boujon",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.18.2",
"morgan": "^1.10.0",
"nodemon": "^2.0.4",
"pg": "^8.11.1"
}
}