Change ESLint rules

This commit is contained in:
Mylloon 2022-06-23 02:58:11 +02:00
parent 991c5313c5
commit cbaa37d1b0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 46 additions and 27 deletions

View file

@ -5,12 +5,31 @@
"es2021": true
},
"extends": [
"standard"
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"indent": ["error", 4]
"semi": ["warn", "always"],
"semi-spacing": "warn",
"keyword-spacing": ["warn", {
"before": true,
"after": true
}],
"no-multi-spaces": ["warn", {
"ignoreEOLComments": true,
"exceptions": {
"VariableDeclarator": true
}
}],
"key-spacing": "warn",
"space-before-blocks": "warn",
"space-before-function-paren": ["warn", "never"],
"space-infix-ops": "warn",
"brace-style": "warn",
"comma-spacing": "warn",
"indent": "warn",
"arrow-spacing": "warn"
}
}

View file

@ -1,12 +1,12 @@
const router = require('express').Router()
const marked = require('marked')
const router = require('express').Router();
const marked = require('marked');
const readme = require('../utils/readme')
const readme = require('../utils/readme');
// Home Page
router.get('/', (_, res) => {
readme.get()
.then(data => res.render('index', { readme: marked.parse(data) }))
})
.then(data => res.render('index', { readme: marked.parse(data) }));
});
module.exports = router
module.exports = router;

View file

@ -1,13 +1,13 @@
const express = require('express')
const express = require('express');
const app = express()
const port = 3000
const app = express();
const port = 3000;
app.set('views', 'src/views')
app.set('view engine', 'ejs')
app.set('views', 'src/views');
app.set('view engine', 'ejs');
app.use('/', require('./routes'))
app.use('/', require('./routes'));
app.listen(port, () => {
console.log(`Constnium started on port ${port}.`)
})
console.log(`Constnium started on port ${port}.`);
});

View file

@ -1,29 +1,29 @@
const fetch = require('node-fetch')
const fetch = require('node-fetch');
// URL of the repo
const repoURL = 'https://git.kennel.ml/Anri/Constnium/raw/branch/main/README.md'
const repoURL = 'https://git.kennel.ml/Anri/Constnium/raw/branch/main/README.md';
// Store the data from the repo
let data = null
let data = null;
// Store last time data as been pulled from the repo
let timestamp = 0
let timestamp = 0;
// Retrieve the data from the repo
async function get () {
const now = Date.now()
async function get() {
const now = Date.now();
// If data is older than one day, refresh it
if (Math.ceil(Math.abs(now - timestamp) / (1000 * 3600 * 24)) > 2 || data === null) {
await fetch(repoURL)
.then(res => {
data = res.text()
timestamp = now
})
data = res.text();
timestamp = now;
});
}
return data
return data;
}
module.exports = {
get
}
};