Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
c336cd4503 |
6
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
robots.txt
|
||||
sitemap.xml
|
||||
client/robots.txt
|
||||
client/sitemap.xml
|
||||
server/node_modules
|
||||
.obsidian
|
|
@ -1,2 +1,4 @@
|
|||
# saoulbonmonsieur
|
||||
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
lib/anime.min.js → client/lib/anime.min.js
vendored
18
server/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# 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
|
||||
```
|
6
server/database.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE DATABASE saoulbonmonsieur;
|
||||
|
||||
CREATE TABLE todo(
|
||||
todo_id SERIAL PRIMARY KEY,
|
||||
description VARCHAR(255)
|
||||
);
|
11
server/db.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const Pool = require("pg").Pool;
|
||||
|
||||
const pool = new Pool({
|
||||
user: "postgres",
|
||||
password: "postgres",
|
||||
host: "localhost",
|
||||
database: "saoulbonmonsieur",
|
||||
port: 5432
|
||||
})
|
||||
|
||||
module.exports = pool;
|
36
server/index.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
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
Normal file
20
server/package.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
}
|