Skip to content

Commit

Permalink
Merge pull request #57 from push-protocol/add-prettier
Browse files Browse the repository at this point in the history
add: prettier + eslint + husky
  • Loading branch information
Igx22 authored Jul 19, 2024
2 parents 784891d + 86c9521 commit 391fd61
Show file tree
Hide file tree
Showing 49 changed files with 2,676 additions and 1,647 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public
build
dist
20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"env": {
"browser": true,
"es2021": true
},
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "unused-imports", "simple-import-sort"],
"rules": {
"unused-imports/no-unused-imports": "error",
"prefer-const": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-var": "error"
}
}
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public
build
dist
9 changes: 9 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
printWidth: 100
tabWidth: 2
singleQuote: true
semi: false
jsxSingleQuote: true
quoteProps: as-needed
trailingComma: none
bracketSpacing: true
bracketSameLine: false
32 changes: 24 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@
"dev": "ts-node-dev --respawn --inspect=9229 --transpile-only ./src/app.ts",
"dev6001": "ts-node-dev --inspect=6001 --transpile-only ./src/app.ts",
"dev6002": "ts-node-dev --inspect=6002 --transpile-only ./src/app.ts",
"heroku-postbuild": "npm run build",
"start": "nodemon",
"inspect": "nodemon --inspect src/app.ts",
"test": "mocha --inspect=9229 -r ts-node/register tests/**/*.test.ts --require tests/root.ts --serial",
"lint": "npm run lint:js ",
"lint:eslint": "eslint --ignore-path .gitignore --ext .ts",
"lint:js": "npm run lint:eslint src/",
"lint:fix": "npm run lint:js -- --fix"
"lint": "eslint '**/*.{js,ts,jsx,tsx}'",
"lint:fix": "eslint --fix '**/*.{js,ts,jsx,tsx}'",
"format": "prettier --write '**/*.{js,ts,jsx,tsx}'",
"prepare": "husky"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
]
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -112,15 +122,21 @@
"@types/mongoose": "^5.3.17",
"@types/mysql": "^2.15.21",
"@types/node": "^10.17.60",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"@typescript-eslint/parser": "^1.7.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"aws-sdk": "2.770.0",
"eslint": "^8.7.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unused-imports": "^4.0.0",
"husky": "^9.0.11",
"jest": "^24.1.0",
"lint-staged": "^15.2.7",
"mocha": "^9.1.3",
"nodemon": "^2.0.1",
"prettier": "^1.17.0",
"prettier": "^3.3.3",
"pretty-quick": "^4.0.0",
"ts-jest": "^24.0.0",
"ts-node": "^10.4.0",
"ts-node-dev": "1.0.0-pre.44",
Expand Down
24 changes: 12 additions & 12 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Router } from 'express';

import {storageRoutes} from './routes/storageRoutes';
import {ExpressUtil} from "../utilz/expressUtil";

// guaranteed to get dependencies
export default () => {
const app = Router();
app.use(ExpressUtil.handle);
storageRoutes(app);
return app;
};
import { Router } from 'express'

import { ExpressUtil } from '../utilz/expressUtil'
import { storageRoutes } from './routes/storageRoutes'

// guaranteed to get dependencies
export default () => {
const app = Router()
app.use(ExpressUtil.handle)
storageRoutes(app)
return app
}
11 changes: 6 additions & 5 deletions src/api/middlewares/onlyLocalhost.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Container } from 'typedi'

import config from '../../config'

var dns = require('dns')
var os = require('os')
var ifaces = os.networkInterfaces()
const dns = require('dns')
const os = require('os')
const ifaces = os.networkInterfaces()

/**
* @param {*} req Express req Object
Expand All @@ -14,8 +15,8 @@ const onlyLocalhost = async (req, res, next) => {
const Logger = Container.get('logger')
try {
// Check if ip is localhost and only continue
var ip = req.connection.remoteAddress
var host = req.get('host')
const ip = req.connection.remoteAddress
const host = req.get('host')

if (config.environment === 'production') {
// Return with unauthorized error
Expand Down
Loading

0 comments on commit 391fd61

Please sign in to comment.