init commit babey

currently basically just a boilerplate and does Absolutely Fucking Nothing
This commit is contained in:
jill 2020-09-02 15:48:41 +03:00
commit ca0852800e
Signed by untrusted user who does not match committer: oat
GPG key ID: DD83A9617A252385
8 changed files with 685 additions and 0 deletions

40
src/index.ts Normal file
View file

@ -0,0 +1,40 @@
import * as express from 'express';
import * as mongoose from 'mongoose';
import * as fs from 'fs';
const config = JSON.parse(fs.readFileSync('./config/config.json', {encoding: 'utf8'}));
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
});
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', dbClient);
app.set('config', config);
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, () => {
console.log(`expressjs server launched on port ${config.port}, should now function properly`);
});
});