Skip to content

Commit 6eb970f

Browse files
committed
Fix identazione
1 parent f85fc53 commit 6eb970f

File tree

4 files changed

+76
-104
lines changed

4 files changed

+76
-104
lines changed

jsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": [
3-
"./src/**/*"
4-
]
5-
}
2+
"include": [
3+
"./src/**/*"
4+
]
5+
}

server/database/User.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const mongoose = require('mongoose');
1+
const mongoose = require("mongoose");
22
const userSchema = new mongoose.Schema({
3-
firstName: String,
4-
lastName: String,
5-
nickname: String,
6-
biography: String,
7-
email: String,
8-
password: String,
9-
postedAds: [{ title: String }]
3+
firstName: String,
4+
lastName: String,
5+
nickname: String,
6+
biography: String,
7+
email: String,
8+
password: String,
9+
postedAds: [{ title: String }],
1010
});
1111

1212
const User = mongoose.model("User", userSchema);
13-
module.exports = User;
13+
module.exports = User;

server/database/database.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
1-
const mongoose = require('mongoose');
1+
const mongoose = require("mongoose");
22
const fs = require("fs/promises");
33
const path = require("path");
44

55
const configurationTemplate = {
6-
databaseName: "teacherfinder",
7-
connectionString: `mongodb://127.0.0.1:27071/${configurationTemplate.databaseName}`
6+
databaseName: "teacherfinder",
7+
connectionString: `mongodb://127.0.0.1:27071/${configurationTemplate.databaseName}`,
88
};
99

1010
const CONFIG_PATH = path.join(__dirname, "db-config.json");
1111

12-
fs.fileExists = async function(path) {
13-
try {
14-
await fs.stat(path);
15-
return true;
16-
} catch {
17-
return false;
18-
}
19-
}
12+
fs.fileExists = async function (path) {
13+
try {
14+
await fs.stat(path);
15+
return true;
16+
} catch {
17+
return false;
18+
}
19+
};
2020

2121
module.exports = class Database {
22-
static mongoConnection;
23-
static mongoConfig;
24-
static async generateConfigurationTemplate() {
25-
if(!(await fs.fileExists(CONFIG_PATH))) {
26-
try {
27-
// se non esiste già creo file di configurazione da template
28-
await fs.writeFile(CONFIG_PATH, JSON.stringify(configurationTemplate));
29-
return true;
30-
} catch {
31-
return false;
32-
}
33-
} else {
34-
return false;
35-
}
22+
static mongoConnection;
23+
static mongoConfig;
24+
static async generateConfigurationTemplate() {
25+
if (!(await fs.fileExists(CONFIG_PATH))) {
26+
try {
27+
// se non esiste già creo file di configurazione da template
28+
await fs.writeFile(CONFIG_PATH, JSON.stringify(configurationTemplate));
29+
return true;
30+
} catch {
31+
return false;
32+
}
33+
} else {
34+
return false;
3635
}
36+
}
3737

38-
static async readConfiguration() {
39-
await Database.generateConfigurationTemplate();
40-
this.mongoConfig = await fs.readFile(CONFIG_PATH, "utf-8");
41-
this.mongoConfig = JSON.parse(this.mongoConfig);
42-
}
38+
static async readConfiguration() {
39+
await Database.generateConfigurationTemplate();
40+
this.mongoConfig = await fs.readFile(CONFIG_PATH, "utf-8");
41+
this.mongoConfig = JSON.parse(this.mongoConfig);
42+
}
4343

44-
static async connect() {
45-
if(typeof this.mongoConfig !== "undefined") {
46-
this.mongoConnection = await mongoose.connect(this.mongoConfig.connectionString);
47-
return this.mongoConnection;
48-
} else
49-
throw new Error("Nessuna configurazione caricata!");
50-
}
44+
static async connect() {
45+
if (typeof this.mongoConfig !== "undefined") {
46+
this.mongoConnection = await mongoose.connect(
47+
this.mongoConfig.connectionString
48+
);
49+
return this.mongoConnection;
50+
} else throw new Error("Nessuna configurazione caricata!");
51+
}
5152

52-
static isConnected() {
53-
return (typeof Database.mongoConnection !== "undefined");
54-
}
55-
}
53+
static isConnected() {
54+
return typeof Database.mongoConnection !== "undefined";
55+
}
56+
};

server/index.js

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,94 +8,65 @@ const port = 8080;
88

99
// Definisco endpoint API lato server
1010
app.get("/api", (req, res) => {
11-
res.send({ works: true });
11+
res.send({ works: true });
1212
});
1313

1414
// Endpoint Utente
1515
// ===============
16-
app.get("/api/user/login", (req, res) => {
17-
18-
});
16+
app.get("/api/user/login", (req, res) => {});
1917

20-
app.get("/api/user/logout", (req, res) => {
21-
22-
});
18+
app.get("/api/user/logout", (req, res) => {});
2319

24-
app.get("/api/user/checkToken", (req, res) => {
25-
26-
});
20+
app.get("/api/user/checkToken", (req, res) => {});
2721

2822
// Endpoint Annunci
2923
// ================
30-
app.get("/api/ads/list/:userId", (req, res) => {
24+
app.get("/api/ads/list/:userId", (req, res) => {});
3125

32-
});
26+
app.get("/api/ads/search/:keyword", (req, res) => {});
3327

34-
app.get("/api/ads/search/:keyword", (req, res) => {
28+
app.get("/api/ads/getAdInfo/:id", (req, res) => {});
3529

36-
});
37-
38-
app.get("/api/ads/getAdInfo/:id", (req, res) => {
39-
40-
});
41-
42-
app.post("/api/ads/createAd", (req, res) => {
43-
44-
});
30+
app.post("/api/ads/createAd", (req, res) => {});
4531

4632
// Endpoint Recensioni
4733
// ===================
48-
app.get("/api/reviews/getReviews/:adId", (req, res) => {
49-
50-
});
34+
app.get("/api/reviews/getReviews/:adId", (req, res) => {});
5135

52-
app.get("/api/reviews/getUserReviews/:userId", (req, res) => {
36+
app.get("/api/reviews/getUserReviews/:userId", (req, res) => {});
5337

54-
});
55-
56-
app.post("/api/reviews/postReview", (req, res) => {
57-
58-
});
38+
app.post("/api/reviews/postReview", (req, res) => {});
5939

6040
// Endpoint Iscrizioni
6141
// ===================
6242
app.put("/api/subscriptions/acceptSubscription", (req, res) => {
63-
// tutor
43+
// tutor
6444
});
6545

6646
app.put("/api/subscriptions/rejectSubscription", (req, res) => {
67-
// tutor
47+
// tutor
6848
});
6949

7050
app.put("/api/subscriptions/cancelSubscription", (req, res) => {
71-
// studente
51+
// studente
7252
});
7353

74-
app.put("/api/subscriptions/paySubscription", (req, res) => {
75-
76-
});
77-
78-
app.get("/api/subscriptions/list/:userId", (req, res) => {
54+
app.put("/api/subscriptions/paySubscription", (req, res) => {});
7955

80-
});
56+
app.get("/api/subscriptions/list/:userId", (req, res) => {});
8157

8258
// Endpoint Impostazioni
8359
// =====================
84-
app.get("/api/settings/current", (req, res) => {
85-
86-
});
87-
88-
app.put("/api/settings/change/:settingId/to/:newValue", (req, res) => {
89-
90-
});
60+
app.get("/api/settings/current", (req, res) => {});
9161

62+
app.put("/api/settings/change/:settingId/to/:newValue", (req, res) => {});
9263

9364
// Permetto a Vue.js di gestire le path single-page con Vue Router
9465
// Sul front-end compilato!
9566
app.use(history());
96-
app.use('/', express.static(path.join(__dirname, '..', 'dist')));
67+
app.use("/", express.static(path.join(__dirname, "..", "dist")));
9768

9869
// Avvio il server
9970
app.listen(port, () => {
100-
console.log(`Express server listening: http://localhost:${port}/`)
101-
});
71+
console.log(`Express server listening: http://localhost:${port}/`);
72+
});

0 commit comments

Comments
 (0)