Change ESLint rules
This commit is contained in:
parent
991c5313c5
commit
cbaa37d1b0
4 changed files with 46 additions and 27 deletions
|
@ -5,12 +5,31 @@
|
||||||
"es2021": true
|
"es2021": true
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"standard"
|
"eslint:recommended"
|
||||||
],
|
],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": "latest"
|
"ecmaVersion": "latest"
|
||||||
},
|
},
|
||||||
"rules": {
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const router = require('express').Router()
|
const router = require('express').Router();
|
||||||
const marked = require('marked')
|
const marked = require('marked');
|
||||||
|
|
||||||
const readme = require('../utils/readme')
|
const readme = require('../utils/readme');
|
||||||
|
|
||||||
// Home Page
|
// Home Page
|
||||||
router.get('/', (_, res) => {
|
router.get('/', (_, res) => {
|
||||||
readme.get()
|
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;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const express = require('express')
|
const express = require('express');
|
||||||
|
|
||||||
const app = express()
|
const app = express();
|
||||||
const port = 3000
|
const port = 3000;
|
||||||
|
|
||||||
app.set('views', 'src/views')
|
app.set('views', 'src/views');
|
||||||
app.set('view engine', 'ejs')
|
app.set('view engine', 'ejs');
|
||||||
|
|
||||||
app.use('/', require('./routes'))
|
app.use('/', require('./routes'));
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Constnium started on port ${port}.`)
|
console.log(`Constnium started on port ${port}.`);
|
||||||
})
|
});
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
const fetch = require('node-fetch')
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
// URL of the repo
|
// 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
|
// Store the data from the repo
|
||||||
let data = null
|
let data = null;
|
||||||
|
|
||||||
// Store last time data as been pulled from the repo
|
// Store last time data as been pulled from the repo
|
||||||
let timestamp = 0
|
let timestamp = 0;
|
||||||
|
|
||||||
// Retrieve the data from the repo
|
// Retrieve the data from the repo
|
||||||
async function get () {
|
async function get() {
|
||||||
const now = Date.now()
|
const now = Date.now();
|
||||||
// If data is older than one day, refresh it
|
// If data is older than one day, refresh it
|
||||||
if (Math.ceil(Math.abs(now - timestamp) / (1000 * 3600 * 24)) > 2 || data === null) {
|
if (Math.ceil(Math.abs(now - timestamp) / (1000 * 3600 * 24)) > 2 || data === null) {
|
||||||
await fetch(repoURL)
|
await fetch(repoURL)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
data = res.text()
|
data = res.text();
|
||||||
timestamp = now
|
timestamp = now;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get
|
get
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in a new issue