Compare commits

..

No commits in common. "1eebe45e4e8abbc682eadbbb2e60954e28907b81" and "ca0852800e3f56ffb00b655d9663e5129c6238cf" have entirely different histories.

7 changed files with 17 additions and 1509 deletions

View file

@ -1 +0,0 @@
**/*.js

View file

@ -1,37 +0,0 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"warn",
"tab"
],
"linebreak-style": "warn",
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

3
.gitignore vendored
View file

@ -1,5 +1,4 @@
.vscode
node_modules
built
config/config.json
*.log
config/config.json

1421
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -13,12 +13,6 @@
"dependencies": {
"express": "^4.17.1",
"mongoose": "^5.10.2",
"typescript": "^4.0.2",
"winston": "^3.3.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"eslint": "^7.8.1"
"typescript": "^4.0.2"
}
}

View file

@ -1,62 +1,40 @@
import * as express from 'express';
import * as mongoose from 'mongoose';
import * as fs from 'fs';
import * as winston from 'winston';
import * as format from './lib/format';
const config = JSON.parse(fs.readFileSync('./config/config.json', {encoding: 'utf8'}));
const db = mongoose.connect(`${config.dbconnectionURL}/${config.dbname}`, {
useNewUrlParser: true, // idfk what any of this does i just copied an example
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
const dbClient = mongoose.connect(`${config.dbconnectionURL}/${config.dbname}`, {
useNewUrlParser: true, // idfk what any of this does i just copied an example
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
});
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.printf(log => `${format.formatTime(new Date(log.timestamp))} | ${log.message}`)
),
transports: [
new winston.transports.File({filename: `${config.name}-error.log`, level: 'error'}),
new winston.transports.File({filename: `${config.name}.log`}),
new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp(),
winston.format.printf(log =>
`${format.formatTime(new Date(log.timestamp))} - [${log.level}] ${log.message}`
)
),
level: process.env.DEBUG === 'true' ? 'silly' : 'info'
})
]
});
logger.info('connecting to mongodb database');
db.then(() => {
logger.info('connected to database!');
console.log('connecting to mongodb database...');
dbClient.then(() => {
console.log('connected to database!');
const app = express();
app.use(express.urlencoded({ extended: true }));
app.set('db', db);
app.set('db', dbClient);
app.set('config', config);
app.set('logger', logger);
app.get('/', (req, res) => {
res.send(`${config.name} homepage - unfinished`);
});
app.get('/recent', (req, res) => {
let query = req.query;
});
app.get('*', (req, res) => {
res.status(404).send('404');
});
app.listen(config.port, () => {
logger.info(`expressjs server launched on port ${config.port}, should now function properly`);
console.log(`expressjs server launched on port ${config.port}, should now function properly`);
});
});

View file

@ -1,6 +0,0 @@
export function formatTime(date: Date) : string {
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
return `${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes} UTC`;
}