Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter addition #12

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"airbnb-base"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"linebreak-style": ["error", "windows"],
"no-param-reassign": 0
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ package-lock.json
public/package-lock.json
.vs/
yarn.lock
.vscode/
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"buildPublic": "cd public && npm run build",
"prestart": "npm run -s build",
"start": "node dist/index.js",
"dev": "nodemon -w ./src --exec \"babel-node ./src\""
"dev": "nodemon -w ./src --exec \"babel-node ./src\"",
"lint": "eslint"
},
"keywords": [],
"author": "etiaro",
Expand All @@ -25,6 +26,7 @@
"moment": "^2.24.0",
"mysql": "^2.18.1",
"play-sound": "^1.1.3",
"regenerator-runtime": "^0.13.7",
"request": "^2.88.2",
"serialport": "^9.0.1",
"youtube-mp3-downloader": "^0.7.7",
Expand All @@ -35,6 +37,9 @@
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"eslint": "^7.28.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
"nodemon": "^2.0.7",
"rimraf": "^2.7.1"
}
Expand Down
3 changes: 2 additions & 1 deletion public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint"
},
"proxy": "http://localhost:80",
"eslintConfig": {
Expand Down
934 changes: 480 additions & 454 deletions src/database/database.js

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import "regenerator-runtime/runtime.js";
import 'regenerator-runtime/runtime';
import express from 'express';
import bodyParser from 'body-parser';
import { notFound, catchErrors } from './middlewares/errors';
import login from "./routes/login";
import player from "./routes/player";
import notification from './routes/notification';
import cfg from './config/database';
import gCfg from './config/general';
import {database} from './database/database';
import {player as playerController} from './player/player';
import cors from 'cors';
import path from 'path';
import fs from 'fs';
import http from 'http';
import https from 'https';
import { notFound, catchErrors } from './middlewares/errors';
import login from './routes/login';
import player from './routes/player';
import notification from './routes/notification';
import cfg from './config/database';
import gCfg from './config/general';
import { database } from './database/database';
import { player as playerController } from './player/player';

database.init(cfg.db,()=>{
playerController.init();
database.init(cfg.db, () => {
playerController.init();
});

const app = express();


app.set('secretKey', gCfg.secret);
app.use(cors());

Expand All @@ -33,7 +32,7 @@ app.use('/api/login', login());
app.use('/api/player', player());
app.use('/api/notification', notification());

//hosting built react app(front end)
// hosting built react app(front end)
app.use(express.static(path.join(__dirname, '../public/build/')));
app.use('/playlist', express.static(path.join(__dirname, '../public/build/')));
app.use('/library', express.static(path.join(__dirname, '../public/build/')));
Expand All @@ -46,10 +45,10 @@ app.use(notFound);
app.use(catchErrors);

// Start
var httpServ = http.createServer(app);
const httpServ = http.createServer(app);
httpServ.listen(80);

var privateKey = fs.readFileSync(path.join(__dirname, 'certificates', '/alice.key'), 'utf8');
var certificate = fs.readFileSync(path.join(__dirname, 'certificates', '/alice.crt'), 'utf8');
var httpsServ = https.createServer({key: privateKey, cert: certificate}, app);
const privateKey = fs.readFileSync(path.join(__dirname, 'certificates', '/alice.key'), 'utf8');
const certificate = fs.readFileSync(path.join(__dirname, 'certificates', '/alice.crt'), 'utf8');
const httpsServ = https.createServer({ key: privateKey, cert: certificate }, app);
httpsServ.listen(443);
21 changes: 8 additions & 13 deletions src/middlewares/errors.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import express from 'express';

export function notFound(req, res, next) {
console.log('404', req.originalUrl, req.connection.remoteAddress);
return res.status(404).sendFile(__dirname + "/404.html");
const err = new Error('404 page not found');
err.status = 404;
next(err);
export function notFound(req, res) {
console.log('404', req.originalUrl, req.connection.remoteAddress);
return res.status(404).sendFile(`${__dirname}/404.html`);
}

export async function catchErrors(err, req, res, next) {
res.status(err.status || 500).send({
message: err.message
});
}
export async function catchErrors(err, req, res) {
res.status(err.status || 500).send({
message: err.message,
});
}
Loading