Skip to content

Commit 4a5f21f

Browse files
committed
code reformatted using prettier
1 parent 810e6de commit 4a5f21f

34 files changed

+8592
-8560
lines changed

README.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
A simple way to solve your complex parking issues.
44

55
---
6+
67
## Requirements
78

89
For development, you will only need Node.js and a node global package, npm, installed in your environement.
910

1011
### Node
11-
- #### Node installation on Windows
1212

13-
Just go on [official Node.js website](https://nodejs.org/) and download the installer.
14-
Also, be sure to have `git` available in your PATH, `npm` might need it (You can find git [here](https://git-scm.com/)).
13+
- #### Node installation on Windows
14+
15+
Just go on [official Node.js website](https://nodejs.org/) and download the installer.
16+
Also, be sure to have `git` available in your PATH, `npm` might need it (You can find git [here](https://git-scm.com/)).
1517

16-
- #### Node installation on Ubuntu
18+
- #### Node installation on Ubuntu
1719

18-
You can install nodejs and npm easily with apt install, just run the following commands.
20+
You can install nodejs and npm easily with apt install, just run the following commands.
1921

20-
$ sudo apt install nodejs
21-
$ sudo apt install npm
22+
$ sudo apt install nodejs
23+
$ sudo apt install npm
2224

23-
- #### Other Operating Systems
24-
You can find more information about the installation on the [official Node.js website](https://nodejs.org/) and the [official NPM website](https://npmjs.org/).
25+
- #### Other Operating Systems
26+
You can find more information about the installation on the [official Node.js website](https://nodejs.org/) and the [official NPM website](https://npmjs.org/).
2527

2628
If the installation was successful, you should be able to run the following command.
2729

@@ -48,18 +50,20 @@ If you need to update `npm`, you can make it using `npm`! Cool right? After runn
4850
## Configure environmental variables
4951

5052
Create a `.env` file then edit it with your settings. You will need:
51-
- ENV=development
52-
- PORT=[your_port]
53-
- MONGO_URI=[your_mongo_uri]
54-
- JWT_SECRET=[your_jwt_secret]
55-
- EXPIRY=[your_jwt_expiry_time]
56-
- SECRET=[your_secret_for_mongostore]
57-
- EMAIL=[your_email_address]
58-
- PASS=[your_email_password]
59-
- CLOUDINARY_CLOUD_NAME=[your_cloudinary_cloud_name]
60-
- CLOUDINARY_KEY=[your_cloudinary_key]
61-
- CLOUDINARY_SECRET=[your_cloudinary_secret]
62-
- MAPBOX_TOKEN=[your_mapbox_project]
53+
54+
- ENV=development
55+
- PORT=[your_port]
56+
- MONGO_URI=[your_mongo_uri]
57+
- JWT_SECRET=[your_jwt_secret]
58+
- EXPIRY=[your_jwt_expiry_time]
59+
- SECRET=[your_secret_for_mongostore]
60+
- EMAIL=[your_email_address]
61+
- PASS=[your_email_password]
62+
- CLOUDINARY_CLOUD_NAME=[your_cloudinary_cloud_name]
63+
- CLOUDINARY_KEY=[your_cloudinary_key]
64+
- CLOUDINARY_SECRET=[your_cloudinary_secret]
65+
- MAPBOX_TOKEN=[your_mapbox_project]
66+
6367
## Running the project
6468

6569
$ npm start

app.js

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
11
/* ------------ Imports ----------- */
22

3-
const express = require("express");
4-
const cors = require("cors");
5-
const mongoose = require("mongoose");
6-
const cookieParser = require("cookie-parser");
7-
const favicon = require("serve-favicon");
8-
const session = require("express-session");
9-
const MongoDBStore = require("connect-mongo")(session);
10-
const flash = require("express-flash");
11-
const helmet = require("helmet");
12-
const methodOverride = require("method-override");
3+
const express = require('express');
4+
const cors = require('cors');
5+
const mongoose = require('mongoose');
6+
const cookieParser = require('cookie-parser');
7+
const favicon = require('serve-favicon');
8+
const session = require('express-session');
9+
const MongoDBStore = require('connect-mongo')(session);
10+
const flash = require('express-flash');
11+
const helmet = require('helmet');
12+
const methodOverride = require('method-override');
1313

1414
/* ------------ Configs ----------- */
1515

1616
// initialize module to access .env variables
17-
require("dotenv").config();
17+
require('dotenv').config();
1818

1919
// access port from env
2020
const port = Number(process.env.PORT);
2121

2222
// db connection variables
2323
const uri = String(process.env.MONGO_URI);
2424
const connectOptions = {
25-
useNewUrlParser: true, // used for parsing the uri
26-
useCreateIndex: true, // use mongoose's default index
27-
useUnifiedTopology: true, // use the newer topology engine
28-
useFindAndModify: false, // allow findOneAndUpdate()
25+
useNewUrlParser: true, // used for parsing the uri
26+
useCreateIndex: true, // use mongoose's default index
27+
useUnifiedTopology: true, // use the newer topology engine
28+
useFindAndModify: false, // allow findOneAndUpdate()
2929
};
3030

3131
/* ------------ MongoDB Setup ----------- */
3232

3333
// initiate connection to mongodb
3434
mongoose
35-
.connect(uri, connectOptions)
36-
.then()
37-
.catch((err) => console.log("Error:" + err));
35+
.connect(uri, connectOptions)
36+
.then()
37+
.catch((err) => console.log('Error:' + err));
3838

3939
// log message on connection success
40-
mongoose.connection.once("open", () =>
41-
console.log("Connected to MongoDB successfully...")
40+
mongoose.connection.once('open', () =>
41+
console.log('Connected to MongoDB successfully...')
4242
);
4343

4444
const app = express();
4545

4646
const secret = process.env.SECRET;
4747

4848
const store = new MongoDBStore({
49-
url: uri,
50-
secret,
51-
touchAfter: 24 * 60 * 60,
49+
url: uri,
50+
secret,
51+
touchAfter: 24 * 60 * 60,
5252
});
5353

5454
// session initialization
55-
store.on("error", function (e) {
56-
console.log("SESSION STORE ERROR", e);
55+
store.on('error', function (e) {
56+
console.log('SESSION STORE ERROR', e);
5757
});
5858

5959
const sessionConfig = {
60-
store, // session store
61-
name: "session", // session name
62-
secret, // session secret
63-
resave: false, // don't save session if unmodified
64-
saveUninitialized: true, // don't create session until something stored
65-
cookie: {
66-
httpOnly: true, // don't let browser javascript access cookies
67-
expires: Date.now() + 1000 * 60 * 60 * 24 * 7, // expire in 7 days
68-
maxAge: 1000 * 60 * 60 * 24 * 7, // expire in 7 days
69-
},
60+
store, // session store
61+
name: 'session', // session name
62+
secret, // session secret
63+
resave: false, // don't save session if unmodified
64+
saveUninitialized: true, // don't create session until something stored
65+
cookie: {
66+
httpOnly: true, // don't let browser javascript access cookies
67+
expires: Date.now() + 1000 * 60 * 60 * 24 * 7, // expire in 7 days
68+
maxAge: 1000 * 60 * 60 * 24 * 7, // expire in 7 days
69+
},
7070
};
7171

7272
app.use(cors()); // allow cross-origin requests
@@ -75,41 +75,41 @@ app.use(express.urlencoded({ extended: true })); // parse the incoming requests
7575
app.use(cookieParser()); // parse the incoming requests with cookies
7676
app.use(session(sessionConfig)); // initialize session
7777
app.use(flash()); // initialize flash messages
78-
app.use(methodOverride("_method")); // override HTTP methods
78+
app.use(methodOverride('_method')); // override HTTP methods
7979
app.use(helmet({ contentSecurityPolicy: false }));
80-
app.use(favicon(__dirname + "/public/img/favicon.ico"));
80+
app.use(favicon(__dirname + '/public/img/favicon.ico'));
8181

8282
// use ejs template engine and allow serving static files
83-
app.use(express.static(__dirname + "/public"));
84-
app.set("view engine", "ejs");
83+
app.use(express.static(__dirname + '/public'));
84+
app.set('view engine', 'ejs');
8585

8686
//include routes from /
87-
app.get("/", (req, res) => {
88-
res.render("index");
87+
app.get('/', (req, res) => {
88+
res.render('index');
8989
});
9090

9191
//include routes from /users
92-
const userRouter = require("./routes/user.route");
93-
app.use("/users", userRouter);
92+
const userRouter = require('./routes/user.route');
93+
app.use('/users', userRouter);
9494

9595
//include routes from /garages
96-
const garageRouter = require("./routes/garage.route");
97-
app.use("/garage", garageRouter);
96+
const garageRouter = require('./routes/garage.route');
97+
app.use('/garage', garageRouter);
9898

9999
//include routes from /slots
100-
const slotRouter = require("./routes/slot.route");
101-
app.use("/slot", slotRouter);
100+
const slotRouter = require('./routes/slot.route');
101+
app.use('/slot', slotRouter);
102102

103103
//include routes from /booking
104-
const bookingRouter = require("./routes/booking.route");
105-
app.use("/booking", bookingRouter);
104+
const bookingRouter = require('./routes/booking.route');
105+
app.use('/booking', bookingRouter);
106106

107107
// handle all routes without endpoints
108-
app.get("*", (req, res) => {
109-
res.render("not-found");
108+
app.get('*', (req, res) => {
109+
res.render('not-found');
110110
});
111111

112112
// start the parkify server
113113
app.listen(port, () =>
114-
console.log(`Parkify running at http://localhost:${port}`)
115-
);
114+
console.log(`Parkify running at http://localhost:${port}`)
115+
);

cloudinary/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
const cloudinary = require("cloudinary").v2;
2-
const { CloudinaryStorage } = require("multer-storage-cloudinary");
1+
const cloudinary = require('cloudinary').v2;
2+
const { CloudinaryStorage } = require('multer-storage-cloudinary');
33

44
// cloudinary configuration
55
cloudinary.config({
6-
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
7-
api_key: process.env.CLOUDINARY_KEY,
8-
api_secret: process.env.CLOUDINARY_SECRET,
6+
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
7+
api_key: process.env.CLOUDINARY_KEY,
8+
api_secret: process.env.CLOUDINARY_SECRET,
99
});
1010

1111
const storage = new CloudinaryStorage({
12-
cloudinary, // Cloudinary instance
13-
params: {
14-
folder: "Parkify", // The name of the folder in cloudinary
15-
allowedFormats: ["jpeg", "png", "jpg"], // The formats you want to allow
16-
},
12+
cloudinary, // Cloudinary instance
13+
params: {
14+
folder: 'Parkify', // The name of the folder in cloudinary
15+
allowedFormats: ['jpeg', 'png', 'jpg'], // The formats you want to allow
16+
},
1717
});
1818

1919
module.exports = {
20-
cloudinary,
21-
storage,
20+
cloudinary,
21+
storage,
2222
};

0 commit comments

Comments
 (0)