Skip to content

Commit d104eb0

Browse files
update packages
1 parent 5dfb413 commit d104eb0

File tree

5 files changed

+846
-602
lines changed

5 files changed

+846
-602
lines changed

Diff for: .eslintrc.js

+71-70
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
11
module.exports = {
2-
env: {
3-
browser: true,
4-
es6: true,
5-
node: true,
6-
},
7-
extends: [
8-
'airbnb',
2+
env: {
3+
browser: true,
4+
es6: true,
5+
node: true,
6+
},
7+
extends: [
8+
// 'plugin:@typescript-eslint/recommended',
9+
'prettier',
10+
],
11+
globals: {
12+
Atomics: 'readonly',
13+
SharedArrayBuffer: 'readonly',
14+
},
15+
parser: '@typescript-eslint/parser',
16+
parserOptions: {
17+
ecmaVersion: 2021,
18+
sourceType: 'module',
19+
},
20+
plugins: ['@typescript-eslint', 'prettier', 'import', 'promise', 'sort-destructure-keys'],
21+
root: true,
22+
rules: {
23+
'arrow-parens': 'off',
24+
camelcase: 'warn',
25+
'consistent-return': 'off',
26+
'comma-dangle': ['warn', 'always-multiline'],
27+
'generator-star-spacing': 'off',
28+
'import/no-unresolved': [
29+
'error',
30+
{
31+
caseSensitive: false,
32+
},
933
],
10-
globals: {
11-
Atomics: 'readonly',
12-
SharedArrayBuffer: 'readonly',
13-
},
14-
parser: '@babel/eslint-parser',
15-
parserOptions: {
16-
ecmaVersion: 2021,
17-
sourceType: 'module',
18-
},
19-
plugins: [
20-
'babel',
21-
'import',
22-
'promise',
23-
'sort-destructure-keys',
34+
'max-len': [
35+
'warn',
36+
{
37+
code: 100,
38+
ignoreComments: true,
39+
ignoreStrings: true,
40+
ignoreTemplateLiterals: true,
41+
ignoreUrls: true,
42+
},
2443
],
25-
rules: {
26-
'arrow-parens': 'off',
27-
camelcase: 'warn',
28-
'consistent-return': 'off',
29-
'comma-dangle': ['warn', 'always-multiline'],
30-
'function-paren-newline': ['warn', 'consistent'],
31-
'generator-star-spacing': 'off',
32-
'import/no-unresolved': ['error', {
33-
caseSensitive: false,
34-
}],
35-
indent: ['warn', 4, {
36-
ArrayExpression: 'first',
37-
CallExpression: { arguments: 'first' },
38-
flatTernaryExpressions: true,
39-
FunctionDeclaration: { parameters: 'first' },
40-
FunctionExpression: { parameters: 'first' },
41-
ignoreComments: true,
42-
ignoredNodes: [
43-
'ConditionalExpression',
44-
],
45-
ImportDeclaration: 'first',
46-
MemberExpression: 1,
47-
ObjectExpression: 'first',
48-
SwitchCase: 1,
49-
VariableDeclarator: 'first',
50-
}],
51-
'max-len': ['warn', {
52-
code: 120,
53-
ignoreComments: true,
54-
ignoreStrings: true,
55-
ignoreTemplateLiterals: true,
56-
ignoreUrls: true,
57-
}],
58-
'no-console': 'off',
59-
'no-else-return': ['warn', {
60-
allowElseIf: true,
61-
}],
62-
'no-multi-assign': 'off',
63-
'no-nested-ternary': 'off',
64-
'no-unneeded-ternary': 'warn',
65-
'no-unused-expressions': ['warn', {
66-
allowShortCircuit: true,
67-
}],
68-
'no-use-before-define': 'off',
69-
'promise/param-names': 'error',
70-
'promise/always-return': 'error',
71-
'promise/catch-or-return': 'error',
72-
'promise/no-native': 'off',
73-
},
44+
'no-console': 'off',
45+
'no-else-return': [
46+
'warn',
47+
{
48+
allowElseIf: true,
49+
},
50+
],
51+
'no-multi-assign': 'off',
52+
'no-nested-ternary': 'off',
53+
'no-unneeded-ternary': 'warn',
54+
'no-unused-expressions': [
55+
'warn',
56+
{
57+
allowShortCircuit: true,
58+
},
59+
],
60+
'no-use-before-define': 'off',
61+
'prettier/prettier': [
62+
'warn',
63+
{
64+
printWidth: 100,
65+
singleQuote: true,
66+
// tabWidth: 4,
67+
trailingComma: 'all',
68+
},
69+
],
70+
'promise/param-names': 'error',
71+
'promise/always-return': 'error',
72+
'promise/catch-or-return': 'error',
73+
'promise/no-native': 'off',
74+
},
7475
};

Diff for: package.json

+19-16
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,29 @@
1414
"author": "",
1515
"license": "ISC",
1616
"devDependencies": {
17-
"@babel/cli": "^7.13.0",
18-
"@babel/core": "^7.13.0",
19-
"@babel/node": "^7.13.0",
20-
"@babel/preset-env": "^7.13.0",
17+
"@babel/cli": "^7.13.16",
18+
"@babel/core": "^7.14.0",
19+
"@babel/node": "^7.13.13",
20+
"@babel/preset-env": "^7.14.1",
21+
"@typescript-eslint/eslint-plugin": "4.22.1",
22+
"@typescript-eslint/parser": "^4.0.0",
23+
"eslint": "^7.0.0",
24+
"eslint-config-prettier": "^8.3.0",
25+
"eslint-plugin-import": "^2.22.1",
26+
"eslint-plugin-prettier": "^3.4.0",
27+
"eslint-plugin-promise": "^5.1.0",
28+
"eslint-plugin-sort-destructure-keys": "^1.3.5",
2129
"nodemon": "^2.0.7",
22-
"sqlite3": "^5.0.2"
30+
"prettier": "^2.2.1",
31+
"sqlite3": "^5.0.2",
32+
"typescript": "^4.2.4"
2333
},
2434
"dependencies": {
25-
"@babel/eslint-parser": "^7.13.0",
2635
"body-parser": "^1.19.0",
27-
"dotenv": "^8.2.0",
36+
"dotenv": "^9.0.0",
2837
"escape-html": "^1.0.3",
29-
"eslint": "^7.20.0",
30-
"eslint-config-airbnb": "^18.2.1",
31-
"eslint-plugin-babel": "^5.3.1",
32-
"eslint-plugin-import": "^2.22.1",
33-
"eslint-plugin-promise": "^4.3.1",
34-
"eslint-plugin-sort-destructure-keys": "^1.3.5",
3538
"express": "^4.17.1",
36-
"knex": "^0.21.18",
37-
"marked": "^2.0.0"
39+
"knex": "^0.95.4",
40+
"marked": "^2.0.3"
3841
}
39-
}
42+
}

Diff for: src/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import bodyParser from 'body-parser';
21
import escapeHtml from 'escape-html';
32
import express from 'express';
43
import fs from 'fs';
@@ -23,13 +22,14 @@ app.engine('md', (filepath, options, fn) => (
2322
app.set('views', path.join(__dirname, 'views'));
2423
app.set('view engine', 'md'); // makes .md the default extension
2524

26-
app.get('/help', (req, res) => res.render('instructions', { title: 'Markdown Example' }));
25+
app.get('/help', (req, res) => res.render('instructions', { title: 'Usage instructions' }));
2726

2827
// this is the business end of this thing
29-
app.use(bodyParser.urlencoded({ extended: true, limit: '50mb' }));
30-
app.use(bodyParser.json({ limit: '50mb' }));
31-
app.use(bodyParser.text({ limit: '50mb' }));
32-
// app.use(bodyParser.raw()); // TODO: accept files
28+
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
29+
app.use(express.json({ limit: '50mb' }));
30+
app.use(express.text({ limit: '50mb' }));
31+
// app.use(express.raw()); // TODO: accept files
32+
3333
app.use('/', urlRoutes(databaseHandlers));
3434

3535
app.listen(PORT, () => console.log(`Diminution is listening on port ${PORT}`));

Diff for: src/routes/index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ const router = express.Router();
1111

1212
// Diminution may be used as a middleware, if you want to set its URLs at the root of another site.
1313
// This EnvVar tells diminution you have a URL they can redirect/passthrough to if it cannot handle a request
14-
const passthrough = process.env.PASSTHROUGH_URL;
15-
const filterPassthrough = process.env.PASSTHROUGH_FILTER;
14+
const {
15+
PASSTHROUGH_URL: passthrough,
16+
PASSTHROUGH_FILTER_SPLATS: filterPassthrough,
17+
} = process.env;
1618

1719
const diminutioRoutes = ({
1820
allURLs,
@@ -46,7 +48,7 @@ const diminutioRoutes = ({
4648
: { longUrl: url } // this shouldn't happen, unless purposely, while working in dev mode
4749
);
4850

49-
process.env.DEBUG && console.log('request made from', req.get('host'), '\n', req.originalUrl);
51+
process.env.DEBUG && console.log('\n\n---\nRequest made from', req.get('host'), '\n', req.originalUrl);
5052

5153
return res.headersSent || getURL(filter, results => (
5254
process.env.DEBUG && console.log(filter, results),

0 commit comments

Comments
 (0)