Compare commits
No commits in common. "server" and "main" have entirely different histories.
6
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
||||||
client/robots.txt
|
robots.txt
|
||||||
client/sitemap.xml
|
sitemap.xml
|
||||||
server/node_modules
|
|
||||||
.obsidian
|
|
|
@ -1,4 +1,2 @@
|
||||||
# saoulbonmonsieur
|
# saoulbonmonsieur
|
||||||
Le site web officiel de l'avocat sur loi de le miament.
|
Le site web officiel de l'avocat sur loi de le miament.
|
||||||
|
|
||||||
Lien vers l'explication du dossier [server](server/README.md)
|
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 370 KiB After Width: | Height: | Size: 370 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 7.9 MiB After Width: | Height: | Size: 7.9 MiB |
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 436 KiB |
Before Width: | Height: | Size: 3.8 MiB After Width: | Height: | Size: 3.8 MiB |
Before Width: | Height: | Size: 418 KiB After Width: | Height: | Size: 418 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 183 KiB |
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 322 KiB |
Before Width: | Height: | Size: 513 KiB After Width: | Height: | Size: 513 KiB |
Before Width: | Height: | Size: 521 KiB After Width: | Height: | Size: 521 KiB |
Before Width: | Height: | Size: 536 KiB After Width: | Height: | Size: 536 KiB |
Before Width: | Height: | Size: 580 KiB After Width: | Height: | Size: 580 KiB |
Before Width: | Height: | Size: 535 KiB After Width: | Height: | Size: 535 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 6.5 MiB After Width: | Height: | Size: 6.5 MiB |
Before Width: | Height: | Size: 777 KiB After Width: | Height: | Size: 777 KiB |
Before Width: | Height: | Size: 5.3 MiB After Width: | Height: | Size: 5.3 MiB |
0
client/lib/anime.min.js → lib/anime.min.js
vendored
|
@ -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
|
|
||||||
```
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE DATABASE saoulbonmonsieur;
|
|
||||||
|
|
||||||
CREATE TABLE todo(
|
|
||||||
todo_id SERIAL PRIMARY KEY,
|
|
||||||
description VARCHAR(255)
|
|
||||||
);
|
|
11
server/db.js
|
@ -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;
|
|
|
@ -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
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|