mirror of
https://gitlab.com/oatmealine/cumstorm.git
synced 2024-06-29 04:02:31 +02:00
config stuff
This commit is contained in:
parent
f50a975df2
commit
7bd647979d
12
src/index.ts
12
src/index.ts
|
@ -1,19 +1,19 @@
|
|||
import * as express from 'express';
|
||||
import { MongoClient } from 'mongodb';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const dbUrl = 'mongodb://localhost:27017'; // hardcoded for now
|
||||
const dbName = 'cumstormgdps'; // hardcoded for now
|
||||
const config = JSON.parse(fs.readFileSync('./config/config.json', {encoding: 'utf8'}));
|
||||
|
||||
const dbClient = new MongoClient(dbUrl);
|
||||
const dbClient = new MongoClient(config.dbconnectionURL);
|
||||
|
||||
let db;
|
||||
|
||||
console.log(`connecting to mongodb database ${dbName}@${dbUrl}...`);
|
||||
console.log('connecting to mongodb database...');
|
||||
dbClient.connect((err) => {
|
||||
if (err) return console.log(err);
|
||||
console.log('connected to database!');
|
||||
|
||||
db = dbClient.db(dbName);
|
||||
db = dbClient.db(config.dbname);
|
||||
const app = express();
|
||||
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
@ -26,5 +26,5 @@ dbClient.connect((err) => {
|
|||
|
||||
app.get('*', (req, res) => res.status(404).send('wrong page dumbass'));
|
||||
|
||||
app.listen(3000);
|
||||
app.listen(config.port);
|
||||
});
|
Loading…
Reference in a new issue