pull/4/head
Cameron Clough 2022-03-21 13:13:22 +00:00
parent 7680c2fb98
commit 7da0fc9640
No known key found for this signature in database
GPG Key ID: BFB3B74B026ED43F
7 changed files with 34 additions and 40 deletions

13
.babelrc.json 100644
View File

@ -0,0 +1,13 @@
{
"sourceMaps": "inline",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}

View File

@ -1,6 +0,0 @@
cabana
certs
node_modules
static
test
config.js

1
.eslintignore 120000
View File

@ -0,0 +1 @@
.gitignore

View File

@ -1,11 +1,11 @@
{ {
"root": true,
"extends": [ "extends": [
"airbnb-base" "airbnb-base"
], ],
"env": { "env": {
"es6": true, "es6": true,
"node": true, "node": true
"browser": false // do we need this? none of this code will ever run on a browswer
}, },
"plugins": [ "plugins": [
"no-floating-promise" "no-floating-promise"
@ -16,6 +16,17 @@
// retropilot: this seems dumb. do whatever looks nice. // retropilot: this seems dumb. do whatever looks nice.
"arrow-body-style": "off", "arrow-body-style": "off",
// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
// retropilot: ignore comments
"max-len": ["error", 100, 2, {
"ignoreUrls": true,
"ignoreComments": true,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}],
// disallow use of unary operators, ++ and -- // disallow use of unary operators, ++ and --
// http://eslint.org/docs/rules/no-plusplus // http://eslint.org/docs/rules/no-plusplus
// retropilot: we allow them in the for loop // retropilot: we allow them in the for loop
@ -31,17 +42,6 @@
// retropilot: permit referencing functions before they're defined // retropilot: permit referencing functions before they're defined
"no-use-before-define": ["error", { "functions": false }], "no-use-before-define": ["error", { "functions": false }],
// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
// retropilot: ignore comments
"max-len": ["error", 100, 2, {
"ignoreUrls": true,
"ignoreComments": true,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}],
// TODO: fix and remove // TODO: fix and remove
// retropilot: we are in the process of removing all of these // retropilot: we are in the process of removing all of these
"no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true }], "no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true }],

View File

@ -21,7 +21,7 @@ function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) {
const { sep } = path; const { sep } = path;
const initDir = path.isAbsolute(targetDir) ? sep : ''; const initDir = path.isAbsolute(targetDir) ? sep : '';
const baseDir = isRelativeToScript ? global.__basedir : '.'; const baseDir = isRelativeToScript ? __dirname : '.';
return targetDir.split(sep).reduce((parentDir, childDir) => { return targetDir.split(sep).reduce((parentDir, childDir) => {
const curDir = path.resolve(baseDir, parentDir, childDir); const curDir = path.resolve(baseDir, parentDir, childDir);

View File

@ -1,8 +1,6 @@
import 'dotenv/config'; import 'dotenv/config';
import http from 'http'; import http from 'http';
import log4js from 'log4js'; import log4js from 'log4js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
log4js.configure({ log4js.configure({
appenders: { logfile: { type: 'file', filename: 'server.log' }, out: { type: 'console' } /* {type: "file", filename: "server1.log"} */ }, appenders: { logfile: { type: 'file', filename: 'server.log' }, out: { type: 'console' } /* {type: "file", filename: "server1.log"} */ },
@ -15,11 +13,6 @@ process.on('unhandledRejection', (error, p) => {
console.dir(error.stack); console.dir(error.stack);
}); });
// TODO evaluate if this is the best way to determine the root of project
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
global.__basedir = __dirname;
const main = async () => { const main = async () => {
const logger = log4js.getLogger('default'); const logger = log4js.getLogger('default');
const httpServer = http.createServer(await require('./app').default); const httpServer = http.createServer(await require('./app').default);

View File

@ -1,8 +1,7 @@
import 'dotenv/config'; import 'dotenv/config';
import crypto from 'crypto'; import crypto from 'crypto';
import fs from 'fs'; import fs from 'fs';
import path, { dirname } from 'path'; import path from 'path';
import { fileURLToPath } from 'url';
import log4js from 'log4js'; import log4js from 'log4js';
import dirTree from 'directory-tree'; import dirTree from 'directory-tree';
@ -13,20 +12,16 @@ import ffprobeStatic from 'ffprobe-static';
import orm from '../models/index.model'; import orm from '../models/index.model';
const startTime = Date.now();
let lastCleaningTime = 0; let lastCleaningTime = 0;
let startTime = Date.now();
log4js.configure({ log4js.configure({
appenders: { logfile: { type: 'file', filename: 'worker.log' }, out: { type: 'console' } }, appenders: { logfile: { type: 'file', filename: 'worker.log' }, out: { type: 'console' } },
categories: { default: { appenders: ['out', 'logfile'], level: 'info' } } categories: { default: { appenders: ['out', 'logfile'], level: 'info' } },
}); });
const logger = log4js.getLogger('default'); const logger = log4js.getLogger('default');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
global.__basedir = __dirname;
function initializeStorage() { function initializeStorage() {
const verifiedPath = mkDirByPathSync(process.env.STORAGE_PATH, { isRelativeToScript: (process.env.STORAGE_PATH.indexOf('/') !== 0) }); const verifiedPath = mkDirByPathSync(process.env.STORAGE_PATH, { isRelativeToScript: (process.env.STORAGE_PATH.indexOf('/') !== 0) });
if (verifiedPath != null) { if (verifiedPath != null) {

View File

@ -1,6 +1,5 @@
import jwt from 'jsonwebtoken';
import crypto from 'crypto'; import crypto from 'crypto';
import jwt from 'jsonwebtoken';
const devicePrivateKey = "-----BEGIN RSA PRIVATE KEY-----\n" + const devicePrivateKey = "-----BEGIN RSA PRIVATE KEY-----\n" +
"MIIEowIBAAKCAQEAwhH9PqBd/R/QPvcf1Gom5Vp+zYb1+DLjiFMC7a1lNvV8MUqK\n" + "MIIEowIBAAKCAQEAwhH9PqBd/R/QPvcf1Gom5Vp+zYb1+DLjiFMC7a1lNvV8MUqK\n" +
@ -65,7 +64,6 @@ function getSerial() {
} }
export default { export default {
makeJWT, getImei, getSerial, rougePublicKey, devicePubKey, devicePrivateKey, alreadyRegisteredEmail, newUserEmail makeJWT, getImei, getSerial, rougePublicKey, devicePubKey, devicePrivateKey, alreadyRegisteredEmail, newUserEmail
}; };